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
30bfea2a
Commit
30bfea2a
authored
Apr 02, 2010
by
alistert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added #defines for 320 and 200. Changed some #defines to enums. Simplified panel data loading.
parent
93c4b9c1
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
222 additions
and
261 deletions
+222
-261
OpenJazz.h
src/OpenJazz.h
+11
-8
clientgame.cpp
src/game/clientgame.cpp
+3
-2
game.h
src/game/game.h
+4
-2
gamemode.cpp
src/game/gamemode.cpp
+10
-6
gamemode.h
src/game/gamemode.h
+22
-22
servergame.cpp
src/game/servergame.cpp
+2
-2
font.cpp
src/io/gfx/font.cpp
+32
-77
font.h
src/io/gfx/font.h
+1
-1
paletteeffects.cpp
src/io/gfx/paletteeffects.cpp
+1
-1
video.cpp
src/io/gfx/video.cpp
+4
-4
video.h
src/io/gfx/video.h
+9
-5
level.cpp
src/level/level.cpp
+3
-3
level.h
src/level/level.h
+12
-8
levelframe.cpp
src/level/levelframe.cpp
+7
-5
main.cpp
src/main.cpp
+23
-38
gamemenu.cpp
src/menu/gamemenu.cpp
+3
-3
mainmenu.cpp
src/menu/mainmenu.cpp
+5
-6
menu.cpp
src/menu/menu.cpp
+5
-5
menu.h
src/menu/menu.h
+7
-5
setupmenu.cpp
src/menu/setupmenu.cpp
+7
-6
player.cpp
src/player/player.cpp
+2
-2
player.h
src/player/player.h
+41
-42
scene.cpp
src/scene/scene.cpp
+7
-7
sceneload.cpp
src/scene/sceneload.cpp
+1
-1
No files found.
src/OpenJazz.h
View file @
30bfea2a
...
@@ -110,12 +110,6 @@
...
@@ -110,12 +110,6 @@
// Standard string length
// Standard string length
#define STRING_LENGTH 32
#define STRING_LENGTH 32
// Loop return type
#define NORMAL_LOOP 0
#define TYPING_LOOP 1
#define SET_KEY_LOOP 2
#define SET_JOYSTICK_LOOP 3
// Return values
// Return values
#define E_DATA -14
#define E_DATA -14
#define E_VERSION -13
#define E_VERSION -13
...
@@ -150,7 +144,16 @@
...
@@ -150,7 +144,16 @@
#define MUL(x, y) (((x) * (y)) >> 10)
#define MUL(x, y) (((x) * (y)) >> 10)
#define DIV(x, y) (((x) << 10) / (y))
#define DIV(x, y) (((x) << 10) / (y))
// Enum
enum
LoopType
{
NORMAL_LOOP
,
TYPING_LOOP
,
SET_KEY_LOOP
,
SET_JOYSTICK_LOOP
};
// Datatype
// Datatype
typedef
int
fixed
;
typedef
int
fixed
;
...
@@ -164,7 +167,7 @@ EXTERN unsigned int globalTicks;
...
@@ -164,7 +167,7 @@ EXTERN unsigned int globalTicks;
// Functions in main.cpp
// Functions in main.cpp
EXTERN
int
loop
(
int
type
);
EXTERN
int
loop
(
LoopType
type
);
// Functions in util.cpp
// Functions in util.cpp
...
...
src/game/clientgame.cpp
View file @
30bfea2a
...
@@ -40,7 +40,8 @@ ClientGame::ClientGame (char *address) {
...
@@ -40,7 +40,8 @@ ClientGame::ClientGame (char *address) {
unsigned
char
buffer
[
BUFFER_LENGTH
];
unsigned
char
buffer
[
BUFFER_LENGTH
];
unsigned
int
timeout
;
unsigned
int
timeout
;
int
count
,
ret
,
mode
;
int
count
,
ret
;
GameModeType
mode
;
sock
=
net
->
join
(
address
);
sock
=
net
->
join
(
address
);
...
@@ -108,7 +109,7 @@ ClientGame::ClientGame (char *address) {
...
@@ -108,7 +109,7 @@ ClientGame::ClientGame (char *address) {
printf
(
"Connected to server (version %d).
\n
"
,
buffer
[
2
]);
printf
(
"Connected to server (version %d).
\n
"
,
buffer
[
2
]);
// Copy game parameters
// Copy game parameters
mode
=
buffer
[
3
]
;
mode
=
GameModeType
(
buffer
[
3
])
;
difficulty
=
buffer
[
4
];
difficulty
=
buffer
[
4
];
maxPlayers
=
buffer
[
5
];
maxPlayers
=
buffer
[
5
];
nPlayers
=
buffer
[
6
];
nPlayers
=
buffer
[
6
];
...
...
src/game/game.h
View file @
30bfea2a
...
@@ -24,7 +24,9 @@
...
@@ -24,7 +24,9 @@
#ifndef _GAME_H
#ifndef _GAME_H
#define _GAME_H
#define _GAME_H
#include "gamemode.h"
#include "io/network.h"
#include "io/network.h"
...
@@ -124,7 +126,7 @@ class ServerGame : public Game {
...
@@ -124,7 +126,7 @@ class ServerGame : public Game {
int
sock
;
int
sock
;
public
:
public
:
ServerGame
(
int
mode
,
char
*
firstLevel
,
int
gameDifficulty
);
ServerGame
(
GameModeType
mode
,
char
*
firstLevel
,
int
gameDifficulty
);
~
ServerGame
();
~
ServerGame
();
int
setLevel
(
char
*
fileName
);
int
setLevel
(
char
*
fileName
);
...
...
src/game/gamemode.cpp
View file @
30bfea2a
...
@@ -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
...
@@ -147,7 +147,7 @@ void TeamGameMode::drawScore () {
...
@@ -147,7 +147,7 @@ void TeamGameMode::drawScore () {
}
}
int
CoopGameMode
::
getMode
()
{
GameModeType
CoopGameMode
::
getMode
()
{
return
M_COOP
;
return
M_COOP
;
...
@@ -166,21 +166,21 @@ bool CoopGameMode::endOfLevel (Player *player, unsigned char gridX,
...
@@ -166,21 +166,21 @@ bool CoopGameMode::endOfLevel (Player *player, unsigned char gridX,
}
}
int
BattleGameMode
::
getMode
()
{
GameModeType
BattleGameMode
::
getMode
()
{
return
M_BATTLE
;
return
M_BATTLE
;
}
}
int
TeamBattleGameMode
::
getMode
()
{
GameModeType
TeamBattleGameMode
::
getMode
()
{
return
M_TEAMBATTLE
;
return
M_TEAMBATTLE
;
}
}
int
RaceGameMode
::
getMode
()
{
GameModeType
RaceGameMode
::
getMode
()
{
return
M_RACE
;
return
M_RACE
;
...
@@ -206,9 +206,13 @@ bool RaceGameMode::endOfLevel (Player *player, unsigned char gridX,
...
@@ -206,9 +206,13 @@ bool RaceGameMode::endOfLevel (Player *player, unsigned char gridX,
}
}
GameMode
*
createGameMode
(
int
mode
)
{
GameMode
*
createGameMode
(
GameModeType
mode
)
{
switch
(
mode
)
{
switch
(
mode
)
{
case
M_SINGLE
:
return
NULL
;
case
M_COOP
:
case
M_COOP
:
...
...
src/game/gamemode.h
View file @
30bfea2a
...
@@ -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
...
@@ -29,14 +29,16 @@
...
@@ -29,14 +29,16 @@
// Constants
// Constants
// Game modes
#define MAX_PLAYERS (MAX_CLIENTS + 1)
#define M_SINGLE 0
#define M_COOP 1
#define M_BATTLE 2
// Enum
#define M_TEAMBATTLE 3
#define M_RACE 4
enum
GameModeType
{
#define MAX_PLAYERS (MAX_CLIENTS + 1)
M_SINGLE
=
0
,
M_COOP
=
1
,
M_BATTLE
=
2
,
M_TEAMBATTLE
=
3
,
M_RACE
=
4
};
// Classes
// Classes
...
@@ -46,13 +48,12 @@ class Player;
...
@@ -46,13 +48,12 @@ class Player;
class
GameMode
{
class
GameMode
{
public
:
public
:
virtual
int
getMode
()
=
0
;
virtual
GameModeType
getMode
()
=
0
;
virtual
unsigned
char
chooseTeam
()
=
0
;
virtual
unsigned
char
chooseTeam
()
=
0
;
virtual
void
drawScore
()
=
0
;
virtual
void
drawScore
()
=
0
;
virtual
bool
hit
(
Player
*
source
,
Player
*
victim
);
virtual
bool
hit
(
Player
*
source
,
Player
*
victim
);
virtual
bool
kill
(
Player
*
source
,
Player
*
victim
);
virtual
bool
kill
(
Player
*
source
,
Player
*
victim
);
virtual
bool
endOfLevel
(
Player
*
player
,
unsigned
char
gridX
,
virtual
bool
endOfLevel
(
Player
*
player
,
unsigned
char
gridX
,
unsigned
char
gridY
);
unsigned
char
gridY
);
virtual
void
outOfTime
();
virtual
void
outOfTime
();
};
};
...
@@ -84,9 +85,8 @@ class TeamGameMode : public GameMode {
...
@@ -84,9 +85,8 @@ class TeamGameMode : public GameMode {
class
CoopGameMode
:
public
CooperativeGameMode
{
class
CoopGameMode
:
public
CooperativeGameMode
{
public
:
public
:
int
getMode
();
GameModeType
getMode
();
bool
endOfLevel
(
Player
*
player
,
unsigned
char
gridX
,
bool
endOfLevel
(
Player
*
player
,
unsigned
char
gridX
,
unsigned
char
gridY
);
unsigned
char
gridY
);
};
};
...
@@ -96,7 +96,7 @@ class BattleGameMode : public FreeForAllGameMode {
...
@@ -96,7 +96,7 @@ class BattleGameMode : public FreeForAllGameMode {
int
targetKills
;
int
targetKills
;
public
:
public
:
int
getMode
();
GameModeType
getMode
();
};
};
...
@@ -106,7 +106,7 @@ class TeamBattleGameMode : public TeamGameMode {
...
@@ -106,7 +106,7 @@ class TeamBattleGameMode : public TeamGameMode {
int
targetKills
;
int
targetKills
;
public
:
public
:
int
getMode
();
GameModeType
getMode
();
};
};
...
@@ -116,12 +116,12 @@ class RaceGameMode : public FreeForAllGameMode {
...
@@ -116,12 +116,12 @@ class RaceGameMode : public FreeForAllGameMode {
int
targetLaps
;
int
targetLaps
;
public
:
public
:
int
getMode
();
GameModeType
getMode
();
bool
hit
(
Player
*
source
,
Player
*
victim
);
bool
hit
(
Player
*
source
,
Player
*
victim
);
bool
endOfLevel
(
Player
*
player
,
unsigned
char
gridX
,
bool
endOfLevel
(
Player
*
player
,
unsigned
char
gridX
,
unsigned
char
gridY
);
unsigned
char
gridY
);
};
};
// Variable
// Variable
...
@@ -130,7 +130,7 @@ EXTERN GameMode *gameMode; // NULL for single-player games
...
@@ -130,7 +130,7 @@ EXTERN GameMode *gameMode; // NULL for single-player games
// Function
// Function
GameMode
*
createGameMode
(
int
mode
);
GameMode
*
createGameMode
(
GameModeType
mode
);
#endif
#endif
...
...
src/game/servergame.cpp
View file @
30bfea2a
...
@@ -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
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
#include <string.h>
#include <string.h>
ServerGame
::
ServerGame
(
int
mode
,
char
*
firstLevel
,
int
gameDifficulty
)
{
ServerGame
::
ServerGame
(
GameModeType
mode
,
char
*
firstLevel
,
int
gameDifficulty
)
{
int
count
;
int
count
;
...
...
src/io/gfx/font.cpp
View file @
30bfea2a
...
@@ -150,101 +150,56 @@ Font::Font (const char * fileName) {
...
@@ -150,101 +150,56 @@ Font::Font (const char * fileName) {
}
}
Font
::
Font
(
File
*
file
,
bool
big
)
{
Font
::
Font
(
unsigned
char
*
pixels
,
bool
big
)
{
unsigned
char
*
pixels
;
unsigned
char
*
chrPixels
;
int
rle
,
pos
,
index
,
count
;
int
count
,
y
;
// Load font from panel.000
if
(
big
)
lineHeight
=
8
;
if
(
big
)
lineHeight
=
8
;
else
lineHeight
=
7
;
else
lineHeight
=
7
;
pixels
=
new
unsigned
char
[
320
*
lineHeight
];
chrPixels
=
new
unsigned
char
[
8
*
lineHeight
];
if
(
big
)
{
for
(
count
=
0
;
count
<
40
;
count
++
)
{
// Load the large panel font
for
(
y
=
0
;
y
<
lineHeight
;
y
++
)
// Starts at 4691 and goes 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-:.
memcpy
(
chrPixels
+
(
y
*
8
),
pixels
+
(
count
*
8
)
+
(
y
*
SW
),
8
);
pixels
[
0
]
=
BLACK
;
pos
=
1
;
file
->
seek
(
4691
,
true
);
}
else
{
// Load the small panel font
// Starts at 6975 and goes 0123456789oo (where oo = infinity)
pos
=
0
;
file
->
seek
(
6975
,
true
);
}
// RLE decompression and horizontal to vertical character rearrangement
while
(
pos
<
320
*
lineHeight
)
{
rle
=
file
->
loadChar
();
if
(
rle
>=
128
)
{
index
=
file
->
loadChar
();
for
(
count
=
0
;
count
<
(
rle
&
127
);
count
++
)
{
pixels
[(
pos
&
7
)
+
((
pos
/
320
)
*
8
)
+
(((
pos
%
320
)
>>
3
)
*
8
*
lineHeight
)]
=
index
;
pos
++
;
}
}
else
if
(
rle
>
0
)
{
for
(
count
=
0
;
count
<
rle
;
count
++
)
{
pixels
[(
pos
&
7
)
+
((
pos
/
320
)
*
8
)
+
(((
pos
%
320
)
>>
3
)
*
8
*
lineHeight
)]
=
file
->
loadChar
();
pos
++
;
}
}
else
break
;
}
for
(
count
=
0
;
count
<
40
;
count
++
)
characters
[
count
]
=
createSurface
(
chrPixels
,
8
,
lineHeight
);
characters
[
count
]
=
createSurface
(
pixels
+
(
count
*
8
*
lineHeight
),
8
,
lineHeight
);
}
nCharacters
=
40
;
nCharacters
=
40
;
delete
[]
p
ixels
;
delete
[]
chrP
ixels
;
if
(
big
)
{
if
(
big
)
{
// Goes " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-:."
// Create ASCII->font map
// Create ASCII->font map
for
(
count
=
0
;
count
<
45
;
count
++
)
map
[
count
]
=
39
;
for
(
count
=
0
;
count
<
45
;
count
++
)
map
[
count
]
=
0
;
map
[
45
]
=
3
6
;
map
[
45
]
=
3
7
;
map
[
46
]
=
3
8
;
map
[
46
]
=
3
9
;
for
(
count
=
47
;
count
<
48
;
count
++
)
map
[
count
]
=
39
;
for
(
count
=
47
;
count
<
48
;
count
++
)
map
[
count
]
=
0
;
for
(;
count
<
58
;
count
++
)
map
[
count
]
=
count
-
4
8
;
for
(;
count
<
58
;
count
++
)
map
[
count
]
=
count
-
4
7
;
map
[
58
]
=
3
7
;
map
[
58
]
=
3
8
;
for
(
count
=
59
;
count
<
65
;
count
++
)
map
[
count
]
=
39
;
for
(
count
=
59
;
count
<
65
;
count
++
)
map
[
count
]
=
0
;
for
(;
count
<
91
;
count
++
)
map
[
count
]
=
count
-
5
5
;
for
(;
count
<
91
;
count
++
)
map
[
count
]
=
count
-
5
4
;
for
(;
count
<
97
;
count
++
)
map
[
count
]
=
39
;
for
(;
count
<
97
;
count
++
)
map
[
count
]
=
0
;
for
(;
count
<
123
;
count
++
)
map
[
count
]
=
count
-
8
7
;
for
(;
count
<
123
;
count
++
)
map
[
count
]
=
count
-
8
6
;
for
(;
count
<
128
;
count
++
)
map
[
count
]
=
39
;
for
(;
count
<
128
;
count
++
)
map
[
count
]
=
0
;
}
else
{
}
else
{
// Goes " 0123456789oo" (where oo = infinity)
// Create ASCII->font map
// Create ASCII->font map
for
(
count
=
0
;
count
<
48
;
count
++
)
map
[
count
]
=
12
;
for
(
count
=
0
;
count
<
48
;
count
++
)
map
[
count
]
=
0
;
// Use :; to represent the infinity symbol
// Use :; to represent the infinity symbol
for
(;
count
<
60
;
count
++
)
map
[
count
]
=
count
-
4
8
;
for
(;
count
<
60
;
count
++
)
map
[
count
]
=
count
-
4
7
;
for
(;
count
<
128
;
count
++
)
map
[
count
]
=
12
;
for
(;
count
<
128
;
count
++
)
map
[
count
]
=
0
;
}
}
...
...
src/io/gfx/font.h
View file @
30bfea2a
...
@@ -43,7 +43,7 @@ class Font {
...
@@ -43,7 +43,7 @@ class Font {
public
:
public
:
Font
(
const
char
*
fileName
);
Font
(
const
char
*
fileName
);
Font
(
File
*
file
,
bool
big
);
Font
(
unsigned
char
*
pixels
,
bool
big
);
~
Font
();
~
Font
();
int
showString
(
const
char
*
s
,
int
x
,
int
y
);
int
showString
(
const
char
*
s
,
int
x
,
int
y
);
...
...
src/io/gfx/paletteeffects.cpp
View file @
30bfea2a
...
@@ -387,7 +387,7 @@ void SkyPaletteEffect::apply (SDL_Color *shownPalette, bool direct, int mspf) {
...
@@ -387,7 +387,7 @@ void SkyPaletteEffect::apply (SDL_Color *shownPalette, bool direct, int mspf) {
position
=
viewY
+
(
viewH
<<
9
)
-
F4
;
position
=
viewY
+
(
viewH
<<
9
)
-
F4
;
if
(
canvasW
>
320
)
y
=
((
canvasH
-
1
)
/
100
)
+
1
;
if
(
canvasW
>
SW
)
y
=
((
canvasH
-
1
)
/
100
)
+
1
;
else
y
=
((
canvasH
-
34
)
/
100
)
+
1
;
else
y
=
((
canvasH
-
34
)
/
100
)
+
1
;
count
=
(((
position
*
speed
)
/
y
)
>>
20
)
%
255
;
count
=
(((
position
*
speed
)
/
y
)
>>
20
)
%
255
;
...
...
src/io/gfx/video.cpp
View file @
30bfea2a
...
@@ -67,18 +67,18 @@ void createScreen () {
...
@@ -67,18 +67,18 @@ void createScreen () {
#endif
#endif
#if defined(WIZ) || defined(GP2X)
#if defined(WIZ) || defined(GP2X)
screen
=
SDL_SetVideoMode
(
320
,
240
,
8
,
V_FULLSCREEN
);
screen
=
SDL_SetVideoMode
(
320
,
240
,
8
,
FULLSCREEN_FLAGS
);
#else
#else
#ifdef FULLSCREEN_ONLY
#ifdef FULLSCREEN_ONLY
screen
=
SDL_SetVideoMode
(
screenW
,
screenH
,
8
,
V_FULLSCREEN
);
screen
=
SDL_SetVideoMode
(
screenW
,
screenH
,
8
,
FULLSCREEN_FLAGS
);
#else
#else
screen
=
SDL_SetVideoMode
(
screenW
,
screenH
,
8
,
fullscreen
?
V_FULLSCREEN
:
V_WINDOWED
);
screen
=
SDL_SetVideoMode
(
screenW
,
screenH
,
8
,
fullscreen
?
FULLSCREEN_FLAGS
:
WINDOWED_FLAGS
);
#endif
#endif
#endif
#endif
#ifdef SCALE
#ifdef SCALE
// Check that the scale will fit in the current resolution
// Check that the scale will fit in the current resolution
while
(
((
screenW
/
320
<
scaleFactor
)
||
(
screenH
/
200
<
scaleFactor
))
&&
(
scaleFactor
>
1
)
)
{
while
(
((
screenW
/
SW
<
scaleFactor
)
||
(
screenH
/
SH
<
scaleFactor
))
&&
(
scaleFactor
>
1
)
)
{
scaleFactor
--
;
scaleFactor
--
;
...
...
src/io/gfx/video.h
View file @
30bfea2a
...
@@ -20,8 +20,8 @@
...
@@ -20,8 +20,8 @@
*
*
*/
*/
#ifndef _
GRAPHICS
_H
#ifndef _
VIDEO
_H
#define _
GRAPHICS
_H
#define _
VIDEO
_H
#include "OpenJazz.h"
#include "OpenJazz.h"
...
@@ -31,12 +31,16 @@
...
@@ -31,12 +31,16 @@
// Constants
// Constants
#define V_WINDOWED (SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE)
// Original screen dimensions
#define SW 320
#define SH 200
#define WINDOWED_FLAGS (SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE)
#if defined(WIZ) || defined(GP2X)
#if defined(WIZ) || defined(GP2X)
#define
V_FULLSCREEN
(SDL_FULLSCREEN | SDL_SWSURFACE | SDL_HWPALETTE)
#define
FULLSCREEN_FLAGS
(SDL_FULLSCREEN | SDL_SWSURFACE | SDL_HWPALETTE)
#else
#else
#define
V_FULLSCREEN
(SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE)
#define
FULLSCREEN_FLAGS
(SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE)
#endif
#endif
#ifdef SCALE
#ifdef SCALE
...
...
src/level/level.cpp
View file @
30bfea2a
...
@@ -434,7 +434,7 @@ void Level::playSound (int sound) {
...
@@ -434,7 +434,7 @@ void Level::playSound (int sound) {
}
}
void
Level
::
setStage
(
int
newStage
)
{
void
Level
::
setStage
(
LevelStage
newStage
)
{
unsigned
char
buffer
[
MTL_L_STAGE
];
unsigned
char
buffer
[
MTL_L_STAGE
];
...
@@ -456,7 +456,7 @@ void Level::setStage (int newStage) {
...
@@ -456,7 +456,7 @@ void Level::setStage (int newStage) {
}
}
int
Level
::
getStage
()
{
LevelStage
Level
::
getStage
()
{
return
stage
;
return
stage
;
...
@@ -508,7 +508,7 @@ void Level::receive (unsigned char *buffer) {
...
@@ -508,7 +508,7 @@ void Level::receive (unsigned char *buffer) {
case
MT_L_STAGE
:
case
MT_L_STAGE
:
stage
=
buffer
[
2
]
;
stage
=
LevelStage
(
buffer
[
2
])
;
break
;
break
;
...
...
src/level/level.h
View file @
30bfea2a
...
@@ -52,14 +52,18 @@
...
@@ -52,14 +52,18 @@
#define PATHS 16
#define PATHS 16
#define TKEY 127
/* Tileset colour key */
#define TKEY 127
/* Tileset colour key */
// Stages
#define LS_NORMAL 0
#define LS_SUDDENDEATH 1
#define LS_END 2
// Fade delays
// Fade delays
#define T_START 500
#define T_START 500
#define T_END 1000
#define T_END 1000
// Enum
enum
LevelStage
{
LS_NORMAL
=
0
,
LS_SUDDENDEATH
=
1
,
LS_END
=
2
};
// Datatypes
// Datatypes
...
@@ -115,7 +119,7 @@ class Level : public BaseLevel {
...
@@ -115,7 +119,7 @@ class Level : public BaseLevel {
fixed
waterLevelTarget
;
fixed
waterLevelTarget
;
fixed
waterLevelSpeed
;
fixed
waterLevelSpeed
;
fixed
energyBar
;
fixed
energyBar
;
int
stage
;
LevelStage
stage
;
int
loadSprites
(
char
*
fileName
);
int
loadSprites
(
char
*
fileName
);
int
loadTiles
(
char
*
fileName
);
int
loadTiles
(
char
*
fileName
);
...
@@ -153,8 +157,8 @@ class Level : public BaseLevel {
...
@@ -153,8 +157,8 @@ class Level : public BaseLevel {
void
setWaterLevel
(
unsigned
char
gridY
);
void
setWaterLevel
(
unsigned
char
gridY
);
fixed
getWaterLevel
();
fixed
getWaterLevel
();
void
playSound
(
int
sound
);
void
playSound
(
int
sound
);
void
setStage
(
int
stage
);
void
setStage
(
LevelStage
stage
);
int
getStage
();
LevelStage
getStage
();
Scene
*
createScene
();
Scene
*
createScene
();
void
receive
(
unsigned
char
*
buffer
);
void
receive
(
unsigned
char
*
buffer
);
virtual
int
play
();
virtual
int
play
();
...
...
src/level/levelframe.cpp
View file @
30bfea2a
...
@@ -364,7 +364,7 @@ void Level::draw () {
...
@@ -364,7 +364,7 @@ void Level::draw () {
dst
.
x
=
0
;
dst
.
x
=
0
;
dst
.
y
=
canvasH
-
33
;
dst
.
y
=
canvasH
-
33
;
SDL_BlitSurface
(
panel
,
NULL
,
canvas
,
&
dst
);
SDL_BlitSurface
(
panel
,
NULL
,
canvas
,
&
dst
);
drawRect
(
0
,
canvasH
-
1
,
320
,
1
,
BLACK
);
drawRect
(
0
,
canvasH
-
1
,
SW
,
1
,
BLACK
);
// Show panel data
// Show panel data
...
@@ -400,10 +400,12 @@ void Level::draw () {
...
@@ -400,10 +400,12 @@ void Level::draw () {
panelSmallFont
->
showNumber
(
levelNum
+
1
,
196
,
canvasH
-
13
);
panelSmallFont
->
showNumber
(
levelNum
+
1
,
196
,
canvasH
-
13
);
// Show ammo
// Show ammo
if
(
localPlayer
->
getAmmo
(
false
)
==
-
1
)
if
(
localPlayer
->
getAmmo
(
false
)
==
-
1
)
{
panelSmallFont
->
showString
(
":;"
,
225
,
canvasH
-
13
);
else
panelSmallFont
->
showNumber
(
localPlayer
->
getAmmo
(
true
),
245
,
panelSmallFont
->
showString
(
":"
,
225
,
canvasH
-
13
);
canvasH
-
13
);
panelSmallFont
->
showString
(
";"
,
233
,
canvasH
-
13
);
}
else
panelSmallFont
->
showNumber
(
localPlayer
->
getAmmo
(
true
),
245
,
canvasH
-
13
);
// Draw the health bar
// Draw the health bar
...
...
src/main.cpp
View file @
30bfea2a
...
@@ -158,8 +158,8 @@ int loadMain (int argc, char *argv[]) {
...
@@ -158,8 +158,8 @@ int loadMain (int argc, char *argv[]) {
// Default settings
// Default settings
// Video settings
// Video settings
screenW
=
320
;
screenW
=
SW
;
screenH
=
200
;
screenH
=
SH
;
#ifndef FULLSCREEN_ONLY
#ifndef FULLSCREEN_ONLY
fullscreen
=
false
;
fullscreen
=
false
;
#endif
#endif
...
@@ -327,87 +327,73 @@ int loadMain (int argc, char *argv[]) {
...
@@ -327,87 +327,73 @@ int loadMain (int argc, char *argv[]) {
}
}
// Load the panel background
pixels
=
file
->
loadRLE
(
46272
);
panel
=
file
->
loadSurface
(
320
,
32
);
delete
file
;
// Create the panel background
panel
=
createSurface
(
pixels
,
SW
,
32
);
//
Load
the panel's ammo graphics
//
De-scramble
the panel's ammo graphics
sorted
=
new
unsigned
char
[
64
*
27
];
sorted
=
new
unsigned
char
[
64
*
27
];
file
->
seek
(
7537
,
true
);
pixels
=
file
->
loadRLE
(
64
*
27
);
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)];
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
55
*
320
)
];
}
}
panelAmmo
[
0
]
=
createSurface
(
sorted
,
64
,
27
);
panelAmmo
[
0
]
=
createSurface
(
sorted
,
64
,
27
);
delete
[]
pixels
;
file
->
seek
(
8264
,
true
);
pixels
=
file
->
loadRLE
(
64
*
27
);
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)];
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
61
*
320
)
];
}
}
panelAmmo
[
1
]
=
createSurface
(
sorted
,
64
,
27
);
panelAmmo
[
1
]
=
createSurface
(
sorted
,
64
,
27
);
delete
[]
pixels
;
file
->
seek
(
9550
,
true
);
pixels
=
file
->
loadRLE
(
64
*
27
);
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)];
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
68
*
320
)
];
}
}
panelAmmo
[
2
]
=
createSurface
(
sorted
,
64
,
27
);
panelAmmo
[
2
]
=
createSurface
(
sorted
,
64
,
27
);
delete
[]
pixels
;
file
->
seek
(
11060
,
true
);
pixels
=
file
->
loadRLE
(
64
*
27
);
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)];
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
74
*
320
)
];
}
}
panelAmmo
[
3
]
=
createSurface
(
sorted
,
64
,
27
);
panelAmmo
[
3
]
=
createSurface
(
sorted
,
64
,
27
);
delete
[]
pixels
;
file
->
seek
(
12258
,
true
);
pixels
=
file
->
loadRLE
(
64
*
27
);
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)];
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
86
*
320
)
];
}
}
panelAmmo
[
4
]
=
createSurface
(
sorted
,
64
,
27
);
panelAmmo
[
4
]
=
createSurface
(
sorted
,
64
,
27
);
delete
[]
pixels
;
delete
[]
sorted
;
delete
[]
sorted
;
// Load fonts
// Load fonts
panelBigFont
=
NULL
;
panelBigFont
=
NULL
;
panelSmallFont
=
NULL
;
panelSmallFont
=
NULL
;
font2
=
NULL
;
font2
=
NULL
;
...
@@ -417,8 +403,8 @@ int loadMain (int argc, char *argv[]) {
...
@@ -417,8 +403,8 @@ int loadMain (int argc, char *argv[]) {
try
{
try
{
panelBigFont
=
new
Font
(
file
,
true
);
panelBigFont
=
new
Font
(
pixels
+
(
40
*
320
)
,
true
);
panelSmallFont
=
new
Font
(
file
,
false
);
panelSmallFont
=
new
Font
(
pixels
+
(
48
*
320
)
,
false
);
font2
=
new
Font
(
"font2.0fn"
);
font2
=
new
Font
(
"font2.0fn"
);
fontbig
=
new
Font
(
"fontbig.0fn"
);
fontbig
=
new
Font
(
"fontbig.0fn"
);
fontiny
=
new
Font
(
"fontiny.0fn"
);
fontiny
=
new
Font
(
"fontiny.0fn"
);
...
@@ -434,6 +420,8 @@ int loadMain (int argc, char *argv[]) {
...
@@ -434,6 +420,8 @@ int loadMain (int argc, char *argv[]) {
if
(
fontiny
)
delete
fontiny
;
if
(
fontiny
)
delete
fontiny
;
if
(
fontmn1
)
delete
fontmn1
;
if
(
fontmn1
)
delete
fontmn1
;
delete
[]
pixels
;
SDL_FreeSurface
(
panel
);
SDL_FreeSurface
(
panel
);
SDL_FreeSurface
(
panelAmmo
[
0
]);
SDL_FreeSurface
(
panelAmmo
[
0
]);
SDL_FreeSurface
(
panelAmmo
[
1
]);
SDL_FreeSurface
(
panelAmmo
[
1
]);
...
@@ -447,14 +435,11 @@ int loadMain (int argc, char *argv[]) {
...
@@ -447,14 +435,11 @@ int loadMain (int argc, char *argv[]) {
delete
firstPath
;
delete
firstPath
;
delete
file
;
return
e
;
return
e
;
}
}
delete
[]
pixels
;
delete
file
;
// Establish arbitrary timing
// Establish arbitrary timing
...
@@ -578,7 +563,7 @@ void freeMain () {
...
@@ -578,7 +563,7 @@ void freeMain () {
}
}
int
loop
(
int
type
)
{
int
loop
(
LoopType
type
)
{
SDL_Color
shownPalette
[
256
];
SDL_Color
shownPalette
[
256
];
SDL_Event
event
;
SDL_Event
event
;
...
...
src/menu/gamemenu.cpp
View file @
30bfea2a
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
#include "io/sound.h"
#include "io/sound.h"
int
Menu
::
newGameDifficulty
(
int
mode
,
int
levelNum
,
int
worldNum
)
{
int
Menu
::
newGameDifficulty
(
GameModeType
mode
,
int
levelNum
,
int
worldNum
)
{
const
char
*
options
[
4
]
=
{
"easy"
,
"medium"
,
"hard"
,
"turbo"
};
const
char
*
options
[
4
]
=
{
"easy"
,
"medium"
,
"hard"
,
"turbo"
};
char
*
firstLevel
;
char
*
firstLevel
;
...
@@ -153,7 +153,7 @@ int Menu::newGameDifficulty (int mode, int levelNum, int worldNum) {
...
@@ -153,7 +153,7 @@ int Menu::newGameDifficulty (int mode, int levelNum, int worldNum) {
}
}
int
Menu
::
newGameLevel
(
int
mode
)
{
int
Menu
::
newGameLevel
(
GameModeType
mode
)
{
int
option
,
worldNum
,
levelNum
;
int
option
,
worldNum
,
levelNum
;
...
@@ -220,7 +220,7 @@ int Menu::newGameLevel (int mode) {
...
@@ -220,7 +220,7 @@ int Menu::newGameLevel (int mode) {
}
}
int
Menu
::
newGameEpisode
(
int
mode
)
{
int
Menu
::
newGameEpisode
(
GameModeType
mode
)
{
const
char
*
options
[
12
]
=
{
"episode 1"
,
"episode 2"
,
"episode 3"
,
const
char
*
options
[
12
]
=
{
"episode 1"
,
"episode 2"
,
"episode 3"
,
"episode 4"
,
"episode 5"
,
"episode 6"
,
"episode a"
,
"episode b"
,
"episode 4"
,
"episode 5"
,
"episode 6"
,
"episode a"
,
"episode b"
,
...
...
src/menu/mainmenu.cpp
View file @
30bfea2a
...
@@ -89,8 +89,7 @@ int Menu::main () {
...
@@ -89,8 +89,7 @@ int Menu::main () {
}
else
{
}
else
{
if
(
newGameEpisode
(
suboption
)
==
E_QUIT
)
if
(
newGameEpisode
(
GameModeType
(
suboption
))
==
E_QUIT
)
return
E_QUIT
;
return
E_QUIT
;
}
}
...
@@ -237,8 +236,8 @@ int Menu::main () {
...
@@ -237,8 +236,8 @@ int Menu::main () {
dst
.
y
=
canvasH
-
(
canvasH
>>
2
);
dst
.
y
=
canvasH
-
(
canvasH
>>
2
);
SDL_BlitSurface
(
screens
[
14
],
NULL
,
canvas
,
&
dst
);
SDL_BlitSurface
(
screens
[
14
],
NULL
,
canvas
,
&
dst
);
dst
.
x
=
(
canvasW
-
320
)
>>
1
;
dst
.
x
=
(
canvasW
-
SW
)
>>
1
;
dst
.
y
=
(
canvasH
-
200
)
>>
1
;
dst
.
y
=
(
canvasH
-
SH
)
>>
1
;
SDL_BlitSurface
(
screens
[
0
],
NULL
,
canvas
,
&
dst
);
SDL_BlitSurface
(
screens
[
0
],
NULL
,
canvas
,
&
dst
);
switch
(
option
)
{
switch
(
option
)
{
...
@@ -299,8 +298,8 @@ int Menu::main () {
...
@@ -299,8 +298,8 @@ int Menu::main () {
}
}
dst
.
x
=
((
canvasW
-
320
)
>>
1
)
+
src
.
x
;
dst
.
x
=
((
canvasW
-
SW
)
>>
1
)
+
src
.
x
;
dst
.
y
=
((
canvasH
-
200
)
>>
1
)
+
src
.
y
;
dst
.
y
=
((
canvasH
-
SH
)
>>
1
)
+
src
.
y
;
SDL_BlitSurface
(
screens
[
1
],
&
src
,
canvas
,
&
dst
);
SDL_BlitSurface
(
screens
[
1
],
&
src
,
canvas
,
&
dst
);
}
}
...
...
src/menu/menu.cpp
View file @
30bfea2a
...
@@ -84,8 +84,8 @@ Menu::Menu () {
...
@@ -84,8 +84,8 @@ Menu::Menu () {
// Load the main menu graphics
// Load the main menu graphics
file
->
loadPalette
(
palettes
[
0
]);
file
->
loadPalette
(
palettes
[
0
]);
screens
[
0
]
=
file
->
loadSurface
(
320
,
200
);
screens
[
0
]
=
file
->
loadSurface
(
SW
,
SH
);
screens
[
1
]
=
file
->
loadSurface
(
320
,
200
);
screens
[
1
]
=
file
->
loadSurface
(
SW
,
SH
);
if
(
file
->
getSize
()
>
200000
)
{
if
(
file
->
getSize
()
>
200000
)
{
...
@@ -98,8 +98,8 @@ Menu::Menu () {
...
@@ -98,8 +98,8 @@ Menu::Menu () {
SDL_FreeSurface
(
screens
[
0
]);
SDL_FreeSurface
(
screens
[
0
]);
SDL_FreeSurface
(
screens
[
1
]);
SDL_FreeSurface
(
screens
[
1
]);
file
->
loadPalette
(
palettes
[
0
]);
file
->
loadPalette
(
palettes
[
0
]);
screens
[
0
]
=
file
->
loadSurface
(
320
,
200
);
screens
[
0
]
=
file
->
loadSurface
(
SW
,
SH
);
screens
[
1
]
=
file
->
loadSurface
(
320
,
200
);
screens
[
1
]
=
file
->
loadSurface
(
SW
,
SH
);
}
else
{
}
else
{
...
@@ -117,7 +117,7 @@ Menu::Menu () {
...
@@ -117,7 +117,7 @@ Menu::Menu () {
// Load the difficulty graphics
// Load the difficulty graphics
file
->
loadPalette
(
palettes
[
1
]);
file
->
loadPalette
(
palettes
[
1
]);
screens
[
2
]
=
file
->
loadSurface
(
320
,
200
);
screens
[
2
]
=
file
->
loadSurface
(
SW
,
SH
);
SDL_SetColorKey
(
screens
[
2
],
SDL_SRCCOLORKEY
,
0
);
SDL_SetColorKey
(
screens
[
2
],
SDL_SRCCOLORKEY
,
0
);
// Default difficulty setting
// Default difficulty setting
...
...
src/menu/menu.h
View file @
30bfea2a
...
@@ -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
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
#ifndef _MENU_H
#ifndef _MENU_H
#define _MENU_H
#define _MENU_H
#include "game/gamemode.h"
#include "OpenJazz.h"
#include "OpenJazz.h"
...
@@ -46,9 +48,9 @@ class Menu {
...
@@ -46,9 +48,9 @@ class Menu {
int
message
(
const
char
*
text
);
int
message
(
const
char
*
text
);
int
generic
(
const
char
**
optionNames
,
int
options
,
int
*
chosen
);
int
generic
(
const
char
**
optionNames
,
int
options
,
int
*
chosen
);
int
textInput
(
const
char
*
request
,
char
**
text
);
int
textInput
(
const
char
*
request
,
char
**
text
);
int
newGameDifficulty
(
int
mode
,
int
levelNum
,
int
worldNum
);
int
newGameDifficulty
(
GameModeType
mode
,
int
levelNum
,
int
worldNum
);
int
newGameLevel
(
int
mode
);
int
newGameLevel
(
GameModeType
mode
);
int
newGameEpisode
(
int
mode
);
int
newGameEpisode
(
GameModeType
mode
);
int
joinGame
();
int
joinGame
();
int
loadGame
();
int
loadGame
();
int
setupKeyboard
();
int
setupKeyboard
();
...
@@ -60,7 +62,7 @@ class Menu {
...
@@ -60,7 +62,7 @@ class Menu {
int
setupSound
();
int
setupSound
();
public
:
public
:
SDL_Color
palettes
[
4
][
256
];
SDL_Color
palettes
[
4
][
256
];
Menu
();
Menu
();
~
Menu
();
~
Menu
();
...
...
src/menu/setupmenu.cpp
View file @
30bfea2a
...
@@ -267,10 +267,10 @@ int Menu::setupResolution () {
...
@@ -267,10 +267,10 @@ int Menu::setupResolution () {
#ifndef FULLSCREEN_ONLY
#ifndef FULLSCREEN_ONLY
if
(
!
fullscreen
)
if
(
!
fullscreen
)
resolutions
=
SDL_ListModes
(
NULL
,
V_WINDOWED
);
resolutions
=
SDL_ListModes
(
NULL
,
WINDOWED_FLAGS
);
else
else
#endif
#endif
resolutions
=
SDL_ListModes
(
NULL
,
V_FULLSCREEN
);
resolutions
=
SDL_ListModes
(
NULL
,
FULLSCREEN_FLAGS
);
#if defined(WIZ) || defined(GP2X)
#if defined(WIZ) || defined(GP2X)
...
@@ -283,8 +283,9 @@ int Menu::setupResolution () {
...
@@ -283,8 +283,9 @@ int Menu::setupResolution () {
maxH
=
1200
;
maxH
=
1200
;
}
else
{
}
else
{
maxW
=
320
;
maxH
=
200
;
maxW
=
SW
;
maxH
=
SH
;
for
(
count
=
0
;
resolutions
[
count
]
!=
NULL
;
count
++
)
{
for
(
count
=
0
;
resolutions
[
count
]
!=
NULL
;
count
++
)
{
...
@@ -360,7 +361,7 @@ int Menu::setupResolution () {
...
@@ -360,7 +361,7 @@ int Menu::setupResolution () {
if
(
controls
.
release
(
C_DOWN
))
{
if
(
controls
.
release
(
C_DOWN
))
{
if
((
!
dimension
)
&&
(
screenW
>
320
))
{
if
((
!
dimension
)
&&
(
screenW
>
SW
))
{
count
=
13
;
count
=
13
;
...
@@ -371,7 +372,7 @@ int Menu::setupResolution () {
...
@@ -371,7 +372,7 @@ int Menu::setupResolution () {
}
}
if
(
dimension
&&
(
screenH
>
200
))
{
if
(
dimension
&&
(
screenH
>
SH
))
{
count
=
16
;
count
=
16
;
...
...
src/player/player.cpp
View file @
30bfea2a
...
@@ -870,9 +870,9 @@ void Player::receive (unsigned char *buffer) {
...
@@ -870,9 +870,9 @@ void Player::receive (unsigned char *buffer) {
}
}
int
Player
::
reacted
(
unsigned
int
ticks
)
{
PlayerReaction
Player
::
reacted
(
unsigned
int
ticks
)
{
int
oldReaction
;
PlayerReaction
oldReaction
;
if
((
reaction
!=
PR_NONE
)
&&
(
reactionTime
<
ticks
))
{
if
((
reaction
!=
PR_NONE
)
&&
(
reactionTime
<
ticks
))
{
...
...
src/player/player.h
View file @
30bfea2a
...
@@ -77,16 +77,6 @@
...
@@ -77,16 +77,6 @@
#define PA_RSPRING 36
#define PA_RSPRING 36
#define PA_LSPRING 37
/* Surely these are the wrong way round? */
#define PA_LSPRING 37
/* Surely these are the wrong way round? */
// Player facing
#define PF_LEFT 0
#define PF_RIGHT 1
// Player reactions
#define PR_NONE 0
#define PR_HURT 1
#define PR_KILLED 2
#define PR_INVINCIBLE 3
// Player reaction times
// Player reaction times
#define PRT_HURT 1000
#define PRT_HURT 1000
#define PRT_HURTANIM 200
#define PRT_HURTANIM 200
...
@@ -159,6 +149,15 @@
...
@@ -159,6 +149,15 @@
#define PCONTROLS 8
/* Number of player controls. */
#define PCONTROLS 8
/* Number of player controls. */
// Enum
enum
PlayerReaction
{
PR_NONE
,
PR_HURT
,
PR_KILLED
,
PR_INVINCIBLE
};
// Classes
// Classes
class
Anim
;
class
Anim
;
...
@@ -167,37 +166,37 @@ class Bird;
...
@@ -167,37 +166,37 @@ class Bird;
class
Player
:
public
Movable
{
class
Player
:
public
Movable
{
private
:
private
:
Bird
*
bird
;
Bird
*
bird
;
char
*
name
;
char
*
name
;
char
anims
[
PANIMS
];
char
anims
[
PANIMS
];
bool
pcontrols
[
PCONTROLS
];
bool
pcontrols
[
PCONTROLS
];
SDL_Color
palette
[
256
];
SDL_Color
palette
[
256
];
unsigned
char
cols
[
4
];
unsigned
char
cols
[
4
];
int
ammo
[
4
];
int
ammo
[
4
];
int
ammoType
;
/* -1 = blaster, 0 = toaster, 1 = missiles, 2 = bouncer 3 = TNT */
int
ammoType
;
/* -1 = blaster, 0 = toaster, 1 = missiles, 2 = bouncer 3 = TNT */
int
score
;
int
score
;
int
energy
;
int
energy
;
int
lives
;
int
lives
;
int
shield
;
/* 0 = none, 1 = 1 yellow, 2 = 2 yellow, 3 = 1 orange, 4 = 2 orange, 5 = 3 orange, 6 = 4 orange */
int
shield
;
/* 0 = none, 1 = 1 yellow, 2 = 2 yellow, 3 = 1 orange, 4 = 2 orange, 5 = 3 orange, 6 = 4 orange */
bool
floating
;
/* false = normal, true = boarding/bird/etc. */
bool
floating
;
/* false = normal, true = boarding/bird/etc. */
bool
facing
;
bool
facing
;
fixed
direction
;
fixed
direction
;
unsigned
char
animType
;
unsigned
char
animType
;
unsigned
char
eventX
;
unsigned
char
eventX
;
unsigned
char
eventY
;
/* Position of an event (spring, platform, bridge) */
unsigned
char
eventY
;
/* Position of an event (spring, platform, bridge) */
int
event
;
/* 0 = none, 1 = spring, 2 = float up, 3 = platform, 4 = bridge */
int
event
;
/* 0 = none, 1 = spring, 2 = float up, 3 = platform, 4 = bridge */
int
lookTime
;
/* Negative if looking up, positive if looking down, 0 if neither */
int
lookTime
;
/* Negative if looking up, positive if looking down, 0 if neither */
int
reaction
;
PlayerReaction
reaction
;
unsigned
int
reactionTime
;
unsigned
int
reactionTime
;
int
fireSpeed
;
int
fireSpeed
;
unsigned
int
fireTime
;
unsigned
int
fireTime
;
fixed
jumpHeight
;
fixed
jumpHeight
;
fixed
jumpY
;
fixed
jumpY
;
unsigned
int
fastFeetTime
;
unsigned
int
fastFeetTime
;
unsigned
char
warpX
,
warpY
;
unsigned
char
warpX
,
warpY
;
unsigned
int
warpTime
;
unsigned
int
warpTime
;
int
enemies
,
items
;
int
enemies
,
items
;
unsigned
char
team
;
unsigned
char
team
;
void
addAmmo
(
int
type
,
int
amount
);
void
addAmmo
(
int
type
,
int
amount
);
...
@@ -241,7 +240,7 @@ class Player : public Movable {
...
@@ -241,7 +240,7 @@ class Player : public Movable {
void
bonusStep
(
unsigned
int
ticks
,
int
msps
);
void
bonusStep
(
unsigned
int
ticks
,
int
msps
);
void
view
(
unsigned
int
ticks
,
int
mspf
);
void
view
(
unsigned
int
ticks
,
int
mspf
);
void
draw
(
unsigned
int
ticks
,
int
change
);
void
draw
(
unsigned
int
ticks
,
int
change
);
int
reacted
(
unsigned
int
ticks
);
PlayerReaction
reacted
(
unsigned
int
ticks
);
};
};
...
...
src/scene/scene.cpp
View file @
30bfea2a
...
@@ -195,7 +195,7 @@ int Scene::play () {
...
@@ -195,7 +195,7 @@ int Scene::play () {
unsigned
int
lastTicks
=
globalTicks
;
unsigned
int
lastTicks
=
globalTicks
;
int
newpage
=
true
;
int
newpage
=
true
;
int
fadein
=
false
;
int
fadein
=
false
;
SDL_Rect
textRect
=
{
0
,
0
,
320
,
200
};
SDL_Rect
textRect
=
{
0
,
0
,
SW
,
SH
};
while
(
true
)
{
while
(
true
)
{
...
@@ -230,8 +230,8 @@ int Scene::play () {
...
@@ -230,8 +230,8 @@ int Scene::play () {
textRect
.
x
=
0
;
textRect
.
x
=
0
;
textRect
.
y
=
0
;
textRect
.
y
=
0
;
textRect
.
w
=
320
;
textRect
.
w
=
SW
;
textRect
.
h
=
200
;
textRect
.
h
=
SH
;
ScenePalette
*
palette
=
palettes
;
ScenePalette
*
palette
=
palettes
;
while
(
palette
&&
(
palette
->
id
!=
pages
[
sceneIndex
].
paletteIndex
))
palette
=
palette
->
next
;
while
(
palette
&&
(
palette
->
id
!=
pages
[
sceneIndex
].
paletteIndex
))
palette
=
palette
->
next
;
...
@@ -260,8 +260,8 @@ int Scene::play () {
...
@@ -260,8 +260,8 @@ int Scene::play () {
if
(
image
)
{
if
(
image
)
{
dst
.
x
=
(
pages
[
sceneIndex
].
bgPos
[
bg
]
&
65535
)
*
2
+
(
canvasW
-
320
)
>>
1
;
dst
.
x
=
(
pages
[
sceneIndex
].
bgPos
[
bg
]
&
65535
)
*
2
+
(
canvasW
-
SW
)
>>
1
;
dst
.
y
=
((
pages
[
sceneIndex
].
bgPos
[
bg
]
&
(
~
65535
))
>>
16
)
*
2
+
(
canvasH
-
200
)
>>
1
;
dst
.
y
=
((
pages
[
sceneIndex
].
bgPos
[
bg
]
&
(
~
65535
))
>>
16
)
*
2
+
(
canvasH
-
SH
)
>>
1
;
SDL_BlitSurface
(
image
->
image
,
NULL
,
canvas
,
&
dst
);
SDL_BlitSurface
(
image
->
image
,
NULL
,
canvas
,
&
dst
);
}
}
...
@@ -315,8 +315,8 @@ int Scene::play () {
...
@@ -315,8 +315,8 @@ int Scene::play () {
}
}
xOffset
=
((
canvasW
-
320
)
>>
1
)
+
textRect
.
x
+
x
;
xOffset
=
((
canvasW
-
SW
)
>>
1
)
+
textRect
.
x
+
x
;
yOffset
=
((
canvasH
-
200
)
>>
1
)
+
textRect
.
y
+
y
;
yOffset
=
((
canvasH
-
SH
)
>>
1
)
+
textRect
.
y
+
y
;
switch
(
text
->
alignment
)
{
switch
(
text
->
alignment
)
{
...
...
src/scene/sceneload.cpp
View file @
30bfea2a
...
@@ -116,7 +116,7 @@ void Scene::loadAni (File *f, int dataIndex) {
...
@@ -116,7 +116,7 @@ void Scene::loadAni (File *f, int dataIndex) {
// Skip back size header, this is read by the surface reader
// Skip back size header, this is read by the surface reader
f
->
seek
(
-
2
,
false
);
f
->
seek
(
-
2
,
false
);
SDL_Surface
*
image
=
f
->
loadSurface
(
320
,
200
);
SDL_Surface
*
image
=
f
->
loadSurface
(
SW
,
SH
);
SDL_BlitSurface
(
image
,
NULL
,
canvas
,
NULL
);
SDL_BlitSurface
(
image
,
NULL
,
canvas
,
NULL
);
SDL_FreeSurface
(
image
);
SDL_FreeSurface
(
image
);
...
...
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