Saturday, December 24, 2011

PLEASE HELP!!! really easy java help?

ok so i made this applet for my project. heres the part i need the help in.


i made this boat using polygons and i need it to move to the left...i dont know how to please help!!! thanks a lot!!! :D








heres the boat part of the code








public class SummerHoliday extends Applet implements ActionListener, Runnable





// boat deck points


int xCoords[] = {50, 300, 235, 100}; // x cordinates array


int yCoords[] = {455, 455, 515, 515}; // y cordinates array





//boat sale cordinates


int xCoorda[] = {135, 135, 145, 145}; //x cordinate array


int yCoorda[] = {460, 300, 385, 425}; //y cordinate array





public void paint (graphics g)





//************************************鈥?br>

//BOAT


//boat deck


Color boatdeck = new Color (147, 73, 0);


g1.setColor (boatdeck);


g1.fillPolygon (xCoords, yCoords, 4); // this makes the boat and declare the points


if (asd1 %26lt; 60 || asd1 %26gt; 120)


asd1 = 60;


asd1 = asd1 + 3;











//boat sale


Color boatsale = new Color (0, 0, 0);


g1.setColor (boatsale);


g1.fillPolygon (xCoorda, yCoorda, 4);








//human1 on the boat


Color humanface = new Color (251, 202, 153); //color human face


g1.setColor (humanface); //tells color what


g1.fillOval (90, 425, 15, 15); //makes face


Color humanshirt = new Color (255, 0, 0); //color for his shirt


g1.setColor (humanshirt); //tells color what


g1.fillRect (90, 440, 15, 15); //makes shirt


Color humaneyes = new Color (0, 0, 0); //color of eye 1


g1.setColor (humaneyes); //detects eye 1


g1.fillOval (92, 429, 5, 5); //makes eye 1


Color humaneye2 = new Color (0, 0, 0); //color of eye 2


g1.setColor (humaneye2); //detects eye 2


g1.fillOval (99, 429, 5, 5); //makes eye 2








//human2 on the boat


Color humanface2 = new Color (251, 202, 153); //Color human face


g1.setColor (humanface2); // detects face


g1.fillOval (230, 425, 15, 15); //makes face


Color supereyes = new Color (0, 0, 0); //color human eye1


g1.setColor (supereyes); //detects eye 1


g1.fillOval (232, 429, 5, 5); //makes eye 1


Color supereyes2 = new Color (0, 0, 0); // color for eye 2


g1.setColor (supereyes2); //detects eye 2


g1.fillOval (239, 429, 5, 5); //makes eye


Color shirt = new Color (120, 233, 7); //color for shirt


g1.setColor (shirt); //detects shirt


g1.fillRect (230, 440, 15, 15); //makes shirt








thanks again :D|||Moving the object means redrawing it in new position.


The old way of improving the appearance and performance of moving objects was to have two or more objects drawn in sequence in slightly different sequential positions and then hide the previous and show next one in quick succession.


It has been a long time since I had anything to do with graphics, so my approach may be outdated, but it will still work.

No comments:

Post a Comment