-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMoveMent.pde
38 lines (37 loc) · 1.12 KB
/
MoveMent.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
void keyPressed() {
//if (pageNum == 3) { // In game
// AnimatedSprite 1 controls
if (keyCode == RIGHT){
player.change_x = MOVE_SPEED;
}
if (keyCode == LEFT){
player.change_x = -MOVE_SPEED;
}
if (keyCode == UP && (isOnGround(player, gw.platforms) || isOnLadder(player,gw.ladders))){
player.change_y = -JUMP_SPEED;
}
if (keyCode == UP && player.fly){
player.change_y = -JUMP_SPEED;
}
if (keyCode == DOWN && (isOnLadder(player,gw.ladders) || player.fly)){
player.change_y = MOVE_SPEED;
}
//}
if (!gameStarted && !showLeaderboard && !back) {
if (keyCode >= 65 && keyCode <= 90 || keyCode >= 97 && keyCode <= 122 || keyCode == 32) {
playerName += key;
} else if (keyCode == BACKSPACE && playerName.length() > 0) {
playerName = playerName.substring(0, playerName.length() - 1);
}
}
}
void keyReleased() {
//if (pageNum == 3) {
// AnimatedSprite 1 controls
if (keyCode == RIGHT || keyCode == LEFT) {
player.change_x = 0;
} else if (keyCode == UP || keyCode == DOWN) {
player.change_y = 0;
}
//}
}