@@ -65,12 +65,12 @@ static ENetPeer* connect_client(ENetHost *client, int port)
65
65
enet_address_set_host (& address , "localhost" );
66
66
address .port = port ;
67
67
/* Initiate the connection, allocating the two channels 0 and 1. */
68
- server = enet_host_connect (client , & address , 2 , 0 );
68
+ server = enet_host_connect (client , & address , 2 , 0 );
69
69
if (server == NULL )
70
70
abort_example ("Client: No available peers for initiating an ENet connection.\n" );
71
71
72
72
/* Wait up to 5 seconds for the connection attempt to succeed. */
73
- if (enet_host_service (client , & event , 5000 ) > 0 &&
73
+ if (enet_host_service (client , & event , 5000 ) > 0 &&
74
74
event .type == ENET_EVENT_TYPE_CONNECT )
75
75
{
76
76
printf ("Client: Connected to %x:%u.\n" ,
@@ -138,6 +138,7 @@ int main(int argc, char **argv)
138
138
bool done = false; // when true, client exits
139
139
int dx = 0 , dy = 0 ; // movement direction
140
140
int port = DEFAULT_PORT ;
141
+ int i ;
141
142
142
143
if (argc == 2 ) {
143
144
port = atoi (argv [1 ]);
@@ -186,17 +187,25 @@ int main(int argc, char **argv)
186
187
break ;
187
188
case ALLEGRO_EVENT_KEY_DOWN :
188
189
switch (event .keyboard .keycode ) {
190
+ case ALLEGRO_KEY_UP :
189
191
case ALLEGRO_KEY_W : dy -= 1 ; direction_changed = true; break ;
192
+ case ALLEGRO_KEY_DOWN :
190
193
case ALLEGRO_KEY_S : dy += 1 ; direction_changed = true; break ;
194
+ case ALLEGRO_KEY_LEFT :
191
195
case ALLEGRO_KEY_A : dx -= 1 ; direction_changed = true; break ;
196
+ case ALLEGRO_KEY_RIGHT :
192
197
case ALLEGRO_KEY_D : dx += 1 ; direction_changed = true; break ;
193
198
}
194
199
break ;
195
200
case ALLEGRO_EVENT_KEY_UP :
196
201
switch (event .keyboard .keycode ) {
202
+ case ALLEGRO_KEY_UP :
197
203
case ALLEGRO_KEY_W : dy += 1 ; direction_changed = true; break ;
204
+ case ALLEGRO_KEY_DOWN :
198
205
case ALLEGRO_KEY_S : dy -= 1 ; direction_changed = true; break ;
206
+ case ALLEGRO_KEY_LEFT :
199
207
case ALLEGRO_KEY_A : dx += 1 ; direction_changed = true; break ;
208
+ case ALLEGRO_KEY_RIGHT :
200
209
case ALLEGRO_KEY_D : dx -= 1 ; direction_changed = true; break ;
201
210
}
202
211
break ;
@@ -229,7 +238,7 @@ int main(int argc, char **argv)
229
238
230
239
// draw each player
231
240
al_clear_to_color (al_map_rgb_f (0 , 0 , 0 ));
232
- for (int i = 0 ; i < MAX_PLAYER_COUNT ; i ++ ) {
241
+ for (i = 0 ; i < MAX_PLAYER_COUNT ; i ++ ) {
233
242
if (!players [i ].active ) continue ;
234
243
235
244
int x = players [i ].x ;
@@ -244,6 +253,7 @@ int main(int argc, char **argv)
244
253
disconnect_client (client , server );
245
254
enet_host_destroy (client );
246
255
enet_deinitialize ();
256
+ return 0 ;
247
257
}
248
258
249
259
/* vim: set sts=3 sw=3 et: */
0 commit comments