-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGear.java
More file actions
39 lines (31 loc) · 908 Bytes
/
Copy pathGear.java
File metadata and controls
39 lines (31 loc) · 908 Bytes
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
import greenfoot.Actor;
public class Gear extends Actor {
int vel = 3;
boolean onFloor;
public Gear(int rot) {
onFloor = false;
this.setRotation(rot);
}
public void act() {
this.move(this.vel);
Actor boilerBottom = this.getOneObjectAtOffset(0, 0, BoilerBottom.class);
if(boilerBottom == null) {
// Makes the gear acc. towards the ground after leaving the alliance station chute.
if(this.vel < 10 && !onFloor) {
++this.vel;
}
if(this.getRotation() > 90) {
this.turn(-5);
}
if(this.getRotation() < 90) {
this.turn(5);
}
}
if(this.getY() > 378) {
onFloor = true;
this.setLocation(this.getX(), 396);
this.setRotation(0);
vel = 0;
}
}
}