-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBullet.java
More file actions
32 lines (30 loc) · 738 Bytes
/
Bullet.java
File metadata and controls
32 lines (30 loc) · 738 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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Bullet here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Bullet extends ScrollingActor
{
public int speed = 15;
public Bullet(int size)
{
GreenfootImage image = getImage();
image.scale(15 + size * 3,15 + size * 3);
setImage(image);
}
public void act()
{
move(5);
checkRemove();
}
public void checkRemove()
{
World w = getWorld();
if (getY() > w.getHeight() || getX() > w.getWidth())
{
w.removeObject(this);
}
}
}