xxxxxxxxxx
Turtle t1;
Turtle t2;
TurtleLeg tl1;
TurtleLeg tl2;
lure = new Spot;
void setup() {
size(800, 600);
t1 = new Turtle();
tl1 = new TurtleLeg();
t2 = new Turtle();
tl2 = new TurtleLeg();
t1.setPosition(800, 500); //coordinates to start appearing?
t1.setVelocity(-2, -1); //how fast and which direction?
t1.setSpeed(2);
tl1.setPosition(800, 500); //variables for TurtleLeg object has to be the exact same as corresponding turtle object
tl1.setVelocity(-2, -1);
tl1.setSpeed(2);
t2.setPosition(800, 200); //ccoordinates to start appearing?
t2.setVelocity(-1, -0.5);
tl2.setPosition(800, 200); //variables for TurtleLeg object has to be the exact same as corresponding turtle object
tl2.setVelocity(-1, -0.5);
}
void draw() {
background(116,160,245);
fill(234,216,123);
noStroke();
rect(0,450,800,800);
fill(100, 145, 252);
rect(0,240,800,210);
fill(83,127,25);
triangle(0,470, 30, 470, 15, 250);
triangle(40,470, 70, 470, 55, 250);
triangle(20,470, 50, 470, 35, 250);
triangle(60,470, 90, 470, 75, 250);
triangle(80,470, 110, 470, 95, 250);
fill(255, 158, 39);
quad(500, 450, 800, 450, 670, 270, 630, 270);
quad(400, 450, 520, 450, 470, 380, 450, 380);
fill(167, 199, 255);
rect(0,0,800,40);
fill(138, 180, 250);
rect(0,40,800,40);
lure.display();
//turtle1
t1.display(); //body with head and tail displayed
t1.tailrotate(); //rotate tail
t1.move(); //translate body
tl1.display(); //display arms and legs
tl1.move(); //move(rotate arms and legs)
//turtle2
t2.display();
t2.move();
t2.tailrotate();
tl2.display(); //display arms and legs
tl2.move(); //move(rotate arms and legs)
}
void mouseClicked(){
lure.p.x = mouseX;
lure.p.y = mouseY;
int posx = mouseX - t1.p.x;
int posy = mouseY - t1.p.y;
int sum = abs(posx) + abs(posy);
float resx = posx / sum;
float resy = posy / sum;
t1.v.x = resx;
t1.v.y = resy;
tl1.v.x = resx;
tl1.v.y = resy;
print(resx, resy);
}