-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomBird.java
More file actions
50 lines (39 loc) · 1.21 KB
/
RandomBird.java
File metadata and controls
50 lines (39 loc) · 1.21 KB
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
44
45
46
47
48
49
50
class RandomBird extends DynamicBird
{
RandomBird(Canvas canvas)
{
super(canvas);
this.draw();
}
RandomBird(Canvas canvas, double xPosition, double yPosition)
{
super(canvas, xPosition, yPosition);
this.posStart = new CartesianCoordinate ( xPosition, yPosition );
this.setStart( this.posStart );
}
public double randomTurning()
{
int intAngle = Utils.randomInt(360);
this.direction = (double)intAngle;
return this.direction;
}
public void update ( int time, double angle )
{
this.undraw();
int distance = this.speed * time/1000;
int n = Utils.randomInt(100);
int j = Utils.randomInt(5);
for ( int i = 0; i <= n; i++)
{
this.undraw();
this.putPenUp();
this.move(1);
this.draw();
Utils.pause(5);
this.undraw();
}
this.turn(angle);
this.draw();
//Utils.pause(5);
}
};