-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.c
236 lines (197 loc) · 5.58 KB
/
input.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*
Lacewing
Copyright (C) 2003 Linley Henzell & Captain Pork
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public Licence as published by
the Free Software Foundation; either version 2 of the Licence, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public Licence for more details.
You should have received a copy of the GNU General Public Licence
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
The GPL version 2 is included in this distribution in a file called
LICENCE.TXT. Use any text editor or the TYPE command to read it.
You should be able to reach us by sending an email to
captainpork@fastmail.fm.
File: input.c
History:
6/10/2003 - Version 1.0 finalised
This file contains:
- keyboard input. Commands are passed to cmds.c - see intro to that file
for a bit more information.
*/
#include <math.h>
#define ALLEGRO_NO_CLEAR_BITMAP_ALIAS
#define ALLEGRO_NO_VHLINE_ALIAS
#include "allegro.h"
#include "config.h"
#include "globvars.h"
#include "sound.h"
//#define DEBUG_KEYS 1
#ifdef DEBUG_KEYS
#include "actor.h"
#include "enemy.h"
#include <string.h>
#include "palette.h"
extern RGB palet [256];
int scrs;
int sshot_counter;
#endif
extern int inflicteda, inflictede;
void get_input(void)
{
int i;
for (i = 0; i < NO_CMDS; i ++)
{
if (key [player[0].keys [i]])
actor[player[0].actor_controlled].actor_cmd [i] = 1;
else
actor[player[0].actor_controlled].actor_cmd [i] = 0;
}
for (i = 0; i < NO_CMDS; i ++)
{
if (key [player[1].keys [i]])
actor[player[1].actor_controlled].actor_cmd [i] = 1;
else
actor[player[1].actor_controlled].actor_cmd [i] = 0;
}
if (key [player[0].keys [CMD_LINK]])
{
if (player[0].link_toggle_delay == 0)
{
if (player[0].link_fire == 0)
player[0].link_fire = 1;
else
player[0].link_fire = 0;
player[0].link_toggle_delay = 20;
play_sound(WAV_MENU1);
}
}
if (key [player[1].keys [CMD_LINK]])
{
if (player[1].link_toggle_delay == 0)
{
if (player[1].link_fire == 0)
player[1].link_fire = 1;
else
player[1].link_fire = 0;
player[1].link_toggle_delay = 20;
play_sound(WAV_MENU1);
}
}
/*
if (key [KEY_8_PAD])
actor[player[0].actor_controlled].actor_cmd [CMD_THRUST] = 1;
if (key [KEY_4_PAD])
actor[player[0].actor_controlled].actor_cmd [CMD_LEFT] = 1;
if (key [KEY_6_PAD])
actor[player[0].actor_controlled].actor_cmd [CMD_RIGHT] = 1;
if (key [KEY_0_PAD])
actor[player[0].actor_controlled].actor_cmd [CMD_FIRE1] = 1;
if (key [KEY_ENTER_PAD])
actor[player[0].actor_controlled].actor_cmd [CMD_FIRE2] = 1;
if (key [KEY_PLUS_PAD])
actor[player[0].actor_controlled].actor_cmd [CMD_UPGRADE] = 1;
if (key [KEY_1_PAD])
actor[player[0].actor_controlled].actor_cmd [CMD_LEFT1] = 1;
if (key [KEY_3_PAD])
actor[player[0].actor_controlled].actor_cmd [CMD_RIGHT1] = 1;
if (key [KEY_2_PAD])
actor[player[0].actor_controlled].actor_cmd [CMD_BRAKE] = 1;*/
#ifdef DEBUG_KEYS
char sfile [20];
char istr [20];
if (sshot_counter > 0)
sshot_counter --;
if (key [KEY_F1] && sshot_counter <= 0)
{
BITMAP *scrshot_bmp = create_bitmap(640, 480);
blit(screen, scrshot_bmp, 0,0,0,0,640,480);
strcpy(sfile, "sshot");
strcat(sfile, itoa(scrs, istr, 10));
strcat(sfile, ".bmp");
save_bitmap(sfile, scrshot_bmp, palet);
clear_to_color(screen, COLOUR_WHITE);
play_sound(WAV_MENU2);
scrs ++;
sshot_counter = 15;
}
if (key [KEY_MINUS_PAD] && counter % 5 == 0)
{
gain_upgrade_points(player[0].actor_controlled, 1);
}
if (key [KEY_TILDE])
{
hurt_actor(0, OWNER_ENEMY, 2000);
}
if (key [KEY_TAB])
{
arena.targets_left [0] = 1;
arena.targets_left [1] = 0;
arena.targets_left [2] = 0;
arena.targets_left_total = 1;
for (i = 0; i < NO_ENEMIES; i ++)
{
if (enemy[i].type != ENEMY_NONE)
hurt_enemy(i, 9999, 0,0);
}
}
if (key [KEY_2] && counter % 15 == 0)
{
actor[0].type ++;
}
if (key [KEY_1] && counter % 15 == 0)
{
actor[0].type --;
}
if (key [KEY_E])
{
inflicteda ++;
}
if (key [KEY_R])
{
inflicteda --;
}
if (key [KEY_D])
{
inflictede ++;
}
if (key [KEY_F])
{
inflictede --;
}
if (key [KEY_7_PAD])
{
actor[player[0].actor_controlled].armour += 10;
if (actor[player[0].actor_controlled].armour > actor[player[0].actor_controlled].max_armour)
actor[player[0].actor_controlled].armour = actor[player[0].actor_controlled].max_armour;
}
#endif
// int special [10];
// if (key [KEY_5_PAD] && counter % 10 == 0)
// {
// create_enemy(ENEMY_BOUNCER, 10000 + random() % 50000, 10000 + random() % 50000,
// 1000 - random() % 2000, 1000 - random() % 2000, 0, special);
// create_enemy(ENEMY_STINGER, grand(3), 10000 + random() % 300000, 90000,
// 0, 0, 0, special);
// }
/*
if (key [KEY_UP])
actor[player[1].actor_controlled].actor_cmd [CMD_THRUST] = 1;
if (key [KEY_LEFT])
actor[player[1].actor_controlled].actor_cmd [CMD_LEFT] = 1;
if (key [KEY_RIGHT])
actor[player[1].actor_controlled].actor_cmd [CMD_RIGHT] = 1;
if (key [KEY_DOWN])
actor[player[1].actor_controlled].actor_cmd [CMD_BRAKE] = 1;
if (key [KEY_SPACE])
actor[player[1].actor_controlled].actor_cmd [CMD_FIRE1] = 1;
if (key [KEY_Z])
actor[player[1].actor_controlled].actor_cmd [CMD_FIRE2] = 1;
if (key [KEY_X])
actor[player[1].actor_controlled].actor_cmd [CMD_UPGRADE] = 1;
*/
}