-
Notifications
You must be signed in to change notification settings - Fork 6
/
input.c
84 lines (77 loc) · 3 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
/*
* input.c
* Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/
*
* Copyright (C) 2001 Chuck Mason <[email protected]>
*
* Copyright (C) 2002 Florian Schulze <[email protected]>
*
* This file is part of Jump 'n Bump.
*
* Jump 'n Bump is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Jump 'n Bump 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 License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "globals.h"
void update_player_actions(void)
{
int tmp;
if (client_player_num < 0) {
tmp = key_pressed(KEY_PL1_LEFT) == 1;
if (tmp != player[0].action_left)
tellServerPlayerMoved(0, MOVEMENT_LEFT, tmp);
tmp = key_pressed(KEY_PL1_RIGHT) == 1;
if (tmp != player[0].action_right)
tellServerPlayerMoved(0, MOVEMENT_RIGHT, tmp);
tmp = key_pressed(KEY_PL1_JUMP) == 1;
if (tmp != player[0].action_up)
tellServerPlayerMoved(0, MOVEMENT_UP, tmp);
tmp = key_pressed(KEY_PL2_LEFT);
if (tmp != player[1].action_left)
tellServerPlayerMoved(1, MOVEMENT_LEFT, tmp);
tmp = key_pressed(KEY_PL2_RIGHT) == 1;
if (tmp != player[1].action_right)
tellServerPlayerMoved(1, MOVEMENT_RIGHT, tmp);
tmp = key_pressed(KEY_PL2_JUMP) == 1;
if (tmp != player[1].action_up)
tellServerPlayerMoved(1, MOVEMENT_UP, tmp);
tmp = key_pressed(KEY_PL3_LEFT) == 1;
if (tmp != player[2].action_left)
tellServerPlayerMoved(2, MOVEMENT_LEFT, tmp);
tmp = key_pressed(KEY_PL3_RIGHT) == 1;
if (tmp != player[2].action_right)
tellServerPlayerMoved(2, MOVEMENT_RIGHT, tmp);
tmp = key_pressed(KEY_PL3_JUMP) == 1;
if (tmp != player[2].action_up)
tellServerPlayerMoved(2, MOVEMENT_UP, tmp);
tmp = key_pressed(KEY_PL4_LEFT) == 1;
if (tmp != player[3].action_left)
tellServerPlayerMoved(3, MOVEMENT_LEFT, tmp);
tmp = key_pressed(KEY_PL4_RIGHT) == 1;
if (tmp != player[3].action_right)
tellServerPlayerMoved(3, MOVEMENT_RIGHT, tmp);
tmp = key_pressed(KEY_PL4_JUMP) == 1;
if (tmp != player[3].action_up)
tellServerPlayerMoved(3, MOVEMENT_UP, tmp);
} else {
tmp = key_pressed(KEY_PL1_LEFT) == 1;
if (tmp != player[client_player_num].action_left)
tellServerPlayerMoved(client_player_num, MOVEMENT_LEFT, tmp);
tmp = key_pressed(KEY_PL1_RIGHT) == 1;
if (tmp != player[client_player_num].action_right)
tellServerPlayerMoved(client_player_num, MOVEMENT_RIGHT, tmp);
tmp = key_pressed(KEY_PL1_JUMP) == 1;
if (tmp != player[client_player_num].action_up)
tellServerPlayerMoved(client_player_num, MOVEMENT_UP, tmp);
}
}