-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMario.java
More file actions
53 lines (42 loc) · 827 Bytes
/
Mario.java
File metadata and controls
53 lines (42 loc) · 827 Bytes
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
class Mario {
int x, y, px, py, width, height, marioImageNum, numFramesInAir;
double vert_velocity;
boolean isFalling;
public Mario(int x, int y) {
this.x = x;
this.y = y;
width = 60;
height = 95;
marioImageNum = 0;
vert_velocity = 12.0;
numFramesInAir = 0;
isFalling = false;
}
void yeet() {
if (!isFalling) {
if (numFramesInAir < 20) {
vert_velocity = -20;
numFramesInAir++;
}
if (y + height == 400) {
numFramesInAir = 0;
}
}
}
void savePreviousCoordinates() {
px = x;
py = y;
}
void update() {
vert_velocity += 6.8;
y += vert_velocity;
if(y > 400 - height) {
vert_velocity = 0;
y = 400 - height;
}
if (y < 0)
y = 0;
if (marioImageNum > 4)
marioImageNum = 0;
}
}