Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
openjazz
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
openjazz
Commits
c1b3814a
Commit
c1b3814a
authored
Mar 04, 2010
by
alistert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved input handling.
parent
4a9aa467
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
110 additions
and
148 deletions
+110
-148
game.h
src/game/game.h
+2
-2
controls.cpp
src/io/controls.cpp
+33
-56
controls.h
src/io/controls.h
+9
-8
demolevel.cpp
src/level/demolevel.cpp
+2
-1
levelload.cpp
src/level/levelload.cpp
+12
-6
main.cpp
src/main.cpp
+2
-2
setupmenu.cpp
src/menu/setupmenu.cpp
+45
-70
player.cpp
src/player/player.cpp
+3
-1
player.h
src/player/player.h
+1
-1
playerframe.cpp
src/player/playerframe.cpp
+1
-1
No files found.
src/game/game.h
View file @
c1b3814a
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -70,7 +70,7 @@
...
@@ -70,7 +70,7 @@
#define MTL_L_STAGE 3
#define MTL_L_STAGE 3
#define MTL_P_ANIMS (PANIMS + 3)
#define MTL_P_ANIMS (PANIMS + 3)
#define MTL_P_TEMP 4
5
#define MTL_P_TEMP 4
6
#define BUFFER_LENGTH 255
/* Should always be big enough to hold any message */
#define BUFFER_LENGTH 255
/* Should always be big enough to hold any message */
...
...
src/io/controls.cpp
View file @
c1b3814a
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -46,6 +46,7 @@ Controls::Controls () {
...
@@ -46,6 +46,7 @@ Controls::Controls () {
keys
[
C_JUMP
].
key
=
SDLK_SPACE
;
keys
[
C_JUMP
].
key
=
SDLK_SPACE
;
keys
[
C_FIRE
].
key
=
SDLK_LALT
;
keys
[
C_FIRE
].
key
=
SDLK_LALT
;
#endif
#endif
keys
[
C_SWIM
].
key
=
keys
[
C_JUMP
].
key
;
keys
[
C_CHANGE
].
key
=
SDLK_RCTRL
;
keys
[
C_CHANGE
].
key
=
SDLK_RCTRL
;
keys
[
C_ENTER
].
key
=
SDLK_RETURN
;
keys
[
C_ENTER
].
key
=
SDLK_RETURN
;
keys
[
C_ESCAPE
].
key
=
SDLK_ESCAPE
;
keys
[
C_ESCAPE
].
key
=
SDLK_ESCAPE
;
...
@@ -77,6 +78,8 @@ Controls::Controls () {
...
@@ -77,6 +78,8 @@ Controls::Controls () {
buttons
[
C_STATS
].
button
=
-
1
;
buttons
[
C_STATS
].
button
=
-
1
;
buttons
[
C_PAUSE
].
button
=
-
1
;
buttons
[
C_PAUSE
].
button
=
-
1
;
#endif
#endif
buttons
[
C_SWIM
].
button
=
buttons
[
C_JUMP
].
button
;
axes
[
C_UP
].
axis
=
1
;
axes
[
C_UP
].
axis
=
1
;
axes
[
C_UP
].
direction
=
false
;
axes
[
C_UP
].
direction
=
false
;
axes
[
C_DOWN
].
axis
=
1
;
axes
[
C_DOWN
].
axis
=
1
;
...
@@ -86,6 +89,7 @@ Controls::Controls () {
...
@@ -86,6 +89,7 @@ Controls::Controls () {
axes
[
C_RIGHT
].
axis
=
0
;
axes
[
C_RIGHT
].
axis
=
0
;
axes
[
C_RIGHT
].
direction
=
true
;
axes
[
C_RIGHT
].
direction
=
true
;
axes
[
C_JUMP
].
axis
=
-
1
;
axes
[
C_JUMP
].
axis
=
-
1
;
axes
[
C_SWIM
].
axis
=
-
1
;
axes
[
C_FIRE
].
axis
=
-
1
;
axes
[
C_FIRE
].
axis
=
-
1
;
axes
[
C_CHANGE
].
axis
=
-
1
;
axes
[
C_CHANGE
].
axis
=
-
1
;
axes
[
C_ENTER
].
axis
=
-
1
;
axes
[
C_ENTER
].
axis
=
-
1
;
...
@@ -95,6 +99,10 @@ Controls::Controls () {
...
@@ -95,6 +99,10 @@ Controls::Controls () {
for
(
count
=
0
;
count
<
CONTROLS
;
count
++
)
{
for
(
count
=
0
;
count
<
CONTROLS
;
count
++
)
{
keys
[
count
].
state
=
false
;
buttons
[
count
].
state
=
false
;
axes
[
count
].
state
=
false
;
controls
[
count
].
time
=
0
;
controls
[
count
].
time
=
0
;
controls
[
count
].
state
=
false
;
controls
[
count
].
state
=
false
;
...
@@ -108,6 +116,7 @@ Controls::Controls () {
...
@@ -108,6 +116,7 @@ Controls::Controls () {
void
Controls
::
setKey
(
int
control
,
int
key
)
{
void
Controls
::
setKey
(
int
control
,
int
key
)
{
keys
[
control
].
key
=
key
;
keys
[
control
].
key
=
key
;
keys
[
control
].
state
=
false
;
return
;
return
;
...
@@ -117,6 +126,7 @@ void Controls::setKey (int control, int key) {
...
@@ -117,6 +126,7 @@ void Controls::setKey (int control, int key) {
void
Controls
::
setButton
(
int
control
,
int
button
)
{
void
Controls
::
setButton
(
int
control
,
int
button
)
{
buttons
[
control
].
button
=
button
;
buttons
[
control
].
button
=
button
;
buttons
[
control
].
state
=
false
;
return
;
return
;
...
@@ -127,6 +137,7 @@ void Controls::setAxis (int control, int axis, bool direction) {
...
@@ -127,6 +137,7 @@ void Controls::setAxis (int control, int axis, bool direction) {
axes
[
control
].
axis
=
axis
;
axes
[
control
].
axis
=
axis
;
axes
[
control
].
direction
=
direction
;
axes
[
control
].
direction
=
direction
;
axes
[
control
].
state
=
false
;
return
;
return
;
...
@@ -171,94 +182,60 @@ int Controls::update (SDL_Event *event, int type) {
...
@@ -171,94 +182,60 @@ int Controls::update (SDL_Event *event, int type) {
case
SDL_KEYDOWN
:
case
SDL_KEYDOWN
:
for
(
count
=
0
;
count
<
CONTROLS
;
count
++
)
if
(
type
==
KEY_LOOP
)
return
event
->
key
.
keysym
.
sym
;
if
(
event
->
key
.
keysym
.
sym
==
keys
[
count
].
key
)
{
for
(
count
=
0
;
count
<
CONTROLS
;
count
++
)
if
(
event
->
key
.
keysym
.
sym
==
keys
[
count
].
key
)
keys
[
count
].
state
=
true
;
keys
[
count
].
state
=
true
;
break
;
break
;
}
if
(
type
==
KEY_LOOP
)
return
event
->
key
.
keysym
.
sym
;
break
;
case
SDL_KEYUP
:
case
SDL_KEYUP
:
for
(
count
=
0
;
count
<
CONTROLS
;
count
++
)
for
(
count
=
0
;
count
<
CONTROLS
;
count
++
)
if
(
event
->
key
.
keysym
.
sym
==
keys
[
count
].
key
)
{
if
(
event
->
key
.
keysym
.
sym
==
keys
[
count
].
key
)
keys
[
count
].
state
=
false
;
keys
[
count
].
state
=
false
;
break
;
break
;
}
break
;
case
SDL_JOYBUTTONDOWN
:
case
SDL_JOYBUTTONDOWN
:
for
(
count
=
0
;
count
<
CONTROLS
;
count
++
)
if
(
type
==
JOYSTICK_LOOP
)
return
JOYSTICKB
|
event
->
jbutton
.
button
;
if
(
event
->
jbutton
.
button
==
buttons
[
count
].
button
)
{
for
(
count
=
0
;
count
<
CONTROLS
;
count
++
)
if
(
event
->
jbutton
.
button
==
buttons
[
count
].
button
)
buttons
[
count
].
state
=
true
;
buttons
[
count
].
state
=
true
;
break
;
break
;
}
if
(
type
==
JOYSTICK_LOOP
)
return
JOYSTICKB
|
event
->
jbutton
.
button
;
break
;
case
SDL_JOYBUTTONUP
:
case
SDL_JOYBUTTONUP
:
for
(
count
=
0
;
count
<
CONTROLS
;
count
++
)
for
(
count
=
0
;
count
<
CONTROLS
;
count
++
)
if
(
event
->
jbutton
.
button
==
buttons
[
count
].
button
)
{
if
(
event
->
jbutton
.
button
==
buttons
[
count
].
button
)
buttons
[
count
].
state
=
false
;
buttons
[
count
].
state
=
false
;
break
;
break
;
}
break
;
case
SDL_JOYAXISMOTION
:
case
SDL_JOYAXISMOTION
:
for
(
count
=
0
;
count
<
CONTROLS
;
count
++
)
if
(
type
==
JOYSTICK_LOOP
)
{
if
(
event
->
jaxis
.
axis
==
axes
[
count
].
axis
)
{
if
(
!
axes
[
count
].
direction
&&
(
event
->
jaxis
.
value
<
-
16384
))
{
axes
[
count
].
state
=
true
;
break
;
if
(
event
->
jaxis
.
value
<
-
16384
)
return
JOYSTICKANEG
|
event
->
jaxis
.
axis
;
else
if
(
event
->
jaxis
.
value
>
16384
)
return
JOYSTICKAPOS
|
event
->
jaxis
.
axis
;
}
}
else
if
(
axes
[
count
].
direction
&&
for
(
count
=
0
;
count
<
CONTROLS
;
count
++
)
(
event
->
jaxis
.
value
>
16384
)
)
{
if
(
event
->
jaxis
.
axis
==
axes
[
count
].
axis
)
{
if
(
!
axes
[
count
].
direction
&&
(
event
->
jaxis
.
value
<
-
16384
))
axes
[
count
].
state
=
true
;
axes
[
count
].
state
=
true
;
else
if
(
axes
[
count
].
direction
&&
(
event
->
jaxis
.
value
>
16384
))
break
;
axes
[
count
].
state
=
true
;
else
}
axes
[
count
].
state
=
false
;
else
axes
[
count
].
state
=
false
;
}
if
(
type
==
JOYSTICK_LOOP
)
{
if
(
event
->
jaxis
.
value
<
-
16384
)
return
JOYSTICKANEG
|
event
->
jaxis
.
axis
;
if
(
event
->
jaxis
.
value
>
16384
)
return
JOYSTICKAPOS
|
event
->
jaxis
.
axis
;
}
}
...
...
src/io/controls.h
View file @
c1b3814a
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -36,14 +36,15 @@
...
@@ -36,14 +36,15 @@
#define C_LEFT 2
#define C_LEFT 2
#define C_RIGHT 3
#define C_RIGHT 3
#define C_JUMP 4
#define C_JUMP 4
#define C_FIRE 5
#define C_SWIM 5
#define C_CHANGE 6
/* Change weapon */
#define C_FIRE 6
#define C_ENTER 7
#define C_CHANGE 7
/* Change weapon */
#define C_ESCAPE 8
#define C_ENTER 8
#define C_STATS 9
#define C_ESCAPE 9
#define C_PAUSE 10
#define C_STATS 10
#define C_PAUSE 11
// Size of those arrays
// Size of those arrays
#define CONTROLS 1
1
#define CONTROLS 1
2
// Time interval
// Time interval
#define T_KEY 200
#define T_KEY 200
...
...
src/level/demolevel.cpp
View file @
c1b3814a
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -144,6 +144,7 @@ int DemoLevel::play () {
...
@@ -144,6 +144,7 @@ int DemoLevel::play () {
localPlayer
->
setControl
(
C_FIRE
,
macroPoint
&
16
);
localPlayer
->
setControl
(
C_FIRE
,
macroPoint
&
16
);
localPlayer
->
setControl
(
C_CHANGE
,
macroPoint
&
32
);
localPlayer
->
setControl
(
C_CHANGE
,
macroPoint
&
32
);
localPlayer
->
setControl
(
C_JUMP
,
macroPoint
&
64
);
localPlayer
->
setControl
(
C_JUMP
,
macroPoint
&
64
);
localPlayer
->
setControl
(
C_SWIM
,
macroPoint
&
64
);
...
...
src/level/levelload.cpp
View file @
c1b3814a
...
@@ -811,20 +811,26 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
...
@@ -811,20 +811,26 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
// The players' coordinates
// The players' coordinates
if
(
!
checkpoint
&&
game
)
{
x
=
file
->
loadShort
();
x
=
file
->
loadShort
();
y
=
file
->
loadShort
()
+
1
;
y
=
file
->
loadShort
()
+
1
;
game
->
setCheckpoint
(
x
,
y
);
}
else
file
->
seek
(
4
,
false
);
if
(
!
checkpoint
&&
game
)
game
->
setCheckpoint
(
x
,
y
);
// Set the players' initial values
// Set the players' initial values
if
(
game
)
{
if
(
game
)
{
for
(
count
=
0
;
count
<
nPlayers
;
count
++
)
for
(
count
=
0
;
count
<
nPlayers
;
count
++
)
game
->
resetPlayer
(
players
+
count
);
game
->
resetPlayer
(
players
+
count
);
}
else
{
localPlayer
->
reset
();
localPlayer
->
setPosition
(
TTOF
(
x
),
TTOF
(
y
));
}
}
// Next level
// Next level
x
=
file
->
loadChar
();
x
=
file
->
loadChar
();
y
=
file
->
loadChar
();
y
=
file
->
loadChar
();
...
...
src/main.cpp
View file @
c1b3814a
...
@@ -182,7 +182,7 @@ int loadMain (int argc, char *argv[]) {
...
@@ -182,7 +182,7 @@ int loadMain (int argc, char *argv[]) {
}
}
// Check that the config file was opened, and has the correct version
// Check that the config file was opened, and has the correct version
if
(
file
&&
(
file
->
loadChar
()
==
1
))
{
if
(
file
&&
(
file
->
loadChar
()
==
2
))
{
// Read video settings
// Read video settings
screenW
=
file
->
loadShort
();
screenW
=
file
->
loadShort
();
...
@@ -480,7 +480,7 @@ void freeMain () {
...
@@ -480,7 +480,7 @@ void freeMain () {
if
(
file
)
{
if
(
file
)
{
// Write the version number
// Write the version number
file
->
storeChar
(
1
);
file
->
storeChar
(
2
);
// Write video settings
// Write video settings
file
->
storeShort
(
screenW
);
file
->
storeShort
(
screenW
);
...
...
src/menu/setupmenu.cpp
View file @
c1b3814a
...
@@ -37,10 +37,8 @@
...
@@ -37,10 +37,8 @@
int
Menu
::
setupKeyboard
()
{
int
Menu
::
setupKeyboard
()
{
const
char
*
options
[
7
]
=
{
"up"
,
"down"
,
"left"
,
"right"
,
"jump"
,
"fire"
,
const
char
*
options
[
PCONTROLS
]
=
{
"up"
,
"down"
,
"left"
,
"right"
,
"jump"
,
"swim up"
,
"fire"
,
"weapon"
};
"weapon"
};
int
progress
,
count
,
character
;
int
progress
,
count
,
character
;
bool
used
;
progress
=
0
;
progress
=
0
;
...
@@ -50,27 +48,25 @@ int Menu::setupKeyboard () {
...
@@ -50,27 +48,25 @@ int Menu::setupKeyboard () {
if
(
character
==
E_QUIT
)
return
E_QUIT
;
if
(
character
==
E_QUIT
)
return
E_QUIT
;
if
(
character
>
0
)
{
if
(
character
==
controls
.
getKey
(
C_ESCAPE
))
return
E_NONE
;
used
=
false
;
// Check if key is already in use
for
(
count
=
0
;
count
<
CONTROLS
;
count
++
)
if
(
character
==
controls
.
getKey
(
count
))
{
if
(
count
!=
progress
)
used
=
true
;
if
(
character
>
0
)
{
}
// If not, assign it to the current control
// If this is a navigation controls (up, down, or enter),
// make sure it's not the same as other navigation controls
if
(
!
used
)
{
if
(((
progress
!=
C_UP
)
&&
(
progress
!=
C_DOWN
)
&&
(
progress
!=
C_ENTER
))
||
(
controls
.
getKey
(
progress
)
==
character
)
||
((
controls
.
getKey
(
C_UP
)
!=
character
)
&&
(
controls
.
getKey
(
C_DOWN
)
!=
character
)
&&
(
controls
.
getKey
(
C_ENTER
)
!=
character
)))
{
controls
.
setKey
(
progress
,
character
);
controls
.
setKey
(
progress
,
character
);
progress
++
;
progress
++
;
if
(
progress
==
7
)
{
if
(
progress
==
PCONTROLS
)
{
// If all controls have been assigned, return
// If all controls have been assigned, return
...
@@ -85,13 +81,11 @@ int Menu::setupKeyboard () {
...
@@ -85,13 +81,11 @@ int Menu::setupKeyboard () {
}
}
if
(
controls
.
release
(
C_ESCAPE
))
return
E_NONE
;
SDL_Delay
(
T_FRAME
);
SDL_Delay
(
T_FRAME
);
clearScreen
(
0
);
clearScreen
(
0
);
for
(
count
=
0
;
count
<
7
;
count
++
)
{
for
(
count
=
0
;
count
<
PCONTROLS
;
count
++
)
{
if
(
count
<
progress
)
if
(
count
<
progress
)
fontmn2
->
showString
(
"okay"
,
(
screenW
>>
2
)
+
176
,
fontmn2
->
showString
(
"okay"
,
(
screenW
>>
2
)
+
176
,
...
@@ -122,10 +116,8 @@ int Menu::setupKeyboard () {
...
@@ -122,10 +116,8 @@ int Menu::setupKeyboard () {
int
Menu
::
setupJoystick
()
{
int
Menu
::
setupJoystick
()
{
const
char
*
options
[
7
]
=
{
"up"
,
"down"
,
"left"
,
"right"
,
"jump"
,
"fire"
,
const
char
*
options
[
PCONTROLS
]
=
{
"up"
,
"down"
,
"left"
,
"right"
,
"jump"
,
"swim up"
,
"fire"
,
"weapon"
};
"weapon"
};
int
progress
,
count
,
control
;
int
progress
,
count
,
control
;
bool
used
;
progress
=
0
;
progress
=
0
;
...
@@ -139,20 +131,16 @@ int Menu::setupJoystick () {
...
@@ -139,20 +131,16 @@ int Menu::setupJoystick () {
case
JOYSTICKB
:
case
JOYSTICKB
:
used
=
false
;
// If this is a navigation controls (up, down, or enter),
// make sure it's not the same as other navigation controls
// Check if the button is already in use
for
(
count
=
0
;
count
<
CONTROLS
;
count
++
)
if
(((
progress
!=
C_UP
)
&&
if
((
control
&
0xFF
)
==
controls
.
getButton
(
count
))
{
(
progress
!=
C_DOWN
)
&&
(
progress
!=
C_ENTER
))
||
if
(
count
!=
progress
)
used
=
true
;
(
controls
.
getButton
(
progress
)
==
(
control
&
0xFF
))
||
((
controls
.
getButton
(
C_UP
)
!=
(
control
&
0xFF
))
&&
}
(
controls
.
getButton
(
C_DOWN
)
!=
(
control
&
0xFF
))
&&
(
controls
.
getButton
(
C_ENTER
)
!=
(
control
&
0xFF
))))
{
// If not, assign it to the current control
if
(
!
used
)
{
controls
.
setButton
(
progress
,
control
&
0xFF
);
controls
.
setButton
(
progress
,
control
&
0xFF
);
progress
++
;
progress
++
;
...
@@ -173,21 +161,16 @@ int Menu::setupJoystick () {
...
@@ -173,21 +161,16 @@ int Menu::setupJoystick () {
case
JOYSTICKANEG
:
case
JOYSTICKANEG
:
used
=
false
;
// If this is a navigation controls (up, down, or enter),
// make sure it's not the same as other navigation controls
// Check if the arrow is already in use
for
(
count
=
0
;
count
<
CONTROLS
;
count
++
)
if
(((
control
&
0xFF
)
==
controls
.
getAxis
(
count
))
&&
!
controls
.
getAxisDirection
(
count
))
{
if
(
count
!=
progress
)
used
=
true
;
}
// If not, assign it to the current control
if
(
!
used
)
{
if
(((
progress
!=
C_UP
)
&&
(
progress
!=
C_DOWN
)
&&
(
progress
!=
C_ENTER
))
||
((
controls
.
getAxis
(
progress
)
==
(
control
&
0xFF
))
&&
!
controls
.
getAxisDirection
(
progress
))
||
(((
controls
.
getAxis
(
C_UP
)
!=
(
control
&
0xFF
))
||
controls
.
getAxisDirection
(
C_UP
))
&&
((
controls
.
getAxis
(
C_DOWN
)
!=
(
control
&
0xFF
))
||
controls
.
getAxisDirection
(
C_DOWN
))
&&
((
controls
.
getAxis
(
C_ENTER
)
!=
(
control
&
0xFF
))
||
controls
.
getAxisDirection
(
C_ENTER
))))
{
controls
.
setAxis
(
progress
,
control
&
0xFF
,
false
);
controls
.
setAxis
(
progress
,
control
&
0xFF
,
false
);
progress
++
;
progress
++
;
...
@@ -208,21 +191,16 @@ int Menu::setupJoystick () {
...
@@ -208,21 +191,16 @@ int Menu::setupJoystick () {
case
JOYSTICKAPOS
:
case
JOYSTICKAPOS
:
used
=
false
;
// If this is a navigation controls (up, down, or enter),
// make sure it's not the same as other navigation controls
// Check if the arrow is already in use
for
(
count
=
0
;
count
<
CONTROLS
;
count
++
)
if
(((
control
&
0xFF
)
==
controls
.
getAxis
(
count
))
&&
controls
.
getAxisDirection
(
count
))
{
if
(
count
!=
progress
)
used
=
true
;
}
// If not, assign it to the current control
if
(
!
used
)
{
if
(((
progress
!=
C_UP
)
&&
(
progress
!=
C_DOWN
)
&&
(
progress
!=
C_ENTER
))
||
((
controls
.
getAxis
(
progress
)
==
(
control
&
0xFF
))
&&
controls
.
getAxisDirection
(
progress
))
||
(((
controls
.
getAxis
(
C_UP
)
!=
(
control
&
0xFF
))
||
!
controls
.
getAxisDirection
(
C_UP
))
&&
((
controls
.
getAxis
(
C_DOWN
)
!=
(
control
&
0xFF
))
||
!
controls
.
getAxisDirection
(
C_DOWN
))
&&
((
controls
.
getAxis
(
C_ENTER
)
!=
(
control
&
0xFF
))
||
!
controls
.
getAxisDirection
(
C_ENTER
))))
{
controls
.
setAxis
(
progress
,
control
&
0xFF
,
true
);
controls
.
setAxis
(
progress
,
control
&
0xFF
,
true
);
progress
++
;
progress
++
;
...
@@ -424,12 +402,9 @@ int Menu::setupResolution () {
...
@@ -424,12 +402,9 @@ int Menu::setupResolution () {
int
Menu
::
setup
()
{
int
Menu
::
setup
()
{
const
char
*
setupOptions
[
4
]
=
{
"character"
,
"keyboard"
,
"joystick"
,
const
char
*
setupOptions
[
4
]
=
{
"character"
,
"keyboard"
,
"joystick"
,
"resolution"
};
"resolution"
};
const
char
*
setupCharacterOptions
[
5
]
=
{
"name"
,
"fur"
,
"bandana"
,
"gun"
,
"wristband"
};
const
char
*
setupCharacterOptions
[
5
]
=
{
"name"
,
"fur"
,
"bandana"
,
"gun"
,
const
char
*
setupCharacterColOptions
[
8
]
=
{
"white"
,
"red"
,
"orange"
,
"yellow"
,
"green"
,
"blue"
,
"animation 1"
,
"animation 2"
};
"wristband"
};
const
char
*
setupCharacterColOptions
[
8
]
=
{
"white"
,
"red"
,
"orange"
,
"yellow"
,
"green"
,
"blue"
,
"animation 1"
,
"animation 2"
};
const
unsigned
char
setupCharacterCols
[
8
]
=
{
PC_WHITE
,
PC_RED
,
PC_ORANGE
,
const
unsigned
char
setupCharacterCols
[
8
]
=
{
PC_WHITE
,
PC_RED
,
PC_ORANGE
,
PC_YELLOW
,
PC_LGREEN
,
PC_BLUE
,
PC_SANIM
,
PC_LANIM
};
PC_YELLOW
,
PC_LGREEN
,
PC_BLUE
,
PC_SANIM
,
PC_LANIM
};
int
ret
;
int
ret
;
...
...
src/player/player.cpp
View file @
c1b3814a
...
@@ -787,6 +787,7 @@ void Player::send (unsigned char *data) {
...
@@ -787,6 +787,7 @@ void Player::send (unsigned char *data) {
data
[
42
]
=
(
y
>>
16
)
&
255
;
data
[
42
]
=
(
y
>>
16
)
&
255
;
data
[
43
]
=
(
y
>>
8
)
&
255
;
data
[
43
]
=
(
y
>>
8
)
&
255
;
data
[
44
]
=
y
&
255
;
data
[
44
]
=
y
&
255
;
data
[
45
]
=
pcontrols
[
C_SWIM
];
return
;
return
;
...
@@ -795,7 +796,7 @@ void Player::send (unsigned char *data) {
...
@@ -795,7 +796,7 @@ void Player::send (unsigned char *data) {
void
Player
::
receive
(
unsigned
char
*
buffer
)
{
void
Player
::
receive
(
unsigned
char
*
buffer
)
{
// Interpret data rec
ie
ved from client/server
// Interpret data rec
ei
ved from client/server
switch
(
buffer
[
1
])
{
switch
(
buffer
[
1
])
{
...
@@ -812,6 +813,7 @@ void Player::receive (unsigned char *buffer) {
...
@@ -812,6 +813,7 @@ void Player::receive (unsigned char *buffer) {
pcontrols
[
C_LEFT
]
=
buffer
[
5
];
pcontrols
[
C_LEFT
]
=
buffer
[
5
];
pcontrols
[
C_RIGHT
]
=
buffer
[
6
];
pcontrols
[
C_RIGHT
]
=
buffer
[
6
];
pcontrols
[
C_JUMP
]
=
buffer
[
7
];
pcontrols
[
C_JUMP
]
=
buffer
[
7
];
pcontrols
[
C_SWIM
]
=
buffer
[
45
];
pcontrols
[
C_FIRE
]
=
buffer
[
8
];
pcontrols
[
C_FIRE
]
=
buffer
[
8
];
pcontrols
[
C_CHANGE
]
=
false
;
pcontrols
[
C_CHANGE
]
=
false
;
...
...
src/player/player.h
View file @
c1b3814a
...
@@ -148,7 +148,7 @@
...
@@ -148,7 +148,7 @@
// General
// General
#define PANIMS 38
/* Number of player animations. Is probably higher. */
#define PANIMS 38
/* Number of player animations. Is probably higher. */
#define PCONTROLS
7
/* Number of player controls. */
#define PCONTROLS
8
/* Number of player controls. */
// Classes
// Classes
...
...
src/player/playerframe.cpp
View file @
c1b3814a
...
@@ -158,7 +158,7 @@ void Player::control (unsigned int ticks, int msps) {
...
@@ -158,7 +158,7 @@ void Player::control (unsigned int ticks, int msps) {
}
else
if
(
y
+
PYO_MID
>
level
->
getWaterLevel
())
{
}
else
if
(
y
+
PYO_MID
>
level
->
getWaterLevel
())
{
if
(
pcontrols
[
C_
JUMP
])
{
if
(
pcontrols
[
C_
SWIM
])
{
// Swim upwards
// Swim upwards
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment