lounar Δημοσ. 19 Νοεμβρίου 2007 Δημοσ. 19 Νοεμβρίου 2007 καλησπερα παιδες! παρακατω βλεπετε τον κωδικα για το γνωστο neko project! η ερωτηση μου ειναι πως θα κανω το γατι να κινειται σε κυματοειδη κινηση! στην γραμμη που θα δειτε με ***** ****** ειναι μια for εκει λοιπον πρεπει να μπει αλλη μια For καθως κ καποιες μεταβλητεσ xpos1 xpos2 ypos1 ypos2 κλπ! αν καποιοσ εχει ιδεα πως γινεται pls post!!! >package graphicsfontsetc; import java.applet.*; import java.awt.*; public class neko extends Applet implements Runnable { Image nekopics[] = new Image[9]; Image currentimg; Thread runner; int xpos; public void init() { String nekosrc[] = {"right1.gif", "right2.gif", "stop.gif", "yawn.gif", "scratch1.gif", "scratch2.gif", "sleep1.gif", "sleep2.gif", "awake.gif"}; for (int i = 0; i < nekopics.length; i++) { nekopics[i] = getImage(getCodeBase(), "myimages/" + nekosrc[i]); } setBackground(Color.white); } public void start() { if (runner == null) { runner = new Thread(this); runner.start(); } } public void stop() { if (runner != null) { runner.stop(); runner = null; } } public void run() { nekorun(0, getSize().width / 2); currentimg = nekopics[2]; repaint(); pause(1000); currentimg = nekopics[3]; repaint(); pause(100); nekoscratch(4); nekosleep(8); currentimg = nekopics[8]; repaint(); pause(500); nekorun(xpos, getSize().width + 15); } void nekorun(int start, int end) { currentimg = nekopics[0]; ***** for (int i = start; i < end; i +=10) { ******* xpos = i; } if (currentimg == nekopics[0]) currentimg = nekopics[1]; else currentimg = nekopics[0]; repaint(); pause(150); } } void nekoscratch(int numtimes){ for(int i = numtimes; i > 0; i--){ currentimg = nekopics[4]; repaint(); pause(150); currentimg = nekopics[5]; repaint(); pause(150); } } void nekosleep(int numtimes){ for (int i = numtimes; i> 0; i--){ currentimg = nekopics[6]; repaint(); pause(250); currentimg = nekopics[7]; repaint(); pause(250); } } void pause(int time){ try{ Thread.sleep(time);} catch (InterruptedException e){} } public void paint (Graphics g){ if(currentimg != null) g.drawImage(currentimg, xpos, ypos, this); }
Προτεινόμενες αναρτήσεις
Αρχειοθετημένο
Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.