-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbird.java
41 lines (37 loc) · 965 Bytes
/
bird.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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class bird extends obstacle
{
private int counter = 0;
private boolean fly = true;
private boolean bird = true;
public bird(){
setImage("bird-0.png");
}
public void act()
{
if(dino.alive){
counter++;
if(bird){
fly();
move(-6 - MyWorld.difficulty);
if(isAtEdge()){
getWorld().removeObject(this);
}
}
}
}
private void fly(){
if(counter >= 5){
counter = 0;
if(fly){
setLocation(getX(), getY()+12);
setImage("bird-1.png");
fly = false;
} else {
setLocation(getX(), getY()-12);
setImage("bird-0.png");
fly = true;
}
}
}
}