-
Notifications
You must be signed in to change notification settings - Fork 0
/
DarkBeam.java
66 lines (51 loc) · 1.46 KB
/
DarkBeam.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import greenfoot.*;
public class DarkBeam extends AnimatedActor
{
private double posx;
private double posy;
private double velocityX;
private double velocityY;
private int frameCounter = 0;
private int frameWait = 4;
DarkBeam()
{
super("darkbullet", ".png", 4);
}
/**
* Act - do whatever the ShootyThing wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
World wrld = getWorld();
if (posx == 0.0)
{
Bright ball = (Bright) wrld.getObjects(Bright.class).get(0);
double diffX = getX() - ball.getX();
double diffY = getY() - ball.getY();
velocityX = -10;
velocityY = 0;
posx = getX();
posy = getY();
}
if(frameCounter >= frameWait)
{
super.act();
frameCounter = 0;
}
else
{
frameCounter++;
}
setLocation((int)posx, (int)posy);
posy += velocityY;
posx += velocityX;
Bright bright = (Bright) getOneIntersectingObject(Bright.class);
Hitbox box = (Hitbox) getOneIntersectingObject(Hitbox.class);
if (posx <= 30.0)
wrld.removeObject(this);
if(box != null) {
bright.die();
}
}
}