-
Notifications
You must be signed in to change notification settings - Fork 0
/
Asteroid1.java
35 lines (28 loc) · 883 Bytes
/
Asteroid1.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
import greenfoot.*;
public class Asteroid1 extends Actor {
private int speed;
public Asteroid1(int speed) {
this.speed = speed;
}
public void act() {
setLocation(getX() - speed, getY());
if(getX()==0)
{
setLocation(990, getY());
}
checkCollision();
}
private void checkCollision() {
Laser laser = (Laser) getOneIntersectingObject(Laser.class);
if (laser != null) {
} else {
}
if (laser != null) {
ScoreBoard scoreboard = (ScoreBoard) getWorld().getObjects(ScoreBoard.class).get(0);
scoreboard.addPoints(10);
getWorld().addObject(new ExplosionLaser(), getX(), getY());
getWorld().removeObject(this);
return;
}
}
}