forked from kevin890703/assign6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Background.pde
62 lines (50 loc) · 1 KB
/
Background.pde
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
class Background{
PImage start1;
PImage start2;
PImage bg1;
PImage bg2;
PImage end1;
PImage end2;
int playingBg1x = 0;
int playingBg2x = -640;
Background() {
//since this won't change in the future
this.bg1 = loadImage("img/bg1.png");
this.bg2 = loadImage("img/bg2.png");
this.start1 = loadImage("img/start1.png");
this.start2 = loadImage("img/start2.png");
this.end1 = loadImage("img/end1.png");
this.end2 = loadImage("img/end2.png");
}
void draw()
{
if (state == GameState.START) {
if (second() % 2 == 1 ) {
image(start1, 0, 0);
}
else {
image(start2, 0, 0);
}
}
else if (state == GameState.PLAYING) {
playingBg1x++;
playingBg2x++;
if (playingBg1x == 640) {
playingBg1x = -640;
}
if (playingBg2x == 640) {
playingBg2x = -640;
}
image(bg1, playingBg1x, 0);
image(bg2, playingBg2x, 0);
}
else if (state == GameState.END) {
if (second() % 2 == 1 ) {
image(end1, 0, 0);
}
else {
image(end2, 0, 0);
}
}
}
}