-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetChar.pde
67 lines (58 loc) · 1.48 KB
/
GetChar.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
//Built by Adam //<>// //<>//
class GetChar {
float x, y;
int jumpSpeed= 20;
int gravity= 5;
int drag= 1;
int xSpeed= 4;
int standingIndex;
int jumpingIndex;
int movingLeftIndex;
int movingRightIndex;
PImage duck;
PImage[] jump= new PImage[4];
PImage[] moveR= new PImage[5];
PImage[] moveL= new PImage[5];
PImage[] stand= new PImage[10];
GetChar (float x, float y) {
for (int i = 0; i < stand.length; i++) {
stand[i] = loadImage ("fox/stand"+i+".png");
}
for (int i = 0; i < moveR.length; i++) {
moveR[i] = loadImage ("fox/run"+i+".png");
}
for (int i = 0; i < moveL.length; i++) {
moveL[i] = loadImage ("fox/away"+i+".png");
}
for (int i = 0; i < jump.length; i++) {
jump[i] = loadImage ("fox/jump"+i+".png");
}
duck = loadImage("fox/duck0.png");
}
void standStill() {
if (frameCount % 15 == 0) {
standingIndex = int(random(0, stand.length));
}
image(stand[standingIndex], x, y);
}
void moveRight() {
if (frameCount % 2 == 0) {
movingRightIndex = int (random(0, moveR.length));
}
image(moveR[movingRightIndex], x, y+10);
}
void moveLeft() {
if (frameCount % 2 == 0) {
movingLeftIndex= int (random(0, moveL.length));
}
image(moveL[movingLeftIndex], x, y+10);
}
void jumpping() {
if (frameCount % 20 == 0) {
jumpingIndex= int (random(0, jump.length));
}
image(jump[jumpingIndex], x, y);
jumpSpeed*= drag;
y-=jumpSpeed;
}
}