forked from choupeishuan/assign1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassign1.pde
69 lines (45 loc) · 1 KB
/
assign1.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
63
64
65
66
67
68
69
PImage background1;
PImage background2;
PImage treasure;
PImage enemy;
PImage fighter;
PImage hp;
int hpX = floor(random(250));
int enemyX = 0;
int enemyY = floor(random(380));
int treasureX = floor(random(560));
int treasureY = floor(random(460));
int backgroundX = 0;
void setup () {
size(640,480) ;
treasure = loadImage("img/treasure.png");
enemy = loadImage("img/enemy.png");
fighter = loadImage("img/fighter.png");
hp = loadImage("img/hp.png");
background1 = loadImage("img/bg1.png");
background2 = loadImage("img/bg2.png");
}
void draw() {
if(bgX<=641){
image(bg1, bgX,0);
image(bg2, bgX-641,0);
}
if(bgX>641){
bgX=-641;
}
if(bgX<0){
image(bg1, bgX,0);
image(bg2, bgX+641,0);
}
bgX += 1;
println(bgX);
println(bgX-641);
image(treasure ,treasureX, treasureY);
image(enemy, enemyX, enemyY);
enemyX += 2;
enemyX %= 600;
image(fighter, 580,235);
fill(#FF0000);
rect(9,9, hpX, 20);
image(hp, 0,5);
}