-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlevels.c
111 lines (100 loc) · 1.88 KB
/
levels.c
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
void init_level() {
switch(level) {
case 0:
bot.direction = 0;
bot.position.x = 56;
bot.position.y = 80;
break;
case 1:
bot.direction = 0;
bot.position.x = 72;
bot.position.y = 96;
break;
case 2:
bot.direction = 0;
bot.position.x = 104;
bot.position.y = 48;
break;
case 3:
bot.direction = 0;
bot.position.x = 72;
bot.position.y = 128;
break;
case 4:
bot.direction = 0;
bot.position.x = 72;
bot.position.y = 80;
break;
case 5:
bot.direction = 0;
bot.position.x = 40;
bot.position.y = 80;
break;
case 6:
bot.direction = 1;
bot.position.x = 24;
bot.position.y = 32;
break;
case 7:
bot.direction = 0;
bot.position.x = 72;
bot.position.y = 80;
break;
default:
printf("Invalid level");
}
DISPLAY_OFF;
display_level();
set_bkg_tiles(0, 0, 20, 18, current_level);
reset_sprites();
init_bot();
disable_transmission();
screen = 1;
DISPLAY_ON;
}
void update_level_running() {
UBYTE keys, diff;
if(transmission.active)
update_transmission();
else
update_bot();
keys = joypad();
if(keys != joypad_prev) {
//calculate which key changed
diff = (joypad_prev ^ keys) & keys;
joypad_prev = keys;
switch(diff) {
case J_B:
init_level();
break;
case J_SELECT:
init_programming();
break;
default:
break;
}
}
}
void update_level_idle() {
UBYTE keys, diff;
keys = joypad();
if(keys != joypad_prev) {
//calculate which key changed
diff = (joypad_prev ^ keys) & keys;
joypad_prev = keys;
switch(diff) {
case J_UP: error_sound(); break;
case J_DOWN: error_sound(); break;
case J_LEFT: error_sound(); break;
case J_RIGHT: error_sound(); break;
case J_A:
screen = 2;
break;
case J_SELECT:
init_programming();
break;
default:
break;
}
}
}