-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShuriken.java
More file actions
44 lines (38 loc) · 1.04 KB
/
Shuriken.java
File metadata and controls
44 lines (38 loc) · 1.04 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
import greenfoot.*; // import every greefoot function, object and more
public class Shuriken extends Actor implements Enemy
{
private int speed;
private GreenfootImage image;
private int rotationAngle = 0;
public Shuriken(int _speed) {
this.speed = _speed;
this.image = new GreenfootImage("./images/shuriken.png");
this.setImage(image);
}
public void act() {
this.move(this.speed);
this.removeOnEdge();
this.rotate();
}
/**
* Remove object at the edge of the world
*/
private void removeOnEdge() {
if (this.isAtEdge()) {
MapManager.currentMap.removeObject(this);
}
}
/**
* Rotate the image to create a nice effect
*/
private void rotate() {
rotationAngle = (rotationAngle + 10) % 360;
GreenfootImage rotated = new GreenfootImage(this.image);
rotated.rotate(rotationAngle);
setImage(rotated);
}
@Override
public int getDamage() {
return 4;
}
}