-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathTurtle.java
43 lines (36 loc) · 969 Bytes
/
Turtle.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package p4_group_8_repo;
import javafx.scene.image.Image;
public class Turtle extends Actor{
Image turtle1;
Image turtle2;
Image turtle3;
private int speed;
int i = 1;
boolean bool = true;
@Override
public void act(long now) {
if (now/900000000 % 3 ==0) {
setImage(turtle2);
}
else if (now/900000000 % 3 == 1) {
setImage(turtle1);
}
else if (now/900000000 %3 == 2) {
setImage(turtle3);
}
move(speed , 0);
if (getX() > 600 && speed>0)
setX(-200);
if (getX() < -75 && speed<0)
setX(600);
}
public Turtle(int xpos, int ypos, int s, int w, int h) {
turtle1 = new Image("file:src/p4_group_8_repo/TurtleAnimation1.png", w, h, true, true);
turtle2 = new Image("file:src/p4_group_8_repo/TurtleAnimation2.png", w, h, true, true);
turtle3 = new Image("file:src/p4_group_8_repo/TurtleAnimation3.png", w, h, true, true);
setX(xpos);
setY(ypos);
speed = s;
setImage(turtle2);
}
}