-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.pde
More file actions
33 lines (27 loc) · 740 Bytes
/
Player.pde
File metadata and controls
33 lines (27 loc) · 740 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
class Player extends Model {
boolean canShoot = true;
int shootdelay = 0;
//Creates the player class and where the model spawns
Player() {
x = width/gridsize/2;
y = height - (10 * pixelsize);
}
//Controls for the player
void updateObj() {
if (keyPressed && keyCode == LEFT) {
x -= 5;
}
if (keyPressed && keyCode == RIGHT) {
x += 5;
}
if (keyPressed && key == ' ' && canShoot) {
fireballs.add(new Fireball(x, y));
canShoot = false;
shootdelay = 0;
}
shootdelay++;
if (shootdelay >= 20) {
canShoot = true;
}
}
}