-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpriteCarDown.java
More file actions
67 lines (57 loc) · 1.65 KB
/
Copy pathSpriteCarDown.java
File metadata and controls
67 lines (57 loc) · 1.65 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import java.awt.Graphics2D;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
public class SpriteCarDown extends Sprite {
LocationGrid grid;
private static final int xDiff = 35;
private static final int yDiff = 0;
public SpriteCarDown(int x, int y, LocationGrid g, int index){
super(x-xDiff,y-yDiff,"car3",g,index);
xLoc = x+5;
yLoc = y;
widthLoc = 35;
heightLoc = 40;
grid = g;
g.update(this);
}
public boolean carDown(BufferedImage b){
moveY(10);
if (y >= b.getHeight()) {
y = -heightLoc;
yLoc = y+yDiff;
}
grid.update(this);
if (grid.checkCarCrash(getIndex())) {
moveY(-10);
if (y < 0) {
y = b.getHeight();
yLoc = y+yDiff;
}
grid.update(this);
return true;
}
currentImageIndex = states[0];
states[0] = (states[0]+1)%4;
return false;
}
public boolean carUp(BufferedImage b){
moveY(-10);
if (y < 0-heightLoc) {
y = b.getHeight();
yLoc = y+yDiff;
}
grid.update(this);
if (grid.checkCarCrash(getIndex())) {
moveY(10);
if (y > b.getHeight()) {
y = -heightLoc;
yLoc = y+yDiff;
}
grid.update(this);
return true;
}
currentImageIndex = 12+states[3];
states[3] = (states[3]+1)%4;
return false;
}
}