-
Notifications
You must be signed in to change notification settings - Fork 1
/
BulletEnhanced.java
63 lines (51 loc) · 1.65 KB
/
BulletEnhanced.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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class BulletEnhanced extends Bullet {
int length = 0;
GreenfootImage beamImg = new GreenfootImage(3, 10);
int flameCount = 0;
public BulletEnhanced() {
length = 0;
beamImg.setColor(Color.WHITE);
beamImg.fill();
setImage(beamImg);
flameCount = 0;
}
public boolean checkT(int x,int y){
if(Math.abs(x - CaterOuter.nakami.getX()) < 10){
return true;
}else if(Math.abs(y - CaterOuter.nakami.getY()) < 10){
return true;
}else if(Math.abs(Math.abs(x - CaterOuter.nakami.getX()) - Math.abs(y - CaterOuter.nakami.getY())) < 10){
return true;
}else{
return false;
}
}
@Override
protected void addedToWorld(World world) {
}
public void act() {
if (Stage.inPause) {
if(Cater.beamSound.isPlaying()){
Cater.beamSound.pause();
}
} else {
if(!Cater.beamSound.isPlaying()){
Cater.beamSound.playLoop();
}
flameCount++;
if (length <= 2 * Stage.HEIGHT) {
length += 50;
beamImg = new GreenfootImage(length, 10);
beamImg.setColor(Color.WHITE);
beamImg.fill();
setImage(beamImg);
}
if (flameCount == 250) {
Cater.beamSound.stop();
Cater.isBeaming = false;
getWorld().removeObject(this);
}
}
}
}