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
4da24843
Commit
4da24843
authored
Oct 03, 2010
by
alistert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Doxygenated comments.
parent
1738194a
Changes
83
Show whitespace changes
Inline
Side-by-side
Showing
83 changed files
with
1474 additions
and
947 deletions
+1474
-947
OpenJazz.h
src/OpenJazz.h
+8
-7
baselevel.cpp
src/baselevel.cpp
+50
-8
baselevel.h
src/baselevel.h
+26
-18
bonus.cpp
src/bonus/bonus.cpp
+12
-10
bonus.h
src/bonus/bonus.h
+18
-15
clientgame.cpp
src/game/clientgame.cpp
+49
-14
game.cpp
src/game/game.cpp
+82
-7
game.h
src/game/game.h
+34
-28
gamemode.cpp
src/game/gamemode.cpp
+116
-5
gamemode.h
src/game/gamemode.h
+21
-10
servergame.cpp
src/game/servergame.cpp
+46
-5
controls.cpp
src/io/controls.cpp
+7
-8
controls.h
src/io/controls.h
+13
-12
file.cpp
src/io/file.cpp
+16
-8
file.h
src/io/file.h
+12
-9
anim.cpp
src/io/gfx/anim.cpp
+6
-5
anim.h
src/io/gfx/anim.h
+13
-11
font.cpp
src/io/gfx/font.cpp
+16
-11
font.h
src/io/gfx/font.h
+19
-17
paletteeffects.cpp
src/io/gfx/paletteeffects.cpp
+7
-6
paletteeffects.h
src/io/gfx/paletteeffects.h
+38
-36
sprite.cpp
src/io/gfx/sprite.cpp
+6
-5
sprite.h
src/io/gfx/sprite.h
+9
-7
video.cpp
src/io/gfx/video.cpp
+9
-10
video.h
src/io/gfx/video.h
+21
-17
network.cpp
src/io/network.cpp
+14
-7
network.h
src/io/network.h
+9
-7
sound.cpp
src/io/sound.cpp
+10
-10
sound.h
src/io/sound.h
+8
-6
jj2event.cpp
src/jj2level/jj2event/jj2event.cpp
+6
-7
jj2event.h
src/jj2level/jj2event/jj2event.h
+13
-6
jj2eventframe.cpp
src/jj2level/jj2event/jj2eventframe.cpp
+10
-11
jj2layer.cpp
src/jj2level/jj2layer.cpp
+12
-11
jj2level.cpp
src/jj2level/jj2level.cpp
+12
-10
jj2level.h
src/jj2level/jj2level.h
+44
-35
jj2levelframe.cpp
src/jj2level/jj2levelframe.cpp
+7
-8
jj2levelload.cpp
src/jj2level/jj2levelload.cpp
+7
-8
bullet.cpp
src/level/bullet.cpp
+6
-5
bullet.h
src/level/bullet.h
+13
-11
demolevel.cpp
src/level/demolevel.cpp
+7
-8
bridge.cpp
src/level/event/bridge.cpp
+7
-8
event.cpp
src/level/event/event.cpp
+16
-11
event.h
src/level/event/event.h
+14
-11
eventframe.cpp
src/level/event/eventframe.cpp
+31
-32
guardians.cpp
src/level/event/guardians.cpp
+7
-8
guardians.h
src/level/event/guardians.h
+9
-8
level.cpp
src/level/level.cpp
+12
-10
level.h
src/level/level.h
+55
-48
levelframe.cpp
src/level/levelframe.cpp
+7
-8
levelload.cpp
src/level/levelload.cpp
+7
-8
movable.cpp
src/level/movable.cpp
+7
-8
movable.h
src/level/movable.h
+8
-6
loop.h
src/loop.h
+6
-4
main.cpp
src/main.cpp
+42
-12
gamemenu.cpp
src/menu/gamemenu.cpp
+8
-9
mainmenu.cpp
src/menu/mainmenu.cpp
+7
-8
menu.cpp
src/menu/menu.cpp
+16
-14
menu.h
src/menu/menu.h
+23
-21
plasma.cpp
src/menu/plasma.cpp
+21
-17
plasma.h
src/menu/plasma.h
+7
-5
setupmenu.cpp
src/menu/setupmenu.cpp
+7
-8
planet.cpp
src/planet/planet.cpp
+7
-8
planet.h
src/planet/planet.h
+12
-10
symbian.cpp
src/platforms/symbian.cpp
+20
-1
wiz.cpp
src/platforms/wiz.cpp
+18
-0
wiz.h
src/platforms/wiz.h
+18
-0
bird.cpp
src/player/bird.cpp
+6
-5
bird.h
src/player/bird.h
+11
-9
bonusplayer.cpp
src/player/bonusplayer.cpp
+8
-9
bonusplayer.h
src/player/bonusplayer.h
+15
-10
jj2levelplayer.cpp
src/player/jj2levelplayer.cpp
+12
-11
jj2levelplayer.h
src/player/jj2levelplayer.h
+29
-24
jj2levelplayerframe.cpp
src/player/jj2levelplayerframe.cpp
+19
-18
levelplayer.cpp
src/player/levelplayer.cpp
+7
-8
levelplayer.h
src/player/levelplayer.h
+33
-28
levelplayerframe.cpp
src/player/levelplayerframe.cpp
+14
-12
player.cpp
src/player/player.cpp
+13
-12
player.h
src/player/player.h
+24
-20
scene.cpp
src/scene/scene.cpp
+8
-9
scene.h
src/scene/scene.h
+28
-26
sceneload.cpp
src/scene/sceneload.cpp
+8
-9
util.cpp
src/util.cpp
+9
-10
util.h
src/util.h
+6
-5
No files found.
src/OpenJazz.h
View file @
4da24843
/*
/*
*
*
*
* OpenJazz.h
*
@file
OpenJazz.h
*
*
* Part of the OpenJazz project
*
* @section History
* 23rd August 2005: Created OpenJazz.h
* 23rd August 2005: Created OpenJazz.h
* 31st January 2006: Created level.h from parts of OpenJazz.h
* 31st January 2006: Created level.h from parts of OpenJazz.h
* 31st January 2006: Created player.h from parts of OpenJazz.h
* 31st January 2006: Created player.h from parts of OpenJazz.h
...
@@ -18,9 +21,7 @@
...
@@ -18,9 +21,7 @@
* 30th April 2010: Created util.h from parts of OpenJazz.h
* 30th April 2010: Created util.h from parts of OpenJazz.h
* 30th April 2010: Created loop.h from parts of OpenJazz.h
* 30th April 2010: Created loop.h from parts of OpenJazz.h
*
*
* Part of the OpenJazz project
* @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
...
src/baselevel.cpp
View file @
4da24843
/*
/*
*
*
*
* baselevel.cpp
* @file baselevel.cpp
*
* 30th March 2010: Created baselevel.cpp from parts of level.cpp and
* levelframe.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 30th March 2010: Created baselevel.cpp from parts of level.cpp and
* levelframe.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -18,9 +19,7 @@
...
@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with functionality common to ordinary levels and bonus levels.
* Deals with functionality common to ordinary levels and bonus levels.
*
*
*/
*/
...
@@ -40,6 +39,9 @@
...
@@ -40,6 +39,9 @@
#include "loop.h"
#include "loop.h"
/**
* Create a new base level
*/
BaseLevel
::
BaseLevel
()
{
BaseLevel
::
BaseLevel
()
{
// Arbitrary initial value
// Arbitrary initial value
...
@@ -59,6 +61,9 @@ BaseLevel::BaseLevel () {
...
@@ -59,6 +61,9 @@ BaseLevel::BaseLevel () {
}
}
/**
* Destroy base level
*/
BaseLevel
::~
BaseLevel
()
{
BaseLevel
::~
BaseLevel
()
{
stopMusic
();
stopMusic
();
...
@@ -70,6 +75,13 @@ BaseLevel::~BaseLevel () {
...
@@ -70,6 +75,13 @@ BaseLevel::~BaseLevel () {
}
}
/**
* Play a cutscene.
*
* @param file File name of the cutscene to be played
*
* @return Error code
*/
int
BaseLevel
::
playScene
(
char
*
file
)
{
int
BaseLevel
::
playScene
(
char
*
file
)
{
Scene
*
scene
;
Scene
*
scene
;
...
@@ -97,6 +109,9 @@ int BaseLevel::playScene (char* file) {
...
@@ -97,6 +109,9 @@ int BaseLevel::playScene (char* file) {
}
}
/**
* Perform timing calculations.
*/
void
BaseLevel
::
timeCalcs
()
{
void
BaseLevel
::
timeCalcs
()
{
// Calculate smoothed fps
// Calculate smoothed fps
...
@@ -142,6 +157,11 @@ void BaseLevel::timeCalcs () {
...
@@ -142,6 +157,11 @@ void BaseLevel::timeCalcs () {
}
}
/**
* Display on-screen statistics.
*
* @param bg Palette index of the statistics box(es)
*/
void
BaseLevel
::
drawStats
(
unsigned
char
bg
)
{
void
BaseLevel
::
drawStats
(
unsigned
char
bg
)
{
int
count
,
width
;
int
count
,
width
;
...
@@ -205,6 +225,15 @@ void BaseLevel::drawStats (unsigned char bg) {
...
@@ -205,6 +225,15 @@ void BaseLevel::drawStats (unsigned char bg) {
}
}
/**
* Process iteration.
*
* @param menu Whether or not the level menu should be displayed
* @param option Selected menu uption
* @param message Whether or not the "paused" message is being displayed
*
* @return Error code
*/
int
BaseLevel
::
loop
(
bool
&
menu
,
int
&
option
,
bool
&
message
)
{
int
BaseLevel
::
loop
(
bool
&
menu
,
int
&
option
,
bool
&
message
)
{
int
ret
;
int
ret
;
...
@@ -311,6 +340,9 @@ int BaseLevel::loop (bool& menu, int& option, bool& message) {
...
@@ -311,6 +340,9 @@ int BaseLevel::loop (bool& menu, int& option, bool& message) {
}
}
/**
* Add extra time.
*/
void
BaseLevel
::
addTimer
()
{
void
BaseLevel
::
addTimer
()
{
unsigned
char
buffer
[
MTL_L_PROP
];
unsigned
char
buffer
[
MTL_L_PROP
];
...
@@ -336,6 +368,11 @@ void BaseLevel::addTimer () {
...
@@ -336,6 +368,11 @@ void BaseLevel::addTimer () {
}
}
/**
* Set the level stage.
*
* @param newStage New level stage
*/
void
BaseLevel
::
setStage
(
LevelStage
newStage
)
{
void
BaseLevel
::
setStage
(
LevelStage
newStage
)
{
unsigned
char
buffer
[
MTL_L_STAGE
];
unsigned
char
buffer
[
MTL_L_STAGE
];
...
@@ -358,6 +395,11 @@ void BaseLevel::setStage (LevelStage newStage) {
...
@@ -358,6 +395,11 @@ void BaseLevel::setStage (LevelStage newStage) {
}
}
/**
* Determine the current level stage.
*
* @return The current level stage.
*/
LevelStage
BaseLevel
::
getStage
()
{
LevelStage
BaseLevel
::
getStage
()
{
return
stage
;
return
stage
;
...
...
src/baselevel.h
View file @
4da24843
/*
/*
*
*
*
* baselevel.h
* @file baselevel.h
*
* 30th March 2010: Created baselevel.h from parts of level.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 30th March 2010: Created baselevel.h from parts of level.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -39,18 +40,21 @@
...
@@ -39,18 +40,21 @@
// Enums
// Enums
/// Level type
enum
LevelType
{
enum
LevelType
{
LT_LEVEL
,
LT_BONUS
,
LT_JJ2LEVEL
LT_LEVEL
,
LT_BONUS
,
LT_JJ2LEVEL
};
};
/// Which stats to display on-screen
enum
LevelStats
{
enum
LevelStats
{
S_PLAYERS
=
1
,
S_SCREEN
=
2
S_PLAYERS
=
1
,
S_SCREEN
=
2
};
};
/// Level stage
enum
LevelStage
{
enum
LevelStage
{
LS_NORMAL
=
0
,
LS_SUDDENDEATH
=
1
,
LS_END
=
2
LS_NORMAL
=
0
,
LS_SUDDENDEATH
=
1
,
LS_END
=
2
...
@@ -63,23 +67,27 @@ enum LevelStage {
...
@@ -63,23 +67,27 @@ enum LevelStage {
class
File
;
class
File
;
class
Sprite
;
class
Sprite
;
/// Base class for all level classes
class
BaseLevel
{
class
BaseLevel
{
private
:
private
:
SetupMenu
setupMenu
;
SetupMenu
setupMenu
;
///< Setup menu to run on the player's command
protected
:
protected
:
PaletteEffect
*
paletteEffects
;
PaletteEffect
*
paletteEffects
;
///< Palette effects in use while playing the level
SDL_Color
palette
[
256
];
SDL_Color
palette
[
256
];
///< Palette in use while playing the level
int
sprites
;
int
sprites
;
///< The number of sprite that have been loaded
unsigned
int
tickOffset
,
prevStepTicks
,
prevTicks
,
ticks
;
unsigned
int
tickOffset
;
///< Level time offset from system time
unsigned
int
endTime
;
unsigned
int
prevStepTicks
;
///< Time the last step started
float
smoothfps
;
unsigned
int
prevTicks
;
///< Time the last visual update started
int
items
;
unsigned
int
ticks
;
///< Current time
bool
multiplayer
;
unsigned
int
endTime
;
///< Tick at which the level will end
bool
paused
;
float
smoothfps
;
///< Smoothed FPS counter
LevelStage
stage
;
int
items
;
///< Number of items to be collected
int
stats
;
bool
multiplayer
;
///< Whether or not this is a multiplayer game
bool
paused
;
///< Whether or not the level is paused
LevelStage
stage
;
///< Level stage
int
stats
;
///< Which statistics to display on-screen, see #LevelStats
int
playScene
(
char
*
file
);
int
playScene
(
char
*
file
);
void
timeCalcs
();
void
timeCalcs
();
...
@@ -100,8 +108,8 @@ class BaseLevel {
...
@@ -100,8 +108,8 @@ class BaseLevel {
// Variables
// Variables
EXTERN
BaseLevel
*
baseLevel
;
EXTERN
BaseLevel
*
baseLevel
;
///< Current level
EXTERN
fixed
viewX
,
viewY
;
EXTERN
fixed
viewX
,
viewY
;
///< Level viewing co-ordinates
#endif
#endif
src/bonus/bonus.cpp
View file @
4da24843
/*
/*
*
*
*
* bonus.cpp
* @file bonus.cpp
*
* 23rd August 2005: Created bonus.c
* 3rd February 2009: Renamed bonus.c to bonus.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 23rd August 2005: Created bonus.c
* 3rd February 2009: Renamed bonus.c to bonus.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -18,9 +19,7 @@
...
@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the loading, running and freeing of bonus levels.
* Deals with the loading, running and freeing of bonus levels.
*
*
*/
*/
...
@@ -416,10 +415,13 @@ bool Bonus::checkMask (fixed x, fixed y) {
...
@@ -416,10 +415,13 @@ bool Bonus::checkMask (fixed x, fixed y) {
}
}
/**
* Interpret data received from client/server
*
* @param buffer Received data
*/
void
Bonus
::
receive
(
unsigned
char
*
buffer
)
{
void
Bonus
::
receive
(
unsigned
char
*
buffer
)
{
// Interpret data received from client/server
switch
(
buffer
[
1
])
{
switch
(
buffer
[
1
])
{
case
MT_L_PROP
:
case
MT_L_PROP
:
...
...
src/bonus/bonus.h
View file @
4da24843
/*
/*
*
*
*
* bonus.h
* @file bonus.h
*
* 3rd February 2009: Created bonus.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 3rd February 2009: Created bonus.h
*
*
* @section Licence
* Copyright (c) 2009-2010 Alister Thomson
* Copyright (c) 2009-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -42,10 +43,11 @@
...
@@ -42,10 +43,11 @@
// Datatype
// Datatype
/// JJ1 bonus level grid element
typedef
struct
{
typedef
struct
{
unsigned
char
tile
;
// Indexes the tile set
unsigned
char
tile
;
//
/<
Indexes the tile set
unsigned
char
event
;
unsigned
char
event
;
///< Event type
}
BonusGridElement
;
}
BonusGridElement
;
...
@@ -54,17 +56,18 @@ typedef struct {
...
@@ -54,17 +56,18 @@ typedef struct {
class
Font
;
class
Font
;
/// JJ1 bonus level
class
Bonus
:
public
BaseLevel
{
class
Bonus
:
public
BaseLevel
{
private
:
private
:
SDL_Surface
*
tileSet
;
SDL_Surface
*
tileSet
;
///< Tile images
SDL_Surface
*
background
;
SDL_Surface
*
background
;
///< Background image
Font
*
font
;
Font
*
font
;
///< On-screen message font
Sprite
*
spriteSet
;
Sprite
*
spriteSet
;
///< Sprite images
Anim
animSet
[
BANIMS
];
Anim
animSet
[
BANIMS
];
///< Animations
BonusGridElement
grid
[
BLH
][
BLW
];
BonusGridElement
grid
[
BLH
][
BLW
];
///< Level grid
char
mask
[
60
][
64
];
//
At most 60 tiles, all with 8 * 8 masks
char
mask
[
60
][
64
];
//
/< Tile masks (at most 60 tiles, all with 8 * 8 masks)
fixed
direction
;
fixed
direction
;
///< Player's direction
int
loadSprites
();
int
loadSprites
();
int
loadTiles
(
char
*
fileName
);
int
loadTiles
(
char
*
fileName
);
...
...
src/game/clientgame.cpp
View file @
4da24843
/*
/*
*
*
*
* clientgame.cpp
* @file clientgame.cpp
*
* 18th July 2009: Created clientgame.cpp from parts of game.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 18th July 2009: Created clientgame.cpp from parts of game.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -38,6 +39,11 @@
...
@@ -38,6 +39,11 @@
#include <string.h>
#include <string.h>
/**
* Create game client
*
* @param address Address of the server to which to connect
*/
ClientGame
::
ClientGame
(
char
*
address
)
{
ClientGame
::
ClientGame
(
char
*
address
)
{
unsigned
char
buffer
[
BUFFER_LENGTH
];
unsigned
char
buffer
[
BUFFER_LENGTH
];
...
@@ -229,6 +235,9 @@ ClientGame::ClientGame (char* address) {
...
@@ -229,6 +235,9 @@ ClientGame::ClientGame (char* address) {
}
}
/**
* Disconnect and destroy client
*/
ClientGame
::~
ClientGame
()
{
ClientGame
::~
ClientGame
()
{
net
->
close
(
sock
);
net
->
close
(
sock
);
...
@@ -242,6 +251,13 @@ ClientGame::~ClientGame () {
...
@@ -242,6 +251,13 @@ ClientGame::~ClientGame () {
}
}
/**
* Set the next level and receive level data from server
*
* @param fileName The file name of the next level
*
* @return Error code
*/
int
ClientGame
::
setLevel
(
char
*
fileName
)
{
int
ClientGame
::
setLevel
(
char
*
fileName
)
{
int
ret
;
int
ret
;
...
@@ -291,6 +307,11 @@ int ClientGame::setLevel (char* fileName) {
...
@@ -291,6 +307,11 @@ int ClientGame::setLevel (char* fileName) {
}
}
/**
* Send data to server
*
* @param buffer Data to send. First byte indicates length.
*/
void
ClientGame
::
send
(
unsigned
char
*
buffer
)
{
void
ClientGame
::
send
(
unsigned
char
*
buffer
)
{
net
->
send
(
sock
,
buffer
);
net
->
send
(
sock
,
buffer
);
...
@@ -300,6 +321,13 @@ void ClientGame::send (unsigned char* buffer) {
...
@@ -300,6 +321,13 @@ void ClientGame::send (unsigned char* buffer) {
}
}
/**
* Game iteration
*
* @param ticks Current time
*
* @return Error code
*/
int
ClientGame
::
step
(
unsigned
int
ticks
)
{
int
ClientGame
::
step
(
unsigned
int
ticks
)
{
unsigned
char
sendBuffer
[
BUFFER_LENGTH
];
unsigned
char
sendBuffer
[
BUFFER_LENGTH
];
...
@@ -505,6 +533,11 @@ int ClientGame::step (unsigned int ticks) {
...
@@ -505,6 +533,11 @@ int ClientGame::step (unsigned int ticks) {
}
}
/**
* Ask server to award team a point
*
* @param team Team to receive point
*/
void
ClientGame
::
score
(
unsigned
char
team
)
{
void
ClientGame
::
score
(
unsigned
char
team
)
{
unsigned
char
buffer
[
MTL_G_SCORE
];
unsigned
char
buffer
[
MTL_G_SCORE
];
...
@@ -520,20 +553,22 @@ void ClientGame::score (unsigned char team) {
...
@@ -520,20 +553,22 @@ void ClientGame::score (unsigned char team) {
}
}
/**
* Ask server to approve new checkpoint
*
* @param gridX X-coordinate (in tiles) of the checkpoint
* @param gridY Y-coordinate (in tiles) of the checkpoint
*/
void
ClientGame
::
setCheckpoint
(
unsigned
char
gridX
,
unsigned
char
gridY
)
{
void
ClientGame
::
setCheckpoint
(
unsigned
char
gridX
,
unsigned
char
gridY
)
{
unsigned
char
buffer
[
MTL_G_CHECK
];
unsigned
char
buffer
[
MTL_G_CHECK
];
if
(
mode
)
{
buffer
[
0
]
=
MTL_G_CHECK
;
buffer
[
0
]
=
MTL_G_CHECK
;
buffer
[
1
]
=
MT_G_CHECK
;
buffer
[
1
]
=
MT_G_CHECK
;
buffer
[
2
]
=
gridX
;
buffer
[
2
]
=
gridX
;
buffer
[
3
]
=
gridY
;
buffer
[
3
]
=
gridY
;
send
(
buffer
);
send
(
buffer
);
}
return
;
return
;
}
}
...
...
src/game/game.cpp
View file @
4da24843
/*
/*
*
*
*
* game.cpp
*
@file
game.cpp
*
*
* Part of the OpenJazz project
*
* @section History
* 9th March 2009: Created game.cpp from parts of menu.cpp and level.cpp
* 9th March 2009: Created game.cpp from parts of menu.cpp and level.cpp
* 3rd June 2009: Created network.cpp from parts of game.cpp
* 3rd June 2009: Created network.cpp from parts of game.cpp
* 18th July 2009: Created servergame.cpp from parts of game.cpp
* 18th July 2009: Created servergame.cpp from parts of game.cpp
* 18th July 2009: Created clientgame.cpp from parts of game.cpp
* 18th July 2009: Created clientgame.cpp from parts of game.cpp
*
*
* Part of the OpenJazz project
* @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -41,6 +42,9 @@
...
@@ -41,6 +42,9 @@
#include <string.h>
#include <string.h>
/**
* Create base game
*/
Game
::
Game
()
{
Game
::
Game
()
{
levelFile
=
NULL
;
levelFile
=
NULL
;
...
@@ -52,6 +56,12 @@ Game::Game () {
...
@@ -52,6 +56,12 @@ Game::Game () {
}
}
/**
* Create a new game
*
* @param firstLevel File name of the first level to play
* @param gameDifficulty Difficulty setting
*/
Game
::
Game
(
char
*
firstLevel
,
int
gameDifficulty
)
{
Game
::
Game
(
char
*
firstLevel
,
int
gameDifficulty
)
{
levelFile
=
createString
(
firstLevel
);
levelFile
=
createString
(
firstLevel
);
...
@@ -70,6 +80,9 @@ Game::Game (char *firstLevel, int gameDifficulty) {
...
@@ -70,6 +80,9 @@ Game::Game (char *firstLevel, int gameDifficulty) {
}
}
/**
* Destroy game
*/
Game
::~
Game
()
{
Game
::~
Game
()
{
if
(
levelFile
)
delete
[]
levelFile
;
if
(
levelFile
)
delete
[]
levelFile
;
...
@@ -82,6 +95,13 @@ Game::~Game () {
...
@@ -82,6 +95,13 @@ Game::~Game () {
}
}
/**
* Create a new game mode
*
* @param modeType The mode to create
*
* @return The new game mode (NULL on failure)
*/
GameMode
*
Game
::
createMode
(
GameModeType
modeType
)
{
GameMode
*
Game
::
createMode
(
GameModeType
modeType
)
{
switch
(
modeType
)
{
switch
(
modeType
)
{
...
@@ -113,6 +133,11 @@ GameMode* Game::createMode (GameModeType modeType) {
...
@@ -113,6 +133,11 @@ GameMode* Game::createMode (GameModeType modeType) {
}
}
/**
* Get the game's mode
*
* @return The game's mode
*/
GameMode
*
Game
::
getMode
()
{
GameMode
*
Game
::
getMode
()
{
return
mode
;
return
mode
;
...
@@ -120,6 +145,13 @@ GameMode* Game::getMode () {
...
@@ -120,6 +145,13 @@ GameMode* Game::getMode () {
}
}
/**
* Set the next level
*
* @param fileName The file name of the next level
*
* @return Error code
*/
int
Game
::
setLevel
(
char
*
fileName
)
{
int
Game
::
setLevel
(
char
*
fileName
)
{
if
(
levelFile
)
delete
[]
levelFile
;
if
(
levelFile
)
delete
[]
levelFile
;
...
@@ -132,6 +164,11 @@ int Game::setLevel (char *fileName) {
...
@@ -132,6 +164,11 @@ int Game::setLevel (char *fileName) {
}
}
/**
* Play the game
*
* @return Error code
*/
int
Game
::
play
()
{
int
Game
::
play
()
{
Planet
*
planet
;
Planet
*
planet
;
...
@@ -326,10 +363,13 @@ int Game::play () {
...
@@ -326,10 +363,13 @@ int Game::play () {
}
}
/**
* Move the viewport towards the exit sign
*
* @param change Distance to move
*/
void
Game
::
view
(
int
change
)
{
void
Game
::
view
(
int
change
)
{
// Move the viewport towards the exit sign
if
(
TTOF
(
checkX
)
>
viewX
+
(
canvasW
<<
9
)
+
change
)
viewX
+=
change
;
if
(
TTOF
(
checkX
)
>
viewX
+
(
canvasW
<<
9
)
+
change
)
viewX
+=
change
;
else
if
(
TTOF
(
checkX
)
<
viewX
+
(
canvasW
<<
9
)
-
change
)
viewX
-=
change
;
else
if
(
TTOF
(
checkX
)
<
viewX
+
(
canvasW
<<
9
)
-
change
)
viewX
-=
change
;
...
@@ -341,6 +381,11 @@ void Game::view (int change) {
...
@@ -341,6 +381,11 @@ void Game::view (int change) {
}
}
/**
* No data is sent in single-player mode
*
* @param buffer Data that will not be sent. First byte indicates length.
*/
void
Game
::
send
(
unsigned
char
*
buffer
)
{
void
Game
::
send
(
unsigned
char
*
buffer
)
{
// Do nothing
// Do nothing
...
@@ -350,6 +395,13 @@ void Game::send (unsigned char *buffer) {
...
@@ -350,6 +395,13 @@ void Game::send (unsigned char *buffer) {
}
}
/**
* Game iteration
*
* @param ticks Current time
*
* @return Error code
*/
int
Game
::
step
(
unsigned
int
ticks
)
{
int
Game
::
step
(
unsigned
int
ticks
)
{
// Do nothing
// Do nothing
...
@@ -359,6 +411,11 @@ int Game::step (unsigned int ticks) {
...
@@ -359,6 +411,11 @@ int Game::step (unsigned int ticks) {
}
}
/**
* Assign point to team
*
* @param team Team to receive point
*/
void
Game
::
score
(
unsigned
char
team
)
{
void
Game
::
score
(
unsigned
char
team
)
{
// Do nothing
// Do nothing
...
@@ -368,6 +425,12 @@ void Game::score (unsigned char team) {
...
@@ -368,6 +425,12 @@ void Game::score (unsigned char team) {
}
}
/**
* Set the checkpoint
*
* @param gridX X-coordinate (in tiles) of the checkpoint
* @param gridY Y-coordinate (in tiles) of the checkpoint
*/
void
Game
::
setCheckpoint
(
unsigned
char
gridX
,
unsigned
char
gridY
)
{
void
Game
::
setCheckpoint
(
unsigned
char
gridX
,
unsigned
char
gridY
)
{
checkX
=
gridX
;
checkX
=
gridX
;
...
@@ -378,6 +441,11 @@ void Game::setCheckpoint (unsigned char gridX, unsigned char gridY) {
...
@@ -378,6 +441,11 @@ void Game::setCheckpoint (unsigned char gridX, unsigned char gridY) {
}
}
/**
* Make a player restart the level from the beginning/last checkpoint
*
* @param player Player to reset
*/
void
Game
::
resetPlayer
(
Player
*
player
)
{
void
Game
::
resetPlayer
(
Player
*
player
)
{
player
->
reset
(
checkX
,
checkY
);
player
->
reset
(
checkX
,
checkY
);
...
@@ -387,6 +455,13 @@ void Game::resetPlayer (Player *player) {
...
@@ -387,6 +455,13 @@ void Game::resetPlayer (Player *player) {
}
}
/**
* Re-create a player's level player
*
* @param player Player to reset
* @param levelType Type of level (and, consequently, type of level player)
* @param anims New level player's animations
*/
void
Game
::
resetPlayer
(
Player
*
player
,
LevelType
levelType
,
Anim
**
anims
)
{
void
Game
::
resetPlayer
(
Player
*
player
,
LevelType
levelType
,
Anim
**
anims
)
{
Anim
*
pAnims
[
PANIMS
];
Anim
*
pAnims
[
PANIMS
];
...
...
src/game/game.h
View file @
4da24843
/*
/*
*
*
*
* game.h
*
@file
game.h
*
*
* Part of the OpenJazz project
*
* @section History
* 2nd March 2009: Created network.h from parts of OpenJazz.h
* 2nd March 2009: Created network.h from parts of OpenJazz.h
* 9th February 2009: Renamed network.h to game.h
* 9th February 2009: Renamed network.h to game.h
* 2nd August 2009: Created gamemode.h from parts of game.h
* 2nd August 2009: Created gamemode.h from parts of game.h
*
*
* Part of the OpenJazz project
* @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -83,14 +84,17 @@
...
@@ -83,14 +84,17 @@
class
Anim
;
class
Anim
;
class
File
;
class
File
;
/// Handling for single-player games and base class for multiplayer game handling classes
class
Game
{
class
Game
{
protected
:
protected
:
GameMode
*
mode
;
GameMode
*
mode
;
///< Mode-specific management
char
*
levelFile
;
char
*
levelFile
;
///< Current level's file name
int
difficulty
;
int
difficulty
;
///< Difficulty setting (0 = easy, 1 = medium, 2 = hard, 3 = turbo (hard in JJ2 levels))
unsigned
int
sendTime
,
checkTime
;
unsigned
int
sendTime
;
///< The next time data will be sent
unsigned
char
checkX
,
checkY
;
unsigned
int
checkTime
;
///< The next time a connection/disconnection will be dealt with
unsigned
char
checkX
;
///< X-coordinate of the level checkpoint
unsigned
char
checkY
;
///< Y-coordinate of the level checkpoint
Game
();
Game
();
...
@@ -114,20 +118,21 @@ class Game {
...
@@ -114,20 +118,21 @@ class Game {
};
};
/// Game handling for multiplayer servers
class
ServerGame
:
public
Game
{
class
ServerGame
:
public
Game
{
private
:
private
:
int
clientStatus
[
MAX_CLIENTS
];
/*
int
clientStatus
[
MAX_CLIENTS
];
/*
*< Array of client statuses
-2: Connected and operational
-2: Connected and operational
-1: Not connected
-1: Not connected
>=0: Number of bytes of the level that have been sent */
>=0: Number of bytes of the level that have been sent */
int
clientPlayer
[
MAX_CLIENTS
];
int
clientPlayer
[
MAX_CLIENTS
];
///< Array of client player indexes
int
clientSock
[
MAX_CLIENTS
];
int
clientSock
[
MAX_CLIENTS
];
///< Array of client sockets
unsigned
char
recvBuffers
[
MAX_CLIENTS
][
BUFFER_LENGTH
];
unsigned
char
recvBuffers
[
MAX_CLIENTS
][
BUFFER_LENGTH
];
///< Array of buffers containing data received from clients
int
received
[
MAX_CLIENTS
];
int
received
[
MAX_CLIENTS
];
///< Array containing the amount of data received from each client
unsigned
char
*
levelData
;
unsigned
char
*
levelData
;
///< Contents of the current level file
int
levelSize
;
int
levelSize
;
///< Size of the current level file
int
sock
;
int
sock
;
///< Server socket
public
:
public
:
ServerGame
(
GameModeType
mode
,
char
*
firstLevel
,
int
gameDifficulty
);
ServerGame
(
GameModeType
mode
,
char
*
firstLevel
,
int
gameDifficulty
);
...
@@ -142,15 +147,16 @@ class ServerGame : public Game {
...
@@ -142,15 +147,16 @@ class ServerGame : public Game {
};
};
/// Game handling for multiplayer clients
class
ClientGame
:
public
Game
{
class
ClientGame
:
public
Game
{
private
:
private
:
File
*
file
;
File
*
file
;
///< File to which the incoming level will be written
unsigned
char
recvBuffer
[
BUFFER_LENGTH
];
unsigned
char
recvBuffer
[
BUFFER_LENGTH
];
///< Buffer containing data received from server
int
received
;
int
received
;
///< Amount of data received from server
int
clientID
;
int
clientID
;
///< Client's index on the server
int
maxPlayers
;
int
maxPlayers
;
///< The maximum number of players in the game
int
sock
;
int
sock
;
///< Client socket
public
:
public
:
ClientGame
(
char
*
address
);
ClientGame
(
char
*
address
);
...
@@ -167,7 +173,7 @@ class ClientGame : public Game {
...
@@ -167,7 +173,7 @@ class ClientGame : public Game {
// Variable
// Variable
EXTERN
Game
*
game
;
EXTERN
Game
*
game
;
///< Current game
#endif
#endif
src/game/gamemode.cpp
View file @
4da24843
/*
/*
*
*
*
* gamemode.cpp
* @file gamemode.cpp
*
* 2nd August 2009: Created gamemode.cpp from parts of servergame.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 2nd August 2009: Created gamemode.cpp from parts of servergame.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -28,6 +29,14 @@
...
@@ -28,6 +29,14 @@
#include "player/levelplayer.h"
#include "player/levelplayer.h"
/**
* Outcome of player being hit
*
* @param source Player responsible for the hit
* @param victim Player victim of the hit
*
* @return Whether or not the hit should result in energy loss (true)
*/
bool
GameMode
::
hit
(
Player
*
source
,
Player
*
victim
)
{
bool
GameMode
::
hit
(
Player
*
source
,
Player
*
victim
)
{
return
true
;
return
true
;
...
@@ -35,6 +44,14 @@ bool GameMode::hit (Player *source, Player *victim) {
...
@@ -35,6 +44,14 @@ bool GameMode::hit (Player *source, Player *victim) {
}
}
/**
* Outcome of player being killed
*
* @param source Player responsible for the kill
* @param victim Player victim of the kill
*
* @return Whether or not the player should be be killed (true)
*/
bool
GameMode
::
kill
(
Player
*
source
,
Player
*
victim
)
{
bool
GameMode
::
kill
(
Player
*
source
,
Player
*
victim
)
{
if
(
source
&&
(
victim
==
localPlayer
))
game
->
score
(
source
->
getTeam
());
if
(
source
&&
(
victim
==
localPlayer
))
game
->
score
(
source
->
getTeam
());
...
@@ -44,6 +61,15 @@ bool GameMode::kill (Player *source, Player *victim) {
...
@@ -44,6 +61,15 @@ bool GameMode::kill (Player *source, Player *victim) {
}
}
/**
* Outcome of level being completed
*
* @param player Player that has completed level
* @param gridX X-coordinate (in tiles) of finishing position
* @param gridY Y-coordinate (in tiles) of finishing position
*
* @return Whether or not the end-of-level signpost should be destroyed (true)
*/
bool
GameMode
::
endOfLevel
(
Player
*
player
,
unsigned
char
gridX
,
unsigned
char
gridY
)
{
bool
GameMode
::
endOfLevel
(
Player
*
player
,
unsigned
char
gridX
,
unsigned
char
gridY
)
{
game
->
setCheckpoint
(
gridX
,
gridY
);
game
->
setCheckpoint
(
gridX
,
gridY
);
...
@@ -55,6 +81,9 @@ bool GameMode::endOfLevel (Player *player, unsigned char gridX, unsigned char gr
...
@@ -55,6 +81,9 @@ bool GameMode::endOfLevel (Player *player, unsigned char gridX, unsigned char gr
}
}
/**
* Outcome of time running out
*/
void
GameMode
::
outOfTime
()
{
void
GameMode
::
outOfTime
()
{
return
;
return
;
...
@@ -62,6 +91,11 @@ void GameMode::outOfTime () {
...
@@ -62,6 +91,11 @@ void GameMode::outOfTime () {
}
}
/**
* Get the game mode type
*
* @return Game mode type (M_SINGLE)
*/
GameModeType
SingleGameMode
::
getMode
()
{
GameModeType
SingleGameMode
::
getMode
()
{
return
M_SINGLE
;
return
M_SINGLE
;
...
@@ -69,6 +103,11 @@ GameModeType SingleGameMode::getMode () {
...
@@ -69,6 +103,11 @@ GameModeType SingleGameMode::getMode () {
}
}
/**
* Choose a team for a new player
*
* @return New player's team (0)
*/
unsigned
char
SingleGameMode
::
chooseTeam
()
{
unsigned
char
SingleGameMode
::
chooseTeam
()
{
return
0
;
return
0
;
...
@@ -76,6 +115,11 @@ unsigned char SingleGameMode::chooseTeam () {
...
@@ -76,6 +115,11 @@ unsigned char SingleGameMode::chooseTeam () {
}
}
/**
* Draw the player's team's score (not in single-player mode)
*
* @param font Font to use to draw score
*/
void
SingleGameMode
::
drawScore
(
Font
*
font
)
{
void
SingleGameMode
::
drawScore
(
Font
*
font
)
{
return
;
return
;
...
@@ -83,6 +127,11 @@ void SingleGameMode::drawScore (Font* font) {
...
@@ -83,6 +127,11 @@ void SingleGameMode::drawScore (Font* font) {
}
}
/**
* Choose a team for a new player
*
* @return New player's team (0)
*/
unsigned
char
CooperativeGameMode
::
chooseTeam
()
{
unsigned
char
CooperativeGameMode
::
chooseTeam
()
{
// All players are on the same team
// All players are on the same team
...
@@ -92,6 +141,11 @@ unsigned char CooperativeGameMode::chooseTeam () {
...
@@ -92,6 +141,11 @@ unsigned char CooperativeGameMode::chooseTeam () {
}
}
/**
* Draw the player's team's score (not in cooperative mode)
*
* @param font Font to use to draw score
*/
void
CooperativeGameMode
::
drawScore
(
Font
*
font
)
{
void
CooperativeGameMode
::
drawScore
(
Font
*
font
)
{
// Do nothing
// Do nothing
...
@@ -101,6 +155,11 @@ void CooperativeGameMode::drawScore (Font* font) {
...
@@ -101,6 +155,11 @@ void CooperativeGameMode::drawScore (Font* font) {
}
}
/**
* Choose a team for a new player
*
* @return New player's team (unique)
*/
unsigned
char
FreeForAllGameMode
::
chooseTeam
()
{
unsigned
char
FreeForAllGameMode
::
chooseTeam
()
{
// Every player is on a separate team
// Every player is on a separate team
...
@@ -123,6 +182,11 @@ unsigned char FreeForAllGameMode::chooseTeam () {
...
@@ -123,6 +182,11 @@ unsigned char FreeForAllGameMode::chooseTeam () {
}
}
/**
* Draw the player's team's score
*
* @param font Font to use to draw score
*/
void
FreeForAllGameMode
::
drawScore
(
Font
*
font
)
{
void
FreeForAllGameMode
::
drawScore
(
Font
*
font
)
{
font
->
showNumber
(
localPlayer
->
teamScore
,
64
,
4
);
font
->
showNumber
(
localPlayer
->
teamScore
,
64
,
4
);
...
@@ -132,6 +196,11 @@ void FreeForAllGameMode::drawScore (Font* font) {
...
@@ -132,6 +196,11 @@ void FreeForAllGameMode::drawScore (Font* font) {
}
}
/**
* Choose a team for a new player
*
* @return New player's team (0 or 1)
*/
unsigned
char
TeamGameMode
::
chooseTeam
()
{
unsigned
char
TeamGameMode
::
chooseTeam
()
{
// Players are split between two teams
// Players are split between two teams
...
@@ -158,6 +227,11 @@ unsigned char TeamGameMode::chooseTeam () {
...
@@ -158,6 +227,11 @@ unsigned char TeamGameMode::chooseTeam () {
}
}
/**
* Draw the player's team's score
*
* @param font Font to use to draw score
*/
void
TeamGameMode
::
drawScore
(
Font
*
font
)
{
void
TeamGameMode
::
drawScore
(
Font
*
font
)
{
font
->
showNumber
(
localPlayer
->
teamScore
,
64
,
4
);
font
->
showNumber
(
localPlayer
->
teamScore
,
64
,
4
);
...
@@ -167,6 +241,11 @@ void TeamGameMode::drawScore (Font* font) {
...
@@ -167,6 +241,11 @@ void TeamGameMode::drawScore (Font* font) {
}
}
/**
* Get the game mode type
*
* @return Game mode type (M_COOP)
*/
GameModeType
CoopGameMode
::
getMode
()
{
GameModeType
CoopGameMode
::
getMode
()
{
return
M_COOP
;
return
M_COOP
;
...
@@ -174,6 +253,11 @@ GameModeType CoopGameMode::getMode () {
...
@@ -174,6 +253,11 @@ GameModeType CoopGameMode::getMode () {
}
}
/**
* Get the game mode type
*
* @return Game mode type (M_BATTLE)
*/
GameModeType
BattleGameMode
::
getMode
()
{
GameModeType
BattleGameMode
::
getMode
()
{
return
M_BATTLE
;
return
M_BATTLE
;
...
@@ -181,6 +265,11 @@ GameModeType BattleGameMode::getMode () {
...
@@ -181,6 +265,11 @@ GameModeType BattleGameMode::getMode () {
}
}
/**
* Get the game mode type
*
* @return Game mode type (M_TEAMBATTLE)
*/
GameModeType
TeamBattleGameMode
::
getMode
()
{
GameModeType
TeamBattleGameMode
::
getMode
()
{
return
M_TEAMBATTLE
;
return
M_TEAMBATTLE
;
...
@@ -188,6 +277,11 @@ GameModeType TeamBattleGameMode::getMode () {
...
@@ -188,6 +277,11 @@ GameModeType TeamBattleGameMode::getMode () {
}
}
/**
* Get the game mode type
*
* @return Game mode type (M_RACE)
*/
GameModeType
RaceGameMode
::
getMode
()
{
GameModeType
RaceGameMode
::
getMode
()
{
return
M_RACE
;
return
M_RACE
;
...
@@ -195,6 +289,14 @@ GameModeType RaceGameMode::getMode () {
...
@@ -195,6 +289,14 @@ GameModeType RaceGameMode::getMode () {
}
}
/**
* Outcome of player being hit
*
* @param source Player responsible for the hit
* @param victim Player victim of the hit
*
* @return Whether or not the hit should result in energy loss (false)
*/
bool
RaceGameMode
::
hit
(
Player
*
source
,
Player
*
victim
)
{
bool
RaceGameMode
::
hit
(
Player
*
source
,
Player
*
victim
)
{
return
false
;
return
false
;
...
@@ -202,6 +304,15 @@ bool RaceGameMode::hit (Player *source, Player *victim) {
...
@@ -202,6 +304,15 @@ bool RaceGameMode::hit (Player *source, Player *victim) {
}
}
/**
* Outcome of level being completed
*
* @param player Player that has completed level
* @param gridX X-coordinate (in tiles) of finishing position
* @param gridY Y-coordinate (in tiles) of finishing position
*
* @return Whether or not the end-of-level signpost should be destroyed (false)
*/
bool
RaceGameMode
::
endOfLevel
(
Player
*
player
,
unsigned
char
gridX
,
unsigned
char
gridY
)
{
bool
RaceGameMode
::
endOfLevel
(
Player
*
player
,
unsigned
char
gridX
,
unsigned
char
gridY
)
{
if
(
player
==
localPlayer
)
game
->
score
(
localPlayer
->
getTeam
());
if
(
player
==
localPlayer
)
game
->
score
(
localPlayer
->
getTeam
());
...
...
src/game/gamemode.h
View file @
4da24843
/*
/*
*
*
*
* gamemode.h
* @file gamemode.h
*
* 2nd August 2009: Created gamemode.h from parts of game.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 2nd August 2009: Created gamemode.h from parts of game.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -34,6 +35,7 @@
...
@@ -34,6 +35,7 @@
// Enum
// Enum
/// Game mode identifier
enum
GameModeType
{
enum
GameModeType
{
M_SINGLE
=
0
,
M_COOP
=
1
,
M_BATTLE
=
2
,
M_TEAMBATTLE
=
3
,
M_RACE
=
4
M_SINGLE
=
0
,
M_COOP
=
1
,
M_BATTLE
=
2
,
M_TEAMBATTLE
=
3
,
M_RACE
=
4
...
@@ -46,6 +48,7 @@ enum GameModeType {
...
@@ -46,6 +48,7 @@ enum GameModeType {
class
Font
;
class
Font
;
class
Player
;
class
Player
;
/// Game mode base class
class
GameMode
{
class
GameMode
{
public
:
public
:
...
@@ -59,6 +62,7 @@ class GameMode {
...
@@ -59,6 +62,7 @@ class GameMode {
};
};
/// Single-player game mode
class
SingleGameMode
:
public
GameMode
{
class
SingleGameMode
:
public
GameMode
{
public
:
public
:
...
@@ -68,6 +72,7 @@ class SingleGameMode : public GameMode {
...
@@ -68,6 +72,7 @@ class SingleGameMode : public GameMode {
};
};
/// Co-operative game mode base class
class
CooperativeGameMode
:
public
GameMode
{
class
CooperativeGameMode
:
public
GameMode
{
public
:
public
:
...
@@ -76,6 +81,7 @@ class CooperativeGameMode : public GameMode {
...
@@ -76,6 +81,7 @@ class CooperativeGameMode : public GameMode {
};
};
/// Free-for-all game mode base class
class
FreeForAllGameMode
:
public
GameMode
{
class
FreeForAllGameMode
:
public
GameMode
{
public
:
public
:
...
@@ -84,6 +90,7 @@ class FreeForAllGameMode : public GameMode {
...
@@ -84,6 +90,7 @@ class FreeForAllGameMode : public GameMode {
};
};
/// Team-based game mode base class
class
TeamGameMode
:
public
GameMode
{
class
TeamGameMode
:
public
GameMode
{
public
:
public
:
...
@@ -92,6 +99,7 @@ class TeamGameMode : public GameMode {
...
@@ -92,6 +99,7 @@ class TeamGameMode : public GameMode {
};
};
/// Co-operative game mode
class
CoopGameMode
:
public
CooperativeGameMode
{
class
CoopGameMode
:
public
CooperativeGameMode
{
public
:
public
:
...
@@ -99,30 +107,33 @@ class CoopGameMode : public CooperativeGameMode {
...
@@ -99,30 +107,33 @@ class CoopGameMode : public CooperativeGameMode {
};
};
/// Battle game mode
class
BattleGameMode
:
public
FreeForAllGameMode
{
class
BattleGameMode
:
public
FreeForAllGameMode
{
private
:
private
:
int
targetKills
;
int
targetKills
;
///< Number of kills required for a player to win
public
:
public
:
GameModeType
getMode
();
GameModeType
getMode
();
};
};
/// Team battle game mode
class
TeamBattleGameMode
:
public
TeamGameMode
{
class
TeamBattleGameMode
:
public
TeamGameMode
{
private
:
private
:
int
targetKills
;
int
targetKills
;
///< Number of kills required for a team to win
public
:
public
:
GameModeType
getMode
();
GameModeType
getMode
();
};
};
/// Race game mode
class
RaceGameMode
:
public
FreeForAllGameMode
{
class
RaceGameMode
:
public
FreeForAllGameMode
{
private
:
private
:
int
targetLaps
;
int
targetLaps
;
///< Number of laps required for a player to win
public
:
public
:
GameModeType
getMode
();
GameModeType
getMode
();
...
...
src/game/servergame.cpp
View file @
4da24843
/*
/*
*
*
*
* servergame.cpp
* @file servergame.cpp
*
* 18th July 2009: Created servergame.cpp from parts of game.cpp
* 2nd August 2009: Created gamemode.cpp from parts of servergame.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 18th July 2009: Created servergame.cpp from parts of game.cpp
* 2nd August 2009: Created gamemode.cpp from parts of servergame.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -36,6 +37,13 @@
...
@@ -36,6 +37,13 @@
#include <string.h>
#include <string.h>
/**
* Create game server
*
* @param modeType Game mode
* @param firstLevel File name of the first level to play
* @param gameDifficulty Difficulty setting
*/
ServerGame
::
ServerGame
(
GameModeType
modeType
,
char
*
firstLevel
,
int
gameDifficulty
)
{
ServerGame
::
ServerGame
(
GameModeType
modeType
,
char
*
firstLevel
,
int
gameDifficulty
)
{
int
count
;
int
count
;
...
@@ -84,6 +92,9 @@ ServerGame::ServerGame (GameModeType modeType, char* firstLevel, int gameDifficu
...
@@ -84,6 +92,9 @@ ServerGame::ServerGame (GameModeType modeType, char* firstLevel, int gameDifficu
}
}
/**
* Disconnect clients and destroy server
*/
ServerGame
::~
ServerGame
()
{
ServerGame
::~
ServerGame
()
{
int
count
;
int
count
;
...
@@ -105,6 +116,13 @@ ServerGame::~ServerGame () {
...
@@ -105,6 +116,13 @@ ServerGame::~ServerGame () {
}
}
/**
* Set the next level and load it into memory
*
* @param fileName The file name of the next level
*
* @return Error code
*/
int
ServerGame
::
setLevel
(
char
*
fileName
)
{
int
ServerGame
::
setLevel
(
char
*
fileName
)
{
File
*
file
;
File
*
file
;
...
@@ -162,6 +180,11 @@ int ServerGame::setLevel (char* fileName) {
...
@@ -162,6 +180,11 @@ int ServerGame::setLevel (char* fileName) {
}
}
/**
* Send data to clients
*
* @param buffer Data to send. First byte indicates length.
*/
void
ServerGame
::
send
(
unsigned
char
*
buffer
)
{
void
ServerGame
::
send
(
unsigned
char
*
buffer
)
{
int
count
;
int
count
;
...
@@ -182,6 +205,13 @@ void ServerGame::send (unsigned char* buffer) {
...
@@ -182,6 +205,13 @@ void ServerGame::send (unsigned char* buffer) {
}
}
/**
* Game iteration
*
* @param ticks Current time
*
* @return Error code
*/
int
ServerGame
::
step
(
unsigned
int
ticks
)
{
int
ServerGame
::
step
(
unsigned
int
ticks
)
{
unsigned
char
sendBuffer
[
BUFFER_LENGTH
];
unsigned
char
sendBuffer
[
BUFFER_LENGTH
];
...
@@ -449,6 +479,11 @@ int ServerGame::step (unsigned int ticks) {
...
@@ -449,6 +479,11 @@ int ServerGame::step (unsigned int ticks) {
}
}
/**
* Assign point to team and inform clients
*
* @param team Team to receive point
*/
void
ServerGame
::
score
(
unsigned
char
team
)
{
void
ServerGame
::
score
(
unsigned
char
team
)
{
unsigned
char
buffer
[
MTL_G_SCORE
];
unsigned
char
buffer
[
MTL_G_SCORE
];
...
@@ -472,6 +507,12 @@ void ServerGame::score (unsigned char team) {
...
@@ -472,6 +507,12 @@ void ServerGame::score (unsigned char team) {
}
}
/**
* Set the checkpoint and inform clients
*
* @param gridX X-coordinate (in tiles) of the checkpoint
* @param gridY Y-coordinate (in tiles) of the checkpoint
*/
void
ServerGame
::
setCheckpoint
(
unsigned
char
gridX
,
unsigned
char
gridY
)
{
void
ServerGame
::
setCheckpoint
(
unsigned
char
gridX
,
unsigned
char
gridY
)
{
unsigned
char
buffer
[
MTL_G_CHECK
];
unsigned
char
buffer
[
MTL_G_CHECK
];
...
...
src/io/controls.cpp
View file @
4da24843
/*
/*
*
*
*
* controls.cpp
* @file controls.cpp
*
* 13th July 2009: Created controls.cpp from parts of main.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 13th July 2009: Created controls.cpp from parts of main.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -17,9 +18,7 @@
...
@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with input.
* Deals with input.
*
*
*/
*/
...
...
src/io/controls.h
View file @
4da24843
/*
/*
*
*
*
* controls.h
* @file controls.h
*
* 13th July 2009: Created controls.h from parts of OpenJazz.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 13th July 2009: Created controls.h from parts of OpenJazz.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -54,35 +55,35 @@
...
@@ -54,35 +55,35 @@
// Class
// Class
/// Keeps track of all control input
class
Controls
{
class
Controls
{
private
:
private
:
struct
{
struct
{
int
key
;
// Keyboard key
int
key
;
//
/<
Keyboard key
bool
state
;
bool
state
;
}
keys
[
CONTROLS
];
}
keys
[
CONTROLS
];
struct
{
struct
{
int
button
;
// Joystick button
int
button
;
//
/<
Joystick button
bool
state
;
bool
state
;
}
buttons
[
CONTROLS
];
}
buttons
[
CONTROLS
];
struct
{
struct
{
int
axis
;
// Joystick axis
int
axis
;
//
/<
Joystick axis
bool
direction
;
// Axis direction
bool
direction
;
//
/<
Axis direction
bool
state
;
bool
state
;
}
axes
[
CONTROLS
];
}
axes
[
CONTROLS
];
struct
{
struct
{
unsigned
int
time
;
/* The time from which the control will respond
unsigned
int
time
;
///< The time from which the control will respond to being pressed
to being pressed */
bool
state
;
bool
state
;
}
controls
[
CONTROLS
];
}
controls
[
CONTROLS
];
...
...
src/io/file.cpp
View file @
4da24843
/*
/*
*
*
*
* file.cpp
* @file file.cpp
*
* 3rd February 2009: Created file.cpp from parts of util.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 3rd February 2009: Created file.cpp from parts of util.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -17,6 +18,9 @@
...
@@ -17,6 +18,9 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @section Description
* Deals with files.
*
*/
*/
...
@@ -29,12 +33,16 @@
...
@@ -29,12 +33,16 @@
#include <zlib.h>
#include <zlib.h>
/**
* Try opening a file from the available paths
*
* @param name File name
* @param write Whether or not the file can be written to
*/
File
::
File
(
const
char
*
name
,
bool
write
)
{
File
::
File
(
const
char
*
name
,
bool
write
)
{
Path
*
path
;
Path
*
path
;
// Try opening the file from all the available directories
path
=
firstPath
;
path
=
firstPath
;
while
(
path
)
{
while
(
path
)
{
...
...
src/io/file.h
View file @
4da24843
/*
/*
*
*
*
* file.h
* @file file.h
*
* 3rd February 2009: Created file.h from parts of OpenJazz.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 3rd February 2009: Created file.h from parts of OpenJazz.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -32,6 +33,7 @@
...
@@ -32,6 +33,7 @@
// Classes
// Classes
/// File i/o
class
File
{
class
File
{
private
:
private
:
...
@@ -66,11 +68,12 @@ class File {
...
@@ -66,11 +68,12 @@ class File {
};
};
/// Directory path
class
Path
{
class
Path
{
public
:
public
:
Path
*
next
;
Path
*
next
;
///< Next path to check
char
*
path
;
char
*
path
;
///< Path
Path
(
Path
*
newNext
,
char
*
newPath
);
Path
(
Path
*
newNext
,
char
*
newPath
);
~
Path
();
~
Path
();
...
...
src/io/gfx/anim.cpp
View file @
4da24843
/*
/*
*
*
*
* anim.cpp
* @file anim.cpp
*
* 26th July 2009: Created anim.cpp from parts of sprite.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 26th July 2009: Created anim.cpp from parts of sprite.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
...
src/io/gfx/anim.h
View file @
4da24843
/*
/*
*
*
*
* anim.h
* @file anim.h
*
* 26th July 2009: Created anim.h from parts of sprite.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 26th July 2009: Created anim.h from parts of sprite.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -33,10 +34,11 @@
...
@@ -33,10 +34,11 @@
class
Sprite
;
class
Sprite
;
/// Animation
class
Anim
{
class
Anim
{
private
:
private
:
Sprite
**
sprites
;
Sprite
**
sprites
;
///< Sprite images
signed
char
*
xOffsets
;
signed
char
*
xOffsets
;
signed
char
*
yOffsets
;
signed
char
*
yOffsets
;
bool
ignoreDefaultYOffset
;
bool
ignoreDefaultYOffset
;
...
@@ -45,10 +47,10 @@ class Anim {
...
@@ -45,10 +47,10 @@ class Anim {
signed
char
accessoryX
;
signed
char
accessoryX
;
signed
char
accessoryY
;
signed
char
accessoryY
;
signed
char
yOffset
;
signed
char
yOffset
;
unsigned
char
frames
;
// Number of frames
unsigned
char
frames
;
//
/<
Number of frames
unsigned
char
frame
;
// Current frame
unsigned
char
frame
;
//
/<
Current frame
unsigned
char
accessory
;
// Number of an animation that is an accessory to this animation
unsigned
char
accessory
;
//
/<
Number of an animation that is an accessory to this animation
// Most of the time accessories are used with guardians.
//
/<
Most of the time accessories are used with guardians.
public
:
public
:
Anim
();
Anim
();
...
...
src/io/gfx/font.cpp
View file @
4da24843
/*
/*
*
*
*
* font.cpp
* @file font.cpp
*
* 23rd August 2005: Created font.c
* 3rd February 2009: Renamed font.c to font.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 23rd August 2005: Created font.c
* 3rd February 2009: Renamed font.c to font.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -18,9 +19,7 @@
...
@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the loading, displaying and freeing of screen fonts.
* Deals with the loading, displaying and freeing of screen fonts.
*
*
*/
*/
...
@@ -494,13 +493,19 @@ void Font::showNumber (int n, int x, int y) {
...
@@ -494,13 +493,19 @@ void Font::showNumber (int n, int x, int y) {
}
}
/**
* Map a range of palette indices to another range
*
* @param start Start of original range
* @param length Span of original range
* @param newStart Start of new range
* @param newLength Span of new range
*/
void
Font
::
mapPalette
(
int
start
,
int
length
,
int
newStart
,
int
newLength
)
{
void
Font
::
mapPalette
(
int
start
,
int
length
,
int
newStart
,
int
newLength
)
{
SDL_Color
palette
[
256
];
SDL_Color
palette
[
256
];
int
count
;
int
count
;
// Map a range of palette indices to another range
for
(
count
=
0
;
count
<
length
;
count
++
)
for
(
count
=
0
;
count
<
length
;
count
++
)
palette
[
count
].
r
=
palette
[
count
].
g
=
palette
[
count
].
b
=
palette
[
count
].
r
=
palette
[
count
].
g
=
palette
[
count
].
b
=
(
count
*
newLength
/
length
)
+
newStart
;
(
count
*
newLength
/
length
)
+
newStart
;
...
...
src/io/gfx/font.h
View file @
4da24843
/*
/*
*
*
*
* font.h
* @file font.h
*
* 3rd February 2009: Created font.h from parts of OpenJazz.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 3rd February 2009: Created font.h from parts of OpenJazz.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -33,13 +34,14 @@
...
@@ -33,13 +34,14 @@
class
File
;
class
File
;
/// Font
class
Font
{
class
Font
{
private
:
private
:
SDL_Surface
*
characters
[
128
];
SDL_Surface
*
characters
[
128
];
///< Symbol images
int
nCharacters
;
int
nCharacters
;
///< Number of symbols
unsigned
char
lineHeight
;
unsigned
char
lineHeight
;
///< Vertical spacing of displayed characters
char
map
[
128
];
//
Maps ASCII values to letter position
s
char
map
[
128
];
//
/< Maps ASCII values to symbol indice
s
public
:
public
:
Font
(
const
char
*
fileName
);
Font
(
const
char
*
fileName
);
...
@@ -61,13 +63,13 @@ class Font {
...
@@ -61,13 +63,13 @@ class Font {
// Variables
// Variables
EXTERN
Font
*
font2
;
/* Taken from .0FN file name */
EXTERN
Font
*
font2
;
/*
*
Taken from .0FN file name */
EXTERN
Font
*
fontbig
;
/* Taken from .0FN file name */
EXTERN
Font
*
fontbig
;
/*
*
Taken from .0FN file name */
EXTERN
Font
*
fontiny
;
/* Taken from .0FN file name */
EXTERN
Font
*
fontiny
;
/*
*
Taken from .0FN file name */
EXTERN
Font
*
fontmn1
;
/* Taken from .0FN file name */
EXTERN
Font
*
fontmn1
;
/*
*
Taken from .0FN file name */
EXTERN
Font
*
fontmn2
;
/* Taken from .0FN file name */
EXTERN
Font
*
fontmn2
;
/*
*
Taken from .0FN file name */
EXTERN
Font
*
panelBigFont
;
/* Found in PANEL.000 */
EXTERN
Font
*
panelBigFont
;
/*
*
Found in PANEL.000 */
EXTERN
Font
*
panelSmallFont
;
/* Found in PANEL.000 */
EXTERN
Font
*
panelSmallFont
;
/*
*
Found in PANEL.000 */
#endif
#endif
src/io/gfx/paletteeffects.cpp
View file @
4da24843
/*
/*
*
*
*
* paletteeffects.cpp
* @file paletteeffects.cpp
*
* 4th February 2009: Created palette.cpp from parts of main.cpp and util.cpp
* 1st August 2009: Renamed palette.cpp to paletteeffects.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 4th February 2009: Created palette.cpp from parts of main.cpp and util.cpp
* 1st August 2009: Renamed palette.cpp to paletteeffects.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -61,7 +62,7 @@ void PaletteEffect::apply (SDL_Color* shownPalette, bool direct, int mspf) {
...
@@ -61,7 +62,7 @@ void PaletteEffect::apply (SDL_Color* shownPalette, bool direct, int mspf) {
WhiteInPaletteEffect
::
WhiteInPaletteEffect
WhiteInPaletteEffect
::
WhiteInPaletteEffect
(
fixed
newDuration
,
PaletteEffect
*
nextPE
)
:
PaletteEffect
(
nextPE
)
{
(
int
newDuration
,
PaletteEffect
*
nextPE
)
:
PaletteEffect
(
nextPE
)
{
duration
=
newDuration
;
duration
=
newDuration
;
whiteness
=
F1
+
FH
;
whiteness
=
F1
+
FH
;
...
...
src/io/gfx/paletteeffects.h
View file @
4da24843
/*
/*
*
*
*
* paletteeffects.h
* @file paletteeffects.h
*
* 4th February 2009: Created palette.h from parts of OpenJazz.h
* 1st August 2009: Renamed palette.h to paletteeffects.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 4th February 2009: Created palette.h from parts of OpenJazz.h
* 1st August 2009: Renamed palette.h to paletteeffects.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -46,10 +47,11 @@
...
@@ -46,10 +47,11 @@
// Class
// Class
/// Palette effect base class
class
PaletteEffect
{
class
PaletteEffect
{
protected
:
protected
:
PaletteEffect
*
next
;
// Next effect to use
PaletteEffect
*
next
;
//
/<
Next effect to use
public
:
public
:
PaletteEffect
(
PaletteEffect
*
nextPE
);
PaletteEffect
(
PaletteEffect
*
nextPE
);
...
@@ -59,11 +61,11 @@ class PaletteEffect {
...
@@ -59,11 +61,11 @@ class PaletteEffect {
};
};
/// Dissolve from white palette effect
class
WhiteInPaletteEffect
:
public
PaletteEffect
{
class
WhiteInPaletteEffect
:
public
PaletteEffect
{
private
:
private
:
int
duration
;
// Number of milliseconds the effect lasts
int
duration
;
//
/<
Number of milliseconds the effect lasts
fixed
whiteness
;
fixed
whiteness
;
public
:
public
:
...
@@ -73,11 +75,11 @@ class WhiteInPaletteEffect : public PaletteEffect {
...
@@ -73,11 +75,11 @@ class WhiteInPaletteEffect : public PaletteEffect {
};
};
/// Fade in palette effect
class
FadeInPaletteEffect
:
public
PaletteEffect
{
class
FadeInPaletteEffect
:
public
PaletteEffect
{
private
:
private
:
int
duration
;
// Number of milliseconds the effect lasts
int
duration
;
//
/<
Number of milliseconds the effect lasts
fixed
blackness
;
fixed
blackness
;
public
:
public
:
...
@@ -87,11 +89,11 @@ class FadeInPaletteEffect : public PaletteEffect {
...
@@ -87,11 +89,11 @@ class FadeInPaletteEffect : public PaletteEffect {
};
};
/// Dissolve to white palette effect
class
WhiteOutPaletteEffect
:
public
PaletteEffect
{
class
WhiteOutPaletteEffect
:
public
PaletteEffect
{
private
:
private
:
int
duration
;
// Number of milliseconds the effect lasts
int
duration
;
//
/<
Number of milliseconds the effect lasts
fixed
whiteness
;
fixed
whiteness
;
public
:
public
:
...
@@ -101,11 +103,11 @@ class WhiteOutPaletteEffect : public PaletteEffect {
...
@@ -101,11 +103,11 @@ class WhiteOutPaletteEffect : public PaletteEffect {
};
};
/// Fade out palette effect
class
FadeOutPaletteEffect
:
public
PaletteEffect
{
class
FadeOutPaletteEffect
:
public
PaletteEffect
{
private
:
private
:
int
duration
;
// Number of milliseconds the effect lasts
int
duration
;
//
/<
Number of milliseconds the effect lasts
fixed
blackness
;
fixed
blackness
;
public
:
public
:
...
@@ -115,13 +117,13 @@ class FadeOutPaletteEffect : public PaletteEffect {
...
@@ -115,13 +117,13 @@ class FadeOutPaletteEffect : public PaletteEffect {
};
};
/// Flash colour (dissolve to it and back again) palette effect
class
FlashPaletteEffect
:
public
PaletteEffect
{
class
FlashPaletteEffect
:
public
PaletteEffect
{
private
:
private
:
int
duration
;
// Number of milliseconds the effect lasts
int
duration
;
//
/<
Number of milliseconds the effect lasts
fixed
progress
;
fixed
progress
;
unsigned
char
red
,
green
,
blue
;
// Flash colour
unsigned
char
red
,
green
,
blue
;
//
/<
Flash colour
public
:
public
:
FlashPaletteEffect
(
unsigned
char
newRed
,
unsigned
char
newGreen
,
unsigned
char
newBlue
,
int
newDuration
,
PaletteEffect
*
nextPE
);
FlashPaletteEffect
(
unsigned
char
newRed
,
unsigned
char
newGreen
,
unsigned
char
newBlue
,
int
newDuration
,
PaletteEffect
*
nextPE
);
...
@@ -130,13 +132,13 @@ class FlashPaletteEffect : public PaletteEffect {
...
@@ -130,13 +132,13 @@ class FlashPaletteEffect : public PaletteEffect {
};
};
/// Entry rotation palette effect
class
RotatePaletteEffect
:
public
PaletteEffect
{
class
RotatePaletteEffect
:
public
PaletteEffect
{
private
:
private
:
unsigned
char
first
;
/
* The first palette index affected */
unsigned
char
first
;
/
//< The first palette index affected
int
amount
;
/
* The number of (consecutive) palette indices affected */
int
amount
;
/
//< The number of (consecutive) palette indices affected
fixed
speed
;
// Rotations per second
fixed
speed
;
//
/<
Rotations per second
fixed
position
;
fixed
position
;
public
:
public
:
...
@@ -146,14 +148,14 @@ class RotatePaletteEffect : public PaletteEffect {
...
@@ -146,14 +148,14 @@ class RotatePaletteEffect : public PaletteEffect {
};
};
/// Sky palette palette effect
class
SkyPaletteEffect
:
public
PaletteEffect
{
class
SkyPaletteEffect
:
public
PaletteEffect
{
private
:
private
:
SDL_Color
*
skyPalette
;
SDL_Color
*
skyPalette
;
unsigned
char
first
;
/
* The first palette index affected */
unsigned
char
first
;
/
//< The first palette index affected
int
amount
;
/
* The number of (consecutive) palette indices affected */
int
amount
;
/
//< The number of (consecutive) palette indices affected
fixed
speed
;
// Relative Y speed - as in Jazz 2
fixed
speed
;
//
/<
Relative Y speed - as in Jazz 2
public
:
public
:
SkyPaletteEffect
(
unsigned
char
newFirst
,
int
newAmount
,
fixed
newSpeed
,
SDL_Color
*
newSkyPalette
,
PaletteEffect
*
nextPE
);
SkyPaletteEffect
(
unsigned
char
newFirst
,
int
newAmount
,
fixed
newSpeed
,
SDL_Color
*
newSkyPalette
,
PaletteEffect
*
nextPE
);
...
@@ -162,13 +164,13 @@ class SkyPaletteEffect : public PaletteEffect {
...
@@ -162,13 +164,13 @@ class SkyPaletteEffect : public PaletteEffect {
};
};
/// 2D parallaxing background palette effect
class
P2DPaletteEffect
:
public
PaletteEffect
{
class
P2DPaletteEffect
:
public
PaletteEffect
{
private
:
private
:
unsigned
char
first
;
/
* The first palette index affected */
unsigned
char
first
;
/
//< The first palette index affected
int
amount
;
/
* The number of (consecutive) palette indices affected */
int
amount
;
/
//< The number of (consecutive) palette indices affected
fixed
speed
;
// Relative X & Y speed - as in Jazz 2
fixed
speed
;
//
/<
Relative X & Y speed - as in Jazz 2
public
:
public
:
P2DPaletteEffect
(
unsigned
char
newFirst
,
int
newAmount
,
fixed
newSpeed
,
PaletteEffect
*
nextPE
);
P2DPaletteEffect
(
unsigned
char
newFirst
,
int
newAmount
,
fixed
newSpeed
,
PaletteEffect
*
nextPE
);
...
@@ -177,13 +179,13 @@ class P2DPaletteEffect : public PaletteEffect {
...
@@ -177,13 +179,13 @@ class P2DPaletteEffect : public PaletteEffect {
};
};
/// 1D parallaxing background palette effect
class
P1DPaletteEffect
:
public
PaletteEffect
{
class
P1DPaletteEffect
:
public
PaletteEffect
{
private
:
private
:
unsigned
char
first
;
/
* The first palette index affected */
unsigned
char
first
;
/
//< The first palette index affected
int
amount
;
/
* The number of (consecutive) palette indices affected */
int
amount
;
/
//< The number of (consecutive) palette indices affected
fixed
speed
;
// Relative X & Y speed - as in Jazz 2
fixed
speed
;
//
/<
Relative X & Y speed - as in Jazz 2
public
:
public
:
P1DPaletteEffect
(
unsigned
char
newFirst
,
int
newAmount
,
fixed
newSpeed
,
PaletteEffect
*
nextPE
);
P1DPaletteEffect
(
unsigned
char
newFirst
,
int
newAmount
,
fixed
newSpeed
,
PaletteEffect
*
nextPE
);
...
@@ -192,11 +194,11 @@ class P1DPaletteEffect : public PaletteEffect {
...
@@ -192,11 +194,11 @@ class P1DPaletteEffect : public PaletteEffect {
};
};
/// Underwater darkening palette effect
class
WaterPaletteEffect
:
public
PaletteEffect
{
class
WaterPaletteEffect
:
public
PaletteEffect
{
private
:
private
:
fixed
depth
;
/
* Number of pixels between water surface and total darkness */
fixed
depth
;
/
//< Number of pixels between water surface and total darkness
public
:
public
:
WaterPaletteEffect
(
fixed
newDepth
,
PaletteEffect
*
nextPE
);
WaterPaletteEffect
(
fixed
newDepth
,
PaletteEffect
*
nextPE
);
...
...
src/io/gfx/sprite.cpp
View file @
4da24843
/*
/*
*
*
*
* sprite.cpp
* @file sprite.cpp
*
* 19th March 2009: Created sprite.cpp from parts of event.cpp and player.cpp
* 26th July 2009: Created anim.cpp from parts of sprite.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 19th March 2009: Created sprite.cpp from parts of event.cpp and player.cpp
* 26th July 2009: Created anim.cpp from parts of sprite.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
...
src/io/gfx/sprite.h
View file @
4da24843
/*
/*
*
*
*
* sprite.h
* @file sprite.h
*
* 19th March 2009: Created sprite.h from parts of level.h
* 26th July 2009: Created anim.h from parts of sprite.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 19th March 2009: Created sprite.h from parts of level.h
* 26th July 2009: Created anim.h from parts of sprite.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -32,10 +33,11 @@
...
@@ -32,10 +33,11 @@
// Class
// Class
/// Sprite
class
Sprite
{
class
Sprite
{
private
:
private
:
SDL_Surface
*
pixels
;
SDL_Surface
*
pixels
;
///< Sprite image
public
:
public
:
short
int
xOffset
;
short
int
xOffset
;
...
...
src/io/gfx/video.cpp
View file @
4da24843
/*
/*
*
*
*
* video.cpp
* @file video.cpp
*
* 13th July 2009: Created graphics.cpp from parts of util.cpp
* 26th July 2009: Renamed graphics.cpp to video.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 13th July 2009: Created graphics.cpp from parts of util.cpp
* 26th July 2009: Renamed graphics.cpp to video.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -18,9 +19,7 @@
...
@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Contains graphics utility functions.
* Contains graphics utility functions.
*
*
*/
*/
...
@@ -152,7 +151,7 @@ bool Video::create (int width, int height) {
...
@@ -152,7 +151,7 @@ bool Video::create (int width, int height) {
gain.
gain.
b) the palette is emulated, there will be a HUGE speed loss.
b) the palette is emulated, there will be a HUGE speed loss.
Therefore, assume the palette is emulated. */
Therefore, assume the palette is emulated. */
//
TODO: Find a better way
//
/ @todo Find a better way to determine if palette is emulated
fakePalette
=
true
;
fakePalette
=
true
;
return
true
;
return
true
;
...
...
src/io/gfx/video.h
View file @
4da24843
/*
/*
*
*
*
* video.h
* @file video.h
*
* 13th July 2009: Created graphics.h from parts of OpenJazz.h
* 26th July 2009: Renamed graphics.h to video.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 13th July 2009: Created graphics.h from parts of OpenJazz.h
* 26th July 2009: Renamed graphics.h to video.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -53,22 +54,24 @@
...
@@ -53,22 +54,24 @@
// Class
// Class
/// Video output
class
Video
{
class
Video
{
private
:
private
:
SDL_Surface
*
screen
;
SDL_Surface
*
screen
;
///< Output surface
// Palettes
// Palettes
SDL_Color
*
currentPalette
;
SDL_Color
*
currentPalette
;
///< Current palette
SDL_Color
logicalPalette
[
256
];
SDL_Color
logicalPalette
[
256
];
///< Logical palette (greyscale)
bool
fakePalette
;
bool
fakePalette
;
///< Whether or not the palette mode is being emulated
int
screenW
,
screenH
;
int
screenW
;
///< Real width
int
screenH
;
///< Real height
#ifdef SCALE
#ifdef SCALE
int
scaleFactor
;
int
scaleFactor
;
///< Scaling factor
#endif
#endif
#ifndef FULLSCREEN_ONLY
#ifndef FULLSCREEN_ONLY
bool
fullscreen
;
bool
fullscreen
;
///< Full-screen mode
#endif
#endif
public
:
public
:
...
@@ -102,10 +105,11 @@ class Video {
...
@@ -102,10 +105,11 @@ class Video {
// Variables
// Variables
EXTERN
SDL_Surface
*
canvas
;
EXTERN
SDL_Surface
*
canvas
;
///< Surface used for drawing
EXTERN
int
canvasW
,
canvasH
;
EXTERN
int
canvasW
;
///< Drawing surface width
EXTERN
int
canvasH
;
///< Drawing surface height
EXTERN
Video
video
;
EXTERN
Video
video
;
///< Video output
// Functions
// Functions
...
...
src/io/network.cpp
View file @
4da24843
/*
/*
*
*
*
* network.cpp
* @file network.cpp
*
* 3rd June 2009: Created network.cpp from parts of game.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 3rd June 2009: Created network.cpp from parts of game.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -17,9 +18,7 @@
...
@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with a platform-specific networking API.
* Deals with a platform-specific networking API.
*
*
* On most platforms, USE_SOCKETS should be defined.
* On most platforms, USE_SOCKETS should be defined.
...
@@ -73,6 +72,7 @@ Network::Network () {
...
@@ -73,6 +72,7 @@ Network::Network () {
}
}
Network
::~
Network
()
{
Network
::~
Network
()
{
#ifdef USE_SOCKETS
#ifdef USE_SOCKETS
...
@@ -88,6 +88,7 @@ Network::~Network () {
...
@@ -88,6 +88,7 @@ Network::~Network () {
}
}
int
Network
::
host
()
{
int
Network
::
host
()
{
#ifdef USE_SOCKETS
#ifdef USE_SOCKETS
...
@@ -141,6 +142,7 @@ int Network::host () {
...
@@ -141,6 +142,7 @@ int Network::host () {
}
}
int
Network
::
join
(
char
*
address
)
{
int
Network
::
join
(
char
*
address
)
{
#ifdef USE_SOCKETS
#ifdef USE_SOCKETS
...
@@ -250,6 +252,7 @@ int Network::join (char *address) {
...
@@ -250,6 +252,7 @@ int Network::join (char *address) {
}
}
int
Network
::
accept
(
int
sock
)
{
int
Network
::
accept
(
int
sock
)
{
#ifdef USE_SOCKETS
#ifdef USE_SOCKETS
...
@@ -281,6 +284,7 @@ int Network::accept (int sock) {
...
@@ -281,6 +284,7 @@ int Network::accept (int sock) {
}
}
void
Network
::
close
(
int
sock
)
{
void
Network
::
close
(
int
sock
)
{
#ifdef USE_SOCKETS
#ifdef USE_SOCKETS
...
@@ -297,6 +301,7 @@ void Network::close (int sock) {
...
@@ -297,6 +301,7 @@ void Network::close (int sock) {
}
}
int
Network
::
send
(
int
sock
,
unsigned
char
*
buffer
)
{
int
Network
::
send
(
int
sock
,
unsigned
char
*
buffer
)
{
#ifdef USE_SOCKETS
#ifdef USE_SOCKETS
...
@@ -309,6 +314,7 @@ int Network::send (int sock, unsigned char *buffer) {
...
@@ -309,6 +314,7 @@ int Network::send (int sock, unsigned char *buffer) {
}
}
int
Network
::
recv
(
int
sock
,
unsigned
char
*
buffer
,
int
length
)
{
int
Network
::
recv
(
int
sock
,
unsigned
char
*
buffer
,
int
length
)
{
#ifdef USE_SOCKETS
#ifdef USE_SOCKETS
...
@@ -321,6 +327,7 @@ int Network::recv (int sock, unsigned char *buffer, int length) {
...
@@ -321,6 +327,7 @@ int Network::recv (int sock, unsigned char *buffer, int length) {
}
}
bool
Network
::
isConnected
(
int
sock
)
{
bool
Network
::
isConnected
(
int
sock
)
{
#ifdef USE_SOCKETS
#ifdef USE_SOCKETS
...
...
src/io/network.h
View file @
4da24843
/*
/*
*
*
*
* network.h
* @file network.h
*
* 3rd June 2009: Created network.h from parts of OpenJazz.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 3rd June 2009: Created network.h from parts of OpenJazz.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -48,6 +49,7 @@
...
@@ -48,6 +49,7 @@
// Class
// Class
/// Networking
class
Network
{
class
Network
{
public
:
public
:
...
@@ -75,7 +77,7 @@ class Network {
...
@@ -75,7 +77,7 @@ class Network {
// Variables
// Variables
EXTERN
char
*
netAddress
;
EXTERN
char
*
netAddress
;
/// Server address
EXTERN
Network
*
net
;
EXTERN
Network
*
net
;
#endif
#endif
...
...
src/io/sound.cpp
View file @
4da24843
/*
/*
*
*
*
* sound.cpp
* @file sound.cpp
*
* 23rd August 2005: Created sound.c
* 3rd February 2009: Renamed sound.c to sound.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 23rd August 2005: Created sound.c
* 3rd February 2009: Renamed sound.c to sound.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -18,9 +19,7 @@
...
@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the loading, playing and freeing of music and sound effects.
* Deals with the loading, playing and freeing of music and sound effects.
*
*
* For music, USE_MODPLUG must be defined.
* For music, USE_MODPLUG must be defined.
...
@@ -354,10 +353,11 @@ void freeSounds () {
...
@@ -354,10 +353,11 @@ void freeSounds () {
}
}
/**
* Set the sound to be played
*/
void
playSound
(
int
newSound
)
{
void
playSound
(
int
newSound
)
{
// Set the sound to be played
if
(
sounds
&&
(
newSound
>=
0
))
sounds
[
newSound
].
position
=
0
;
if
(
sounds
&&
(
newSound
>=
0
))
sounds
[
newSound
].
position
=
0
;
return
;
return
;
...
...
src/io/sound.h
View file @
4da24843
/*
/*
*
*
*
* sound.h
* @file sound.h
*
* 2nd June 2009: Created sound.h from parts of OpenJazz.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 2nd June 2009: Created sound.h from parts of OpenJazz.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -56,6 +57,7 @@
...
@@ -56,6 +57,7 @@
// Datatype
// Datatype
/// Sound effect
typedef
struct
{
typedef
struct
{
unsigned
char
*
data
;
unsigned
char
*
data
;
...
...
src/jj2level/jj2event/jj2event.cpp
View file @
4da24843
/*
/*
*
*
*
* jj2event.cpp
* @file jj2event.cpp
*
* 2nd July 2010: Created jj2event.cpp from parts of jj2level.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 2nd July 2010: Created jj2event.cpp from parts of jj2level.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -17,9 +18,7 @@
...
@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the creating and freeing of JJ2 events.
* Deals with the creating and freeing of JJ2 events.
*
*
*/
*/
...
...
src/jj2level/jj2event/jj2event.h
View file @
4da24843
/*
/*
*
*
*
* jj2event.h
* @file jj2event.h
*
* 2nd July 2010: Created jj2event.h from parts of jj2level.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 2nd July 2010: Created jj2event.h from parts of jj2level.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -31,6 +32,7 @@
...
@@ -31,6 +32,7 @@
class
Anim
;
class
Anim
;
/// JJ2 level "movable" event
class
JJ2Event
:
public
Movable
{
class
JJ2Event
:
public
Movable
{
private
:
private
:
...
@@ -39,8 +41,8 @@ class JJ2Event : public Movable {
...
@@ -39,8 +41,8 @@ class JJ2Event : public Movable {
protected
:
protected
:
unsigned
char
type
;
unsigned
char
type
;
int
properties
;
int
properties
;
unsigned
int
endTime
;
//
Point at which the event will terminate
unsigned
int
endTime
;
///<
Point at which the event will terminate
bool
flipped
;
bool
flipped
;
///< Whether or not the sprite image should be flipped
JJ2Event
(
JJ2Event
*
newNext
,
unsigned
char
gridX
,
unsigned
char
gridY
,
unsigned
char
newType
,
int
newProperties
);
JJ2Event
(
JJ2Event
*
newNext
,
unsigned
char
gridX
,
unsigned
char
gridY
,
unsigned
char
newType
,
int
newProperties
);
...
@@ -59,6 +61,7 @@ class JJ2Event : public Movable {
...
@@ -59,6 +61,7 @@ class JJ2Event : public Movable {
};
};
/// JJ2 level pickup event
class
PickupJJ2Event
:
public
JJ2Event
{
class
PickupJJ2Event
:
public
JJ2Event
{
private
:
private
:
...
@@ -72,6 +75,7 @@ class PickupJJ2Event : public JJ2Event {
...
@@ -72,6 +75,7 @@ class PickupJJ2Event : public JJ2Event {
};
};
/// JJ2 level ammo
class
AmmoJJ2Event
:
public
PickupJJ2Event
{
class
AmmoJJ2Event
:
public
PickupJJ2Event
{
public
:
public
:
...
@@ -82,6 +86,7 @@ class AmmoJJ2Event : public PickupJJ2Event {
...
@@ -82,6 +86,7 @@ class AmmoJJ2Event : public PickupJJ2Event {
};
};
/// JJ2 level gold/silver coin
class
CoinGemJJ2Event
:
public
PickupJJ2Event
{
class
CoinGemJJ2Event
:
public
PickupJJ2Event
{
private
:
private
:
...
@@ -95,6 +100,7 @@ class CoinGemJJ2Event : public PickupJJ2Event {
...
@@ -95,6 +100,7 @@ class CoinGemJJ2Event : public PickupJJ2Event {
};
};
/// JJ2 level food
class
FoodJJ2Event
:
public
PickupJJ2Event
{
class
FoodJJ2Event
:
public
PickupJJ2Event
{
public
:
public
:
...
@@ -105,6 +111,7 @@ class FoodJJ2Event : public PickupJJ2Event {
...
@@ -105,6 +111,7 @@ class FoodJJ2Event : public PickupJJ2Event {
};
};
/// Unimplemented JJ2 level event
class
OtherJJ2Event
:
public
JJ2Event
{
class
OtherJJ2Event
:
public
JJ2Event
{
public
:
public
:
...
...
src/jj2level/jj2event/jj2eventframe.cpp
View file @
4da24843
/*
/*
*
*
*
* jj2eventframe.cpp
* @file jj2eventframe.cpp
*
* 2nd July 2010: Created jj2eventframe.cpp from parts of jj2level.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 2nd July 2010: Created jj2eventframe.cpp from parts of jj2level.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -17,9 +18,7 @@
...
@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the playing of JJ2 levels.
* Deals with the playing of JJ2 levels.
*
*
*/
*/
...
@@ -34,7 +33,7 @@
...
@@ -34,7 +33,7 @@
#include "player/jj2levelplayer.h"
#include "player/jj2levelplayer.h"
// Look-up table for ammo animations (in animSet 1)
//
/
Look-up table for ammo animations (in animSet 1)
const
unsigned
char
ammoAnims
[]
=
{
const
unsigned
char
ammoAnims
[]
=
{
28
,
// Ice
28
,
// Ice
24
,
// Bouncer
24
,
// Bouncer
...
@@ -46,7 +45,7 @@ const unsigned char ammoAnims[] = {
...
@@ -46,7 +45,7 @@ const unsigned char ammoAnims[] = {
67
// Sparks
67
// Sparks
};
};
// Look-up table for food etc. animations (in animSet 67)
//
/
Look-up table for food etc. animations (in animSet 67)
const
unsigned
char
pickupAnims
[]
=
{
const
unsigned
char
pickupAnims
[]
=
{
0
,
// 0
0
,
// 0
0
,
// 1
0
,
// 1
...
@@ -347,7 +346,7 @@ JJ2Event* PickupJJ2Event::step (unsigned int ticks, int msps) {
...
@@ -347,7 +346,7 @@ JJ2Event* PickupJJ2Event::step (unsigned int ticks, int msps) {
}
else
{
}
else
{
//
TODO:
Check for bullet overlap
//
/ @todo
Check for bullet overlap
// floating = false;
// floating = false;
}
}
...
@@ -367,7 +366,7 @@ void AmmoJJ2Event::draw (unsigned int ticks, int change) {
...
@@ -367,7 +366,7 @@ void AmmoJJ2Event::draw (unsigned int ticks, int change) {
drawX
=
getDrawX
(
change
);
drawX
=
getDrawX
(
change
);
drawY
=
getDrawY
(
change
);
drawY
=
getDrawY
(
change
);
//
TODO:
Check if ammo is powered up
//
/ @todo
Check if ammo is powered up
if
(
!
endTime
)
an
=
jj2Level
->
getAnim
(
0
,
ammoAnims
[
type
-
33
]
+
1
,
flipped
);
if
(
!
endTime
)
an
=
jj2Level
->
getAnim
(
0
,
ammoAnims
[
type
-
33
]
+
1
,
flipped
);
else
an
=
jj2Level
->
getAnim
(
67
,
86
,
flipped
);
else
an
=
jj2Level
->
getAnim
(
67
,
86
,
flipped
);
...
...
src/jj2level/jj2layer.cpp
View file @
4da24843
/*
/*
*
*
*
* jj2layer.cpp
* @file jj2layer.cpp
*
* 30th June 2010: Created jj2layer.cpp from parts of jj2levelframe.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 30th June 2010: Created jj2layer.cpp from parts of jj2levelframe.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -17,9 +18,7 @@
...
@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Handles JJ2 level layers.
* Handles JJ2 level layers.
*
*
*/
*/
...
@@ -30,10 +29,11 @@
...
@@ -30,10 +29,11 @@
#include "io/gfx/video.h"
#include "io/gfx/video.h"
/**
* Create a blank layer
*/
JJ2Layer
::
JJ2Layer
()
{
JJ2Layer
::
JJ2Layer
()
{
// Create a blank layer
width
=
height
=
1
;
width
=
height
=
1
;
grid
=
new
JJ2Tile
*
[
1
];
grid
=
new
JJ2Tile
*
[
1
];
...
@@ -78,10 +78,11 @@ JJ2Layer::~JJ2Layer () {
...
@@ -78,10 +78,11 @@ JJ2Layer::~JJ2Layer () {
}
}
/**
* Get flipped. We aim to offend!
*/
bool
JJ2Layer
::
getFlipped
(
int
x
,
int
y
)
{
bool
JJ2Layer
::
getFlipped
(
int
x
,
int
y
)
{
// Get flipped. We aim to offend!
if
((
x
<
0
)
||
(
y
<
0
)
||
(
x
>=
width
)
||
(
y
>=
height
))
return
false
;
if
((
x
<
0
)
||
(
y
<
0
)
||
(
x
>=
width
)
||
(
y
>=
height
))
return
false
;
return
grid
[
y
][
x
].
flipped
;
return
grid
[
y
][
x
].
flipped
;
...
...
src/jj2level/jj2level.cpp
View file @
4da24843
/*
/*
*
*
*
* jj2level.cpp
*
@file
jj2level.cpp
*
*
* Part of the OpenJazz project
*
* @section History
* 29th June 2010: Created jj2level.cpp from parts of level.cpp
* 29th June 2010: Created jj2level.cpp from parts of level.cpp
* 2nd July 2010: Created jj2event.cpp from parts of jj2level.cpp
* 2nd July 2010: Created jj2event.cpp from parts of jj2level.cpp
* 2nd July 2010: Created jj2eventframe.cpp from parts of jj2level.cpp
* 2nd July 2010: Created jj2eventframe.cpp from parts of jj2level.cpp
*
*
* Part of the OpenJazz project
* @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -19,9 +20,7 @@
...
@@ -19,9 +20,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the creating, playing and freeing of JJ2 levels.
* Deals with the creating, playing and freeing of JJ2 levels.
*
*
*/
*/
...
@@ -269,10 +268,13 @@ void JJ2Level::warp (JJ2LevelPlayer *player, int id) {
...
@@ -269,10 +268,13 @@ void JJ2Level::warp (JJ2LevelPlayer *player, int id) {
}
}
/**
* Interpret data received from client/server
*
* @param buffer Received data
*/
void
JJ2Level
::
receive
(
unsigned
char
*
buffer
)
{
void
JJ2Level
::
receive
(
unsigned
char
*
buffer
)
{
// Interpret data received from client/server
switch
(
buffer
[
1
])
{
switch
(
buffer
[
1
])
{
case
MT_L_PROP
:
case
MT_L_PROP
:
...
...
src/jj2level/jj2level.h
View file @
4da24843
/*
/*
*
*
*
* jj2level.h
* @file jj2level.h
*
* 29th June 2010: Created jj2level.h from parts of level.h
* 2nd July 2010: Created jj2event.h from parts of jj2level.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 29th June 2010: Created jj2level.h from parts of level.h
* 2nd July 2010: Created jj2event.h from parts of jj2level.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -48,14 +49,16 @@
...
@@ -48,14 +49,16 @@
// Datatypes
// Datatypes
/// JJ2 level tile
typedef
struct
{
typedef
struct
{
unsigned
short
int
tile
;
//
Indexes the tile set
unsigned
short
int
tile
;
///<
Indexes the tile set
unsigned
char
frame
;
//
Current frame being used (for animated tiles)
unsigned
char
frame
;
///<
Current frame being used (for animated tiles)
bool
flipped
;
bool
flipped
;
///< Whether or not the tile image and mask are flipped
}
JJ2Tile
;
}
JJ2Tile
;
/// JJ2 level tile modifier event
typedef
struct
{
typedef
struct
{
unsigned
char
type
;
unsigned
char
type
;
...
@@ -68,12 +71,17 @@ typedef struct {
...
@@ -68,12 +71,17 @@ typedef struct {
class
Font
;
class
Font
;
///< JJ2 level parallaxing layer
class
JJ2Layer
{
class
JJ2Layer
{
private
:
private
:
JJ2Tile
**
grid
;
JJ2Tile
**
grid
;
///< Layer tiles
int
width
,
height
;
int
width
;
///< Width (in tiles)
bool
tileX
,
tileY
,
limit
,
warp
;
int
height
;
///< Height (in tiles)
bool
tileX
;
///< Repeat horizontally
bool
tileY
;
///< Repeat vertically
bool
limit
;
///< Do not view beyond edges
bool
warp
;
///< Warp effect
public
:
public
:
JJ2Layer
();
JJ2Layer
();
...
@@ -94,30 +102,31 @@ class JJ2Layer {
...
@@ -94,30 +102,31 @@ class JJ2Layer {
class
JJ2Event
;
class
JJ2Event
;
class
JJ2LevelPlayer
;
class
JJ2LevelPlayer
;
/// JJ2 level
class
JJ2Level
:
public
BaseLevel
{
class
JJ2Level
:
public
BaseLevel
{
private
:
private
:
SDL_Surface
*
tileSet
;
SDL_Surface
*
tileSet
;
///< Tile images
SDL_Surface
*
flippedTileSet
;
SDL_Surface
*
flippedTileSet
;
///< Tile images (flipped)
JJ2Event
*
events
;
JJ2Event
*
events
;
///< "Movable" events
Font
*
font
;
Font
*
font
;
///< On-screen message font
char
*
mask
;
char
*
mask
;
///< Tile masks
char
*
flippedMask
;
char
*
flippedMask
;
///< Tile masks (flipped)
char
*
musicFile
;
char
*
musicFile
;
///< Music file name
char
*
nextLevel
;
char
*
nextLevel
;
///< Next level file name
Sprite
*
spriteSet
;
Sprite
*
spriteSet
;
///< Sprite images
Sprite
*
flippedSpriteSet
;
Sprite
*
flippedSpriteSet
;
///< Sprite images (flipped)
Anim
**
animSets
;
Anim
**
animSets
;
///< Animation sets
Anim
**
flippedAnimSets
;
Anim
**
flippedAnimSets
;
///< Animation sets (flipped)
JJ2Layer
*
layers
[
LAYERS
];
JJ2Layer
*
layers
[
LAYERS
];
///< All layers
JJ2Layer
*
layer
;
JJ2Layer
*
layer
;
///< Layer 4
JJ2Modifier
**
mods
;
JJ2Modifier
**
mods
;
///< Modifier events for each tile in layer 4
int
nAnimSets
;
int
nAnimSets
;
///< Number of animation sets
bool
TSF
;
bool
TSF
;
///< 1.24 level
unsigned
char
difficulty
;
unsigned
char
difficulty
;
///< Difficulty setting (0 = easy, 1 = medium, 2 or 3 = hard)
fixed
waterLevel
;
fixed
waterLevel
;
///< Height of water
fixed
waterLevelTarget
;
fixed
waterLevelTarget
;
///< Future height of water
fixed
waterLevelSpeed
;
fixed
waterLevelSpeed
;
///< Rate of water level change
void
createEvent
(
int
x
,
int
y
,
unsigned
char
*
data
);
void
createEvent
(
int
x
,
int
y
,
unsigned
char
*
data
);
int
load
(
char
*
fileName
,
unsigned
char
diff
,
bool
checkpoint
);
int
load
(
char
*
fileName
,
unsigned
char
diff
,
bool
checkpoint
);
...
@@ -152,7 +161,7 @@ class JJ2Level : public BaseLevel {
...
@@ -152,7 +161,7 @@ class JJ2Level : public BaseLevel {
// Variable
// Variable
EXTERN
JJ2Level
*
jj2Level
;
EXTERN
JJ2Level
*
jj2Level
;
//< JJ2 level
#endif
#endif
src/jj2level/jj2levelframe.cpp
View file @
4da24843
/*
/*
*
*
*
* jj2levelframe.cpp
* @file jj2levelframe.cpp
*
* 29th June 2010: Created jj2levelframe.cpp from parts of levelframe.cpp
* 30th June 2010: Created jj2layer.cpp from parts of jj2levelframe.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 29th June 2010: Created jj2levelframe.cpp from parts of levelframe.cpp
* 30th June 2010: Created jj2layer.cpp from parts of jj2levelframe.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -18,9 +19,7 @@
...
@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Provides the once-per-frame functions for levels.
* Provides the once-per-frame functions for levels.
*
*
*/
*/
...
...
src/jj2level/jj2levelload.cpp
View file @
4da24843
/*
/*
*
*
*
* levelloadjj2.cpp
* @file jj2levelload.cpp
*
* 28th June 2010: Created levelloadjj2.cpp from parts of levelload.cpp
* 29th June 2010: Renamed levelloadjj2.cpp to jj2levelload.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 28th June 2010: Created levelloadjj2.cpp from parts of levelload.cpp
* 29th June 2010: Renamed levelloadjj2.cpp to jj2levelload.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -18,9 +19,7 @@
...
@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the loading of JJ2 level data.
* Deals with the loading of JJ2 level data.
*
*
*/
*/
...
...
src/level/bullet.cpp
View file @
4da24843
/*
/*
*
*
*
* bullet.cpp
* @file bullet.cpp
*
* 11th February 2009: Created bullet.cpp from parts of events.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 11th February 2009: Created bullet.cpp from parts of events.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
...
src/level/bullet.h
View file @
4da24843
/*
/*
*
*
*
* bullet.h
* @file bullet.h
*
* 11th February 2009: Created bullet.h from parts of events.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 11th February 2009: Created bullet.h from parts of events.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -54,15 +55,16 @@ class Event;
...
@@ -54,15 +55,16 @@ class Event;
class
LevelPlayer
;
class
LevelPlayer
;
class
Sprite
;
class
Sprite
;
/// Bullet
class
Bullet
:
public
Movable
{
class
Bullet
:
public
Movable
{
private
:
private
:
Bullet
*
next
;
Bullet
*
next
;
LevelPlayer
*
source
;
//
If NULL, was fired by an event
LevelPlayer
*
source
;
///< Source player.
If NULL, was fired by an event
Sprite
*
sprite
;
Sprite
*
sprite
;
///< Sprite
int
type
;
//
-1 is TNT, otherwise indexes the bullet set
int
type
;
///<
-1 is TNT, otherwise indexes the bullet set
int
direction
;
// 0: Left, 1: Right, 2: L (lower), 3: R (lower)
int
direction
;
//
/<
0: Left, 1: Right, 2: L (lower), 3: R (lower)
unsigned
int
time
;
//
Time at which the bullet will self-destruct
unsigned
int
time
;
///<
Time at which the bullet will self-destruct
Bullet
*
remove
();
Bullet
*
remove
();
...
...
src/level/demolevel.cpp
View file @
4da24843
/*
/*
*
*
*
* demolevel.cpp
* @file demolevel.cpp
*
* 18th July 2009: Created demolevel.cpp from parts of level.cpp and
* levelload.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 18th July 2009: Created demolevel.cpp from parts of level.cpp and
* levelload.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -18,9 +19,7 @@
...
@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the loading and playing of demo levels.
* Deals with the loading and playing of demo levels.
*
*
*/
*/
...
...
src/level/event/bridge.cpp
View file @
4da24843
/*
/*
*
*
*
* bridge.cpp
* @file bridge.cpp
*
* 2nd March 2010: Created bridge.cpp from parts of event.cpp and eventframe.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 2nd March 2010: Created bridge.cpp from parts of event.cpp and eventframe.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -17,9 +18,7 @@
...
@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Provides the functions of bridge events.
* Provides the functions of bridge events.
*
*
*/
*/
...
...
src/level/event/event.cpp
View file @
4da24843
/*
/*
*
*
*
* event.cpp
*
@file
event.cpp
*
*
* Part of the OpenJazz project
*
* @section History
* 1st January 2006: Created events.c from parts of level.c
* 1st January 2006: Created events.c from parts of level.c
* 3rd February 2009: Renamed events.c to events.cpp
* 3rd February 2009: Renamed events.c to events.cpp
* 5th February 2009: Added parts of events.cpp and level.cpp to player.cpp
* 5th February 2009: Added parts of events.cpp and level.cpp to player.cpp
...
@@ -14,9 +17,7 @@
...
@@ -14,9 +17,7 @@
* 2nd March 2010: Created guardians.cpp from parts of event.cpp and eventframe.cpp
* 2nd March 2010: Created guardians.cpp from parts of event.cpp and eventframe.cpp
* 2nd March 2010: Created bridge.cpp from parts of event.cpp and eventframe.cpp
* 2nd March 2010: Created bridge.cpp from parts of event.cpp and eventframe.cpp
*
*
* Part of the OpenJazz project
* @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -26,9 +27,7 @@
...
@@ -26,9 +27,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with events in ordinary levels.
* Deals with events in ordinary levels.
*
*
*/
*/
...
@@ -158,12 +157,18 @@ void Event::destroy (unsigned int ticks) {
...
@@ -158,12 +157,18 @@ void Event::destroy (unsigned int ticks) {
}
}
/**
* Deal with bullet collisions
*
* @param source Source of the bullet
* @param ticks Current time
*
* @return Whether or not the hit was successful
*/
bool
Event
::
hit
(
LevelPlayer
*
source
,
unsigned
int
ticks
)
{
bool
Event
::
hit
(
LevelPlayer
*
source
,
unsigned
int
ticks
)
{
int
hitsRemaining
;
int
hitsRemaining
;
// Deal with bullet collisions
// Check if event has already been destroyed
// Check if event has already been destroyed
if
((
animType
==
E_LFINISHANIM
)
||
(
animType
==
E_RFINISHANIM
)
||
if
((
animType
==
E_LFINISHANIM
)
||
(
animType
==
E_RFINISHANIM
)
||
(
ticks
<
flashTime
))
return
false
;
(
ticks
<
flashTime
))
return
false
;
...
...
src/level/event/event.h
View file @
4da24843
/*
/*
*
*
*
* event.h
*
@file
event.h
*
*
* Part of the OpenJazz project
*
* @section History
* 4th February 2009: Created events.h from parts of level.h
* 4th February 2009: Created events.h from parts of level.h
* 11th February 2009: Created bullet.h from parts of events.h
* 11th February 2009: Created bullet.h from parts of events.h
* 1st March 2009: Created bird.h from parts of events.h
* 1st March 2009: Created bird.h from parts of events.h
* 19th July 2009: Renamed events.h to event.h
* 19th July 2009: Renamed events.h to event.h
* 2nd March 2010: Created guardians.h from parts of event.h
* 2nd March 2010: Created guardians.h from parts of event.h
*
*
* Part of the OpenJazz project
* @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -79,14 +80,15 @@
...
@@ -79,14 +80,15 @@
class
LevelPlayer
;
class
LevelPlayer
;
/// JJ1 level event
class
Event
:
public
Movable
{
class
Event
:
public
Movable
{
protected
:
protected
:
Event
*
next
;
Event
*
next
;
unsigned
char
gridX
,
gridY
;
// Grid position of the event
unsigned
char
gridX
,
gridY
;
//
/<
Grid position of the event
unsigned
char
animType
;
//
E_LEFTANIM, etc, or 0
unsigned
char
animType
;
///<
E_LEFTANIM, etc, or 0
unsigned
char
frame
;
unsigned
char
frame
;
///< Current animation frame
unsigned
int
flashTime
;
unsigned
int
flashTime
;
///< Time flash will end
bool
noAnimOffset
;
bool
noAnimOffset
;
bool
onlyLAnimOffset
;
bool
onlyLAnimOffset
;
bool
onlyRAnimOffset
;
bool
onlyRAnimOffset
;
...
@@ -119,6 +121,7 @@ class Event : public Movable {
...
@@ -119,6 +121,7 @@ class Event : public Movable {
};
};
/// JJ1 level bridge
class
Bridge
:
public
Event
{
class
Bridge
:
public
Event
{
private
:
private
:
...
...
src/level/event/eventframe.cpp
View file @
4da24843
/*
/*
*
*
*
* eventframe.cpp
*
@file
eventframe.cpp
*
*
* Part of the OpenJazz project
*
* @section History
* 19th July 2009: Created eventframe.cpp from parts of events.cpp
* 19th July 2009: Created eventframe.cpp from parts of events.cpp
* 2nd March 2010: Created guardians.cpp from parts of event.cpp and eventframe.cpp
* 2nd March 2010: Created guardians.cpp from parts of event.cpp and eventframe.cpp
* 2nd March 2010: Created bridge.cpp from parts of event.cpp and eventframe.cpp
* 2nd March 2010: Created bridge.cpp from parts of event.cpp and eventframe.cpp
*
*
* Part of the OpenJazz project
* @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -19,9 +20,7 @@
...
@@ -19,9 +20,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Provides the once-per-frame functions of ordinary events.
* Provides the once-per-frame functions of ordinary events.
*
*
*/
*/
...
@@ -155,7 +154,7 @@ Event* Event::step (unsigned int ticks, int msps) {
...
@@ -155,7 +154,7 @@ Event* Event::step (unsigned int ticks, int msps) {
case
5
:
case
5
:
//
TODO: Find out what this
is
//
/ @todo Find out what behaviour 5
is
break
;
break
;
...
@@ -182,19 +181,19 @@ Event* Event::step (unsigned int ticks, int msps) {
...
@@ -182,19 +181,19 @@ Event* Event::step (unsigned int ticks, int msps) {
case
8
:
case
8
:
//
TODO:
Bird-esque following
//
/ @todo
Bird-esque following
break
;
break
;
case
9
:
case
9
:
//
TODO: Find out what this
is
//
/ @todo Find out what behaviour 9
is
break
;
break
;
case
10
:
case
10
:
//
TODO: Find out what this
is
//
/ @todo Find out what behaviour 10
is
break
;
break
;
...
@@ -226,13 +225,13 @@ Event* Event::step (unsigned int ticks, int msps) {
...
@@ -226,13 +225,13 @@ Event* Event::step (unsigned int ticks, int msps) {
case
14
:
case
14
:
//
TODO:
Move back and forth rapidly
//
/ @todo
Move back and forth rapidly
break
;
break
;
case
15
:
case
15
:
//
TODO:
Rise or lower to meet jazz
//
/ @todo
Rise or lower to meet jazz
break
;
break
;
...
@@ -246,25 +245,25 @@ Event* Event::step (unsigned int ticks, int msps) {
...
@@ -246,25 +245,25 @@ Event* Event::step (unsigned int ticks, int msps) {
case
17
:
case
17
:
//
TODO: Find out what this
is
//
/ @todo Find out what behaviour 17
is
break
;
break
;
case
18
:
case
18
:
//
TODO: Find out what this
is
//
/ @todo Find out what behaviour 18
is
break
;
break
;
case
19
:
case
19
:
//
TODO: Find out what this
is
//
/ @todo Find out what behaviour 19
is
break
;
break
;
case
20
:
case
20
:
//
TODO: Find out what this
is
//
/ @todo Find out what behaviour 20
is
break
;
break
;
...
@@ -278,31 +277,31 @@ Event* Event::step (unsigned int ticks, int msps) {
...
@@ -278,31 +277,31 @@ Event* Event::step (unsigned int ticks, int msps) {
case
22
:
case
22
:
//
TODO:
Fall down in random spot and repeat
//
/ @todo
Fall down in random spot and repeat
break
;
break
;
case
23
:
case
23
:
//
TODO: Find out what this
is
//
/ @todo Find out what behaviour 23
is
break
;
break
;
case
24
:
case
24
:
//
TODO:
Crawl along ground and go downstairs
//
/ @todo
Crawl along ground and go downstairs
break
;
break
;
case
26
:
case
26
:
//
TODO: Find out what this
is
//
/ @todo Find out what behaviour 26
is
break
;
break
;
case
27
:
case
27
:
//
TODO:
Face jazz
//
/ @todo
Face jazz
break
;
break
;
...
@@ -467,49 +466,49 @@ Event* Event::step (unsigned int ticks, int msps) {
...
@@ -467,49 +466,49 @@ Event* Event::step (unsigned int ticks, int msps) {
case
39
:
case
39
:
//
TODO:
Collapsing floor
//
/ @todo
Collapsing floor
break
;
break
;
case
40
:
case
40
:
//
TODO: Find out what this
is
//
/ @todo Find out what behaviour 40
is
break
;
break
;
case
41
:
case
41
:
//
TODO:
Switch left & right anim periodically
//
/ @todo
Switch left & right anim periodically
break
;
break
;
case
42
:
case
42
:
//
TODO: Find out what this
is
//
/ @todo Find out what behaviour 42
is
break
;
break
;
case
43
:
case
43
:
//
TODO: Find out what this
is
//
/ @todo Find out what behaviour 43
is
break
;
break
;
case
44
:
case
44
:
//
TODO:
Leap to greet Jazz very quickly
//
/ @todo
Leap to greet Jazz very quickly
break
;
break
;
case
45
:
case
45
:
//
TODO: Find out what this
is
//
/ @todo Find out what behaviour 45
is
break
;
break
;
case
46
:
case
46
:
//
TODO:
"Final" boss
//
/ @todo
"Final" boss
break
;
break
;
...
@@ -533,7 +532,7 @@ Event* Event::step (unsigned int ticks, int msps) {
...
@@ -533,7 +532,7 @@ Event* Event::step (unsigned int ticks, int msps) {
// 0: Static
// 0: Static
// 25: Float up / Belt
// 25: Float up / Belt
//
TODO:
Remaining event behaviours
//
/ @todo
Remaining event behaviours
break
;
break
;
...
...
src/level/event/guardians.cpp
View file @
4da24843
/*
/*
*
*
*
* guardians.cpp
* @file guardians.cpp
*
* 2nd March 2010: Created guardians.cpp from parts of event.cpp and eventframe.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 2nd March 2010: Created guardians.cpp from parts of event.cpp and eventframe.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -17,9 +18,7 @@
...
@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Provides the functions of guardian events.
* Provides the functions of guardian events.
*
*
*/
*/
...
...
src/level/event/guardians.h
View file @
4da24843
/*
/*
*
*
*
* guardians.h
* @file guardians.h
*
* 2nd March 2010: Created guardians.h from parts of event.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 2nd March 2010: Created guardians.h from parts of event.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -29,7 +30,7 @@
...
@@ -29,7 +30,7 @@
// Class
// Class
/// Guardian event base class
class
Guardian
:
public
Event
{
class
Guardian
:
public
Event
{
protected
:
protected
:
...
@@ -40,7 +41,7 @@ class Guardian : public Event {
...
@@ -40,7 +41,7 @@ class Guardian : public Event {
};
};
/// Episode B guardian
class
DeckGuardian
:
public
Guardian
{
class
DeckGuardian
:
public
Guardian
{
public
:
public
:
...
@@ -52,7 +53,7 @@ class DeckGuardian : public Guardian {
...
@@ -52,7 +53,7 @@ class DeckGuardian : public Guardian {
};
};
/// Episode 1 guardian
class
MedGuardian
:
public
Guardian
{
class
MedGuardian
:
public
Guardian
{
private
:
private
:
...
...
src/level/level.cpp
View file @
4da24843
/*
/*
*
*
*
* level.cpp
*
@file
level.cpp
*
*
* Part of the OpenJazz project
*
* @section History
* 23rd August 2005: Created level.c
* 23rd August 2005: Created level.c
* 1st January 2006: Created events.c from parts of level.c
* 1st January 2006: Created events.c from parts of level.c
* 22nd July 2008: Created levelload.c from parts of level.c
* 22nd July 2008: Created levelload.c from parts of level.c
...
@@ -17,9 +20,7 @@
...
@@ -17,9 +20,7 @@
* levelframe.cpp
* levelframe.cpp
* 29th June 2010: Created jj2level.cpp from parts of level.cpp
* 29th June 2010: Created jj2level.cpp from parts of level.cpp
*
*
* Part of the OpenJazz project
* @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -29,9 +30,7 @@
...
@@ -29,9 +30,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the creating, playing and freeing of levels.
* Deals with the creating, playing and freeing of levels.
*
*
*/
*/
...
@@ -468,10 +467,13 @@ int Level::playBonus () {
...
@@ -468,10 +467,13 @@ int Level::playBonus () {
}
}
/**
* Interpret data received from client/server
*
* @param buffer Received data
*/
void
Level
::
receive
(
unsigned
char
*
buffer
)
{
void
Level
::
receive
(
unsigned
char
*
buffer
)
{
// Interpret data received from client/server
switch
(
buffer
[
1
])
{
switch
(
buffer
[
1
])
{
case
MT_L_PROP
:
case
MT_L_PROP
:
...
...
src/level/level.h
View file @
4da24843
/*
/*
*
*
*
* level.h
*
@file
level.h
*
*
* Part of the OpenJazz project
*
* @section History
* 31st January 2006: Created level.h from parts of OpenJazz.h
* 31st January 2006: Created level.h from parts of OpenJazz.h
* 4th February 2009: Created events.h from parts of level.h
* 4th February 2009: Created events.h from parts of level.h
* 19th March 2009: Created sprite.h from parts of level.h
* 19th March 2009: Created sprite.h from parts of level.h
* 30th March 2010: Created baselevel.h from parts of level.h
* 30th March 2010: Created baselevel.h from parts of level.h
* 29th June 2010: Created jj2level.h from parts of level.h
* 29th June 2010: Created jj2level.h from parts of level.h
*
*
* Part of the OpenJazz project
* @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -63,22 +64,24 @@
...
@@ -63,22 +64,24 @@
// Datatypes
// Datatypes
/// JJ1 level grid element
typedef
struct
{
typedef
struct
{
unsigned
char
tile
;
//
Indexes the tile set
unsigned
char
tile
;
///<
Indexes the tile set
unsigned
char
bg
;
//
0 = Effect background, 1 = Black background
unsigned
char
bg
;
///<
0 = Effect background, 1 = Black background
unsigned
char
event
;
// Indexes the event set
unsigned
char
event
;
//
/<
Indexes the event set
unsigned
char
hits
;
//
Number of times the event has been shot
unsigned
char
hits
;
///<
Number of times the event has been shot
int
time
;
/* Point at which the event will do something, e.g. terminate */
int
time
;
///< Point at which the event will do something, e.g. terminate
}
GridElement
;
}
GridElement
;
/// Pre-defined JJ1 event movement path
typedef
struct
{
typedef
struct
{
short
int
*
x
;
short
int
*
x
;
///< X-coordinates for each node
short
int
*
y
;
short
int
*
y
;
///< Y-coordinates for each node
unsigned
char
length
;
unsigned
char
length
;
///< Number of nodes
unsigned
char
node
;
unsigned
char
node
;
///< Current node
}
EventPath
;
}
EventPath
;
...
@@ -91,33 +94,37 @@ class Font;
...
@@ -91,33 +94,37 @@ class Font;
class
LevelPlayer
;
class
LevelPlayer
;
class
Scene
;
class
Scene
;
/// JJ1 level
class
Level
:
public
BaseLevel
{
class
Level
:
public
BaseLevel
{
private
:
private
:
SDL_Surface
*
tileSet
;
SDL_Surface
*
tileSet
;
///< Tile images
SDL_Surface
*
panel
;
SDL_Surface
*
panel
;
///< HUD background image
SDL_Surface
*
panelAmmo
[
5
];
SDL_Surface
*
panelAmmo
[
5
];
///< HUD ammo type images
Event
*
events
;
Event
*
events
;
///< Events
char
*
musicFile
;
char
*
musicFile
;
///< Music file name
char
*
sceneFile
;
char
*
sceneFile
;
///< File name of cutscene to play when level has been completed
Sprite
*
spriteSet
;
Sprite
*
spriteSet
;
///< Sprites
Anim
animSet
[
ANIMS
];
Anim
animSet
[
ANIMS
];
///< Animations
char
miscAnims
[
4
];
char
miscAnims
[
4
];
///< Further animations
signed
char
bulletSet
[
BULLETS
][
BLENGTH
];
signed
char
bulletSet
[
BULLETS
][
BLENGTH
];
///< Bullet types
signed
char
eventSet
[
EVENTS
][
ELENGTH
];
signed
char
eventSet
[
EVENTS
][
ELENGTH
];
///< Event types
char
mask
[
240
][
64
];
// At most 240 tiles, all with 8 * 8 masks
char
mask
[
240
][
64
];
///< Tile masks. At most 240 tiles, all with 8 * 8 masks
GridElement
grid
[
LH
][
LW
];
// All levels are the same size
GridElement
grid
[
LH
][
LW
];
///< Level grid. All levels are the same size
int
soundMap
[
32
];
int
soundMap
[
32
];
///< Maps event sound effect numbers to actual sound effect indices
SDL_Color
skyPalette
[
256
];
SDL_Color
skyPalette
[
256
];
///< Full palette for sky background
bool
sky
;
bool
sky
;
///< Whether or not to use sky background
unsigned
char
skyOrb
;
unsigned
char
skyOrb
;
///< The tile to use as the background sun/moon/etc.
int
levelNum
,
worldNum
,
nextLevelNum
,
nextWorldNum
;
int
levelNum
;
///<
unsigned
char
difficulty
;
int
worldNum
;
///<
int
enemies
;
int
nextLevelNum
;
///<
fixed
waterLevel
;
int
nextWorldNum
;
///<
fixed
waterLevelTarget
;
unsigned
char
difficulty
;
///< Difficulty setting (0 = easy, 1 = medium, 2 = hard, 3 = turbo)
fixed
waterLevelSpeed
;
int
enemies
;
///< Number of enemies to kill
fixed
energyBar
;
fixed
waterLevel
;
///< Height of water
fixed
waterLevelTarget
;
///< Future height of water
fixed
waterLevelSpeed
;
///< Rate of water level change
fixed
energyBar
;
///< HUD energy bar fullness
void
deletePanel
();
void
deletePanel
();
int
loadPanel
();
int
loadPanel
();
...
@@ -127,15 +134,15 @@ class Level : public BaseLevel {
...
@@ -127,15 +134,15 @@ class Level : public BaseLevel {
int
playBonus
();
int
playBonus
();
protected
:
protected
:
Font
*
font
;
Font
*
font
;
///< On-screen message font
int
load
(
char
*
fileName
,
unsigned
char
diff
,
bool
checkpoint
);
int
load
(
char
*
fileName
,
unsigned
char
diff
,
bool
checkpoint
);
int
step
();
int
step
();
void
draw
();
void
draw
();
public
:
public
:
Bullet
*
bullets
;
Bullet
*
bullets
;
///< Active bullets
EventPath
path
[
PATHS
];
EventPath
path
[
PATHS
];
///< Pre-defined event movement paths
Level
();
Level
();
Level
(
char
*
fileName
,
unsigned
char
diff
,
bool
checkpoint
,
bool
multi
);
Level
(
char
*
fileName
,
unsigned
char
diff
,
bool
checkpoint
,
bool
multi
);
...
@@ -167,11 +174,11 @@ class Level : public BaseLevel {
...
@@ -167,11 +174,11 @@ class Level : public BaseLevel {
};
};
/// JJ1 level played as a demo
class
DemoLevel
:
public
Level
{
class
DemoLevel
:
public
Level
{
private
:
private
:
unsigned
char
*
macro
;
unsigned
char
*
macro
;
///< Sequence of player control codes
public
:
public
:
DemoLevel
(
const
char
*
fileName
);
DemoLevel
(
const
char
*
fileName
);
...
@@ -184,9 +191,9 @@ class DemoLevel : public Level {
...
@@ -184,9 +191,9 @@ class DemoLevel : public Level {
// Variables
// Variables
EXTERN
Level
*
level
;
EXTERN
Level
*
level
;
///< JJ1 level
EXTERN
int
viewH
;
EXTERN
int
viewH
;
///< Canvas height, minus 33 if the panel obscures the whole of the bottom of the canvas
#define viewW canvasW
#define viewW canvasW
#endif
#endif
...
...
src/level/levelframe.cpp
View file @
4da24843
/*
/*
*
*
*
* levelframe.cpp
* @file levelframe.cpp
*
* Part of the OpenJazz project
*
*
* @section History
* 19th July 2009: Created levelframe.cpp from parts of level.cpp
* 19th July 2009: Created levelframe.cpp from parts of level.cpp
* 30th March 2010: Created baselevel.cpp from parts of level.cpp and
* 30th March 2010: Created baselevel.cpp from parts of level.cpp and
* levelframe.cpp
* levelframe.cpp
* 29th June 2010: Created jj2levelframe.cpp from parts of levelframe.cpp
* 29th June 2010: Created jj2levelframe.cpp from parts of levelframe.cpp
*
*
* Part of the OpenJazz project
* @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -20,9 +21,7 @@
...
@@ -20,9 +21,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Provides the once-per-frame functions for levels.
* Provides the once-per-frame functions for levels.
*
*
*/
*/
...
...
src/level/levelload.cpp
View file @
4da24843
/*
/*
*
*
*
* levelload.cpp
* @file levelload.cpp
*
* Part of the OpenJazz project
*
*
* @section History
* 22nd July 2008: Created levelload.c from parts of level.c
* 22nd July 2008: Created levelload.c from parts of level.c
* 3rd February 2009: Renamed levelload.c to levelload.cpp
* 3rd February 2009: Renamed levelload.c to levelload.cpp
* 18th July 2009: Created demolevel.cpp from parts of level.cpp and
* 18th July 2009: Created demolevel.cpp from parts of level.cpp and
...
@@ -10,9 +13,7 @@
...
@@ -10,9 +13,7 @@
* 19th July 2009: Added parts of levelload.cpp to level.cpp
* 19th July 2009: Added parts of levelload.cpp to level.cpp
* 28th June 2010: Created levelloadjj2.cpp from parts of levelload.cpp
* 28th June 2010: Created levelloadjj2.cpp from parts of levelload.cpp
*
*
* Part of the OpenJazz project
* @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -22,9 +23,7 @@
...
@@ -22,9 +23,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the loading of level data.
* Deals with the loading of level data.
*
*
*/
*/
...
...
src/level/movable.cpp
View file @
4da24843
/*
/*
*
*
*
* movable.cpp
* @file movable.cpp
*
* 15th January 2010: Created movable.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 15th January 2010: Created movable.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -17,9 +18,7 @@
...
@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Contains the base class for all movable objects.
* Contains the base class for all movable objects.
*
*
*/
*/
...
...
src/level/movable.h
View file @
4da24843
/*
/*
*
*
*
* movable.h
* @file movable.h
*
* 15th January 2010: Created movable.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 15th January 2010: Created movable.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -29,6 +30,7 @@
...
@@ -29,6 +30,7 @@
// Class
// Class
/// Base class for all movable objects (players, events, bullets, birds)
class
Movable
{
class
Movable
{
protected
:
protected
:
...
...
src/loop.h
View file @
4da24843
/*
/*
*
*
*
* loop.h
* @file loop.h
*
* 30th April 2010: Created loop.h from parts of OpenJazz.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 30th April 2010: Created loop.h from parts of OpenJazz.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -29,6 +30,7 @@
...
@@ -29,6 +30,7 @@
// Enum
// Enum
/// Ways the loop function should handle input.
enum
LoopType
{
enum
LoopType
{
NORMAL_LOOP
,
TYPING_LOOP
,
SET_KEY_LOOP
,
SET_JOYSTICK_LOOP
NORMAL_LOOP
,
TYPING_LOOP
,
SET_KEY_LOOP
,
SET_JOYSTICK_LOOP
...
...
src/main.cpp
View file @
4da24843
/*
/*
*
*
*
* main.cpp
*
@file
main.cpp
*
*
* Part of the OpenJazz project
*
* @section History
* 23rd August 2005: Created main.c
* 23rd August 2005: Created main.c
* 22nd July 2008: Created util.c from parts of main.c
* 22nd July 2008: Created util.c from parts of main.c
* 3rd February 2009: Renamed main.c to main.cpp
* 3rd February 2009: Renamed main.c to main.cpp
* 4th February 2009: Created palette.cpp from parts of main.cpp and util.cpp
* 4th February 2009: Created palette.cpp from parts of main.cpp and util.cpp
* 13th July 2009: Created controls.cpp from parts of main.cpp
* 13th July 2009: Created controls.cpp from parts of main.cpp
*
*
* Part of the OpenJazz project
* @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -21,9 +22,7 @@
...
@@ -21,9 +22,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Contains the main function.
* Contains the main function.
*
*
*/
*/
...
@@ -64,6 +63,17 @@ extern float sinf (float);
...
@@ -64,6 +63,17 @@ extern float sinf (float);
#define PI 3.141592f
#define PI 3.141592f
/**
* Initialises OpenJazz.
*
* Establishes the paths from which to read files, loads configuration, sets up
* the game window and loads required data.
*
* @param argc Number of arguments, as passed to main function
* @param argv Array of argument strings, as apsse to main function
*
* @return Error code
*/
int
loadMain
(
int
argc
,
char
*
argv
[])
{
int
loadMain
(
int
argc
,
char
*
argv
[])
{
File
*
file
;
File
*
file
;
...
@@ -400,6 +410,11 @@ int loadMain (int argc, char *argv[]) {
...
@@ -400,6 +410,11 @@ int loadMain (int argc, char *argv[]) {
}
}
/**
* De-initialises OpenJazz.
*
* Frees data, writes configuration, and shuts down SDL.
*/
void
freeMain
()
{
void
freeMain
()
{
File
*
file
;
File
*
file
;
...
@@ -503,6 +518,16 @@ void freeMain () {
...
@@ -503,6 +518,16 @@ void freeMain () {
}
}
/**
* Process iteration.
*
* Called once per game iteration. Updates timing, video, and input
*
* @param type Type of loop. Normal, typing, or input configuration
* @param paletteEffects Palette effects to apply to video output
*
* @return Error code
*/
int
loop
(
LoopType
type
,
PaletteEffect
*
paletteEffects
)
{
int
loop
(
LoopType
type
,
PaletteEffect
*
paletteEffects
)
{
SDL_Event
event
;
SDL_Event
event
;
...
@@ -597,6 +622,11 @@ int loop (LoopType type, PaletteEffect* paletteEffects) {
...
@@ -597,6 +622,11 @@ int loop (LoopType type, PaletteEffect* paletteEffects) {
}
}
/**
* Main.
*
* Initialises SDL and launches game.
*/
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
MainMenu
*
mainMenu
=
NULL
;
MainMenu
*
mainMenu
=
NULL
;
...
...
src/menu/gamemenu.cpp
View file @
4da24843
/*
/*
*
*
*
* gamemenu.cpp
* @file gamemenu.cpp
*
* 18th July 2009: Created menugame.cpp from parts of menu.cpp
* 26th July 2009: Renamed menugame.cpp to gamemenu.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 18th July 2009: Created menugame.cpp from parts of menu.cpp
* 26th July 2009: Renamed menugame.cpp to gamemenu.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -18,9 +19,7 @@
...
@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the running of the menus used to create a new game.
* Deals with the running of the menus used to create a new game.
*
*
*/
*/
...
@@ -234,7 +233,7 @@ int GameMenu::newGameDifficulty (GameModeType mode, int levelNum, int worldNum)
...
@@ -234,7 +233,7 @@ int GameMenu::newGameDifficulty (GameModeType mode, int levelNum, int worldNum)
int
GameMenu
::
loadGame
()
{
int
GameMenu
::
loadGame
()
{
//
TODO:
Actual loading of saved games
//
/ @todo
Actual loading of saved games
int
option
,
worldNum
,
levelNum
;
int
option
,
worldNum
,
levelNum
;
...
...
src/menu/mainmenu.cpp
View file @
4da24843
/*
/*
*
*
*
* mainmenu.cpp
* @file mainmenu.cpp
*
* 19th July 2009: Created menumain.cpp from parts of menu.cpp
* 26th July 2009: Renamed menumain.cpp to mainmenu.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 19th July 2009: Created menumain.cpp from parts of menu.cpp
* 26th July 2009: Renamed menumain.cpp to mainmenu.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -18,9 +19,7 @@
...
@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the running of the main menu and its generic sub-menus.
* Deals with the running of the main menu and its generic sub-menus.
*
*
*/
*/
...
...
src/menu/menu.cpp
View file @
4da24843
/*
/*
*
*
*
* menu.cpp
*
@file
menu.cpp
*
*
* Part of the OpenJazz project
*
* @section History
* 23rd of August 2005: Created menu.c
* 23rd of August 2005: Created menu.c
* 3rd of February 2009: Renamed menu.c to menu.cpp
* 3rd of February 2009: Renamed menu.c to menu.cpp
* 9th March 2009: Created game.cpp from parts of menu.cpp and level.cpp
* 9th March 2009: Created game.cpp from parts of menu.cpp and level.cpp
...
@@ -12,9 +15,7 @@
...
@@ -12,9 +15,7 @@
* 19th July 2009: Created menumain.cpp from parts of menu.cpp
* 19th July 2009: Created menumain.cpp from parts of menu.cpp
* 23rd June 2010: Merged menuutil.cpp into menu.cpp
* 23rd June 2010: Merged menuutil.cpp into menu.cpp
*
*
* Part of the OpenJazz project
* @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -24,9 +25,7 @@
...
@@ -24,9 +25,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Provides various generic menus.
* Provides various generic menus.
*
*
*/
*/
...
@@ -44,10 +43,11 @@
...
@@ -44,10 +43,11 @@
#include <string.h>
#include <string.h>
/**
* Display a message to the user
*/
int
Menu
::
message
(
const
char
*
text
)
{
int
Menu
::
message
(
const
char
*
text
)
{
// Display a message to the user
video
.
setPalette
(
menuPalette
);
video
.
setPalette
(
menuPalette
);
while
(
true
)
{
while
(
true
)
{
...
@@ -71,10 +71,11 @@ int Menu::message (const char* text) {
...
@@ -71,10 +71,11 @@ int Menu::message (const char* text) {
}
}
/**
* Let the user select from a menu of the given options
*/
int
Menu
::
generic
(
const
char
**
optionNames
,
int
options
,
int
&
chosen
)
{
int
Menu
::
generic
(
const
char
**
optionNames
,
int
options
,
int
&
chosen
)
{
// Let the user select from a menu of the given options
int
count
;
int
count
;
video
.
setPalette
(
menuPalette
);
video
.
setPalette
(
menuPalette
);
...
@@ -121,10 +122,11 @@ int Menu::generic (const char** optionNames, int options, int& chosen) {
...
@@ -121,10 +122,11 @@ int Menu::generic (const char** optionNames, int options, int& chosen) {
}
}
/**
* Let the user edit a text string
*/
int
Menu
::
textInput
(
const
char
*
request
,
char
*&
text
)
{
int
Menu
::
textInput
(
const
char
*
request
,
char
*&
text
)
{
// Let the user to edit a text string
char
*
input
;
char
*
input
;
int
count
,
terminate
,
character
,
x
;
int
count
,
terminate
,
character
,
x
;
unsigned
int
cursor
;
unsigned
int
cursor
;
...
...
src/menu/menu.h
View file @
4da24843
/*
/*
*
*
*
* menu.h
* @file menu.h
*
* 3rd February 2009: Created menu.h from parts of OpenJazz.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 3rd February 2009: Created menu.h from parts of OpenJazz.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -40,6 +41,7 @@
...
@@ -40,6 +41,7 @@
// Classes
// Classes
/// Menu base class, providing generic menu screens
class
Menu
{
class
Menu
{
protected
:
protected
:
...
@@ -49,16 +51,16 @@ class Menu {
...
@@ -49,16 +51,16 @@ class Menu {
};
};
/// New game menus
class
GameMenu
:
public
Menu
{
class
GameMenu
:
public
Menu
{
private
:
private
:
SDL_Surface
*
episodeScreens
[
11
];
SDL_Surface
*
episodeScreens
[
11
];
///< Episode images
SDL_Surface
*
difficultyScreen
;
SDL_Surface
*
difficultyScreen
;
///< 4 difficulty images
SDL_Color
palette
[
256
];
SDL_Color
palette
[
256
];
///< Episode selection palette
SDL_Color
greyPalette
[
256
];
SDL_Color
greyPalette
[
256
];
///< Greyed-out episode selection palette
int
episodes
;
int
episodes
;
///< Number of episodes
unsigned
char
difficulty
;
unsigned
char
difficulty
;
///< Difficulty setting (0 = easy, 1 = medium, 2 = hard, 3 = turbo (hard in JJ2 levels))
int
newGameDifficulty
(
GameModeType
mode
,
char
*
firstLevel
);
int
newGameDifficulty
(
GameModeType
mode
,
char
*
firstLevel
);
int
newGameDifficulty
(
GameModeType
mode
,
int
levelNum
,
int
worldNum
);
int
newGameDifficulty
(
GameModeType
mode
,
int
levelNum
,
int
worldNum
);
...
@@ -75,7 +77,7 @@ class GameMenu : public Menu {
...
@@ -75,7 +77,7 @@ class GameMenu : public Menu {
};
};
/// Setup menus
class
SetupMenu
:
public
Menu
{
class
SetupMenu
:
public
Menu
{
private
:
private
:
...
@@ -92,15 +94,15 @@ class SetupMenu : public Menu {
...
@@ -92,15 +94,15 @@ class SetupMenu : public Menu {
};
};
/// Main menu
class
MainMenu
:
public
Menu
{
class
MainMenu
:
public
Menu
{
private
:
private
:
SDL_Surface
*
background
;
SDL_Surface
*
background
;
///< Menu image
SDL_Surface
*
highlight
;
SDL_Surface
*
highlight
;
///< Menu image with highlighted text
SDL_Surface
*
logo
;
SDL_Surface
*
logo
;
///< OJ logo image
GameMenu
*
gameMenu
;
GameMenu
*
gameMenu
;
///< New game menu
SDL_Color
palette
[
256
];
SDL_Color
palette
[
256
];
///< Menu palette
public
:
public
:
MainMenu
();
MainMenu
();
...
@@ -113,7 +115,7 @@ class MainMenu : public Menu {
...
@@ -113,7 +115,7 @@ class MainMenu : public Menu {
// Variable
// Variable
EXTERN
SDL_Color
menuPalette
[
256
];
EXTERN
SDL_Color
menuPalette
[
256
];
/// Palette used by most menu screens
#endif
#endif
src/menu/plasma.cpp
View file @
4da24843
/*
/*
*
*
*
* plasma.cpp
* @file plasma.cpp
*
* 23rd June 2010: Created plasma.c
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 23rd June 2010: Created plasma.cpp
*
*
* @section Licence
* Copyright (c) 2010 Alireza Nejati
* Copyright (c) 2010 Alireza Nejati
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -17,10 +18,9 @@
...
@@ -17,10 +18,9 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Cool plasma effects for the main menu.
* Cool plasma effects for the main menu.
*
*/
*/
...
@@ -35,7 +35,9 @@
...
@@ -35,7 +35,9 @@
#include "io/gfx/scale2x/scalebit.h"
#include "io/gfx/scale2x/scalebit.h"
#endif
#endif
// Precalculate buffers
/**
* Precalculate buffers
*/
Plasma
::
Plasma
(){
Plasma
::
Plasma
(){
p0
=
0
;
p0
=
0
;
...
@@ -47,9 +49,11 @@ Plasma::Plasma(){
...
@@ -47,9 +49,11 @@ Plasma::Plasma(){
// -1024 < out < 1024
// -1024 < out < 1024
}
}
//
TODO:
this code is awful in so many ways
//
/ @todo
this code is awful in so many ways
// Draws plasma onto canvas
/**
* Draws plasma onto canvas
*/
int
Plasma
::
draw
(){
int
Plasma
::
draw
(){
int
x
,
y
;
int
x
,
y
;
...
...
src/menu/plasma.h
View file @
4da24843
/*
/*
*
*
*
* plasma.h
* @file plasma.h
*
* 23rd June 2010: Created plasma.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 23rd June 2010: Created plasma.h
*
*
* @section Licence
* Copyright (c) 2010 Alireza Nejati
* Copyright (c) 2010 Alireza Nejati
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -24,6 +25,7 @@
...
@@ -24,6 +25,7 @@
#include <SDL/SDL.h>
#include <SDL/SDL.h>
/// Main menu background plasma effect
class
Plasma
{
class
Plasma
{
private
:
private
:
...
...
src/menu/setupmenu.cpp
View file @
4da24843
/*
/*
*
*
*
* setupmenu.cpp
* @file setupmenu.cpp
*
* 18th July 2009: Created menusetup.cpp from parts of menu.cpp
* 26th July 2009: Renamed menusetup.cpp to setupmenu.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 18th July 2009: Created menusetup.cpp from parts of menu.cpp
* 26th July 2009: Renamed menusetup.cpp to setupmenu.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -18,9 +19,7 @@
...
@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the running of setup menus.
* Deals with the running of setup menus.
*
*
*/
*/
...
...
src/planet/planet.cpp
View file @
4da24843
/*
/*
*
*
*
* planet.cpp
* @file planet.cpp
*
* 23rd August 2005: Created planet.c
* 3rd February 2009: Renamed planet.c to planet.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 23rd August 2005: Created planet.c
* 3rd February 2009: Renamed planet.c to planet.cpp
*
*
* @section Licence
* Copyright (c) 2005-2009 Alister Thomson
* Copyright (c) 2005-2009 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -18,9 +19,7 @@
...
@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the loading, displaying and freeing of the planet landing
* Deals with the loading, displaying and freeing of the planet landing
* sequence.
* sequence.
*
*
...
...
src/planet/planet.h
View file @
4da24843
/*
/*
*
*
*
* planet.h
* @file planet.h
*
* 3rd of February 2009: Created planet.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 3rd of February 2009: Created planet.h
*
*
* @section Licence
* Copyright (c) 2009 Alister Thomson
* Copyright (c) 2009 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -31,13 +32,14 @@
...
@@ -31,13 +32,14 @@
// Class
// Class
/// Planet approach sequence
class
Planet
{
class
Planet
{
private
:
private
:
SDL_Color
palette
[
256
];
SDL_Color
palette
[
256
];
/// Palette
Sprite
sprite
;
Sprite
sprite
;
/// Planet image
char
*
name
;
char
*
name
;
/// Planet name
int
id
;
int
id
;
/// World number
public
:
public
:
Planet
(
char
*
fileName
,
int
previous
);
Planet
(
char
*
fileName
,
int
previous
);
...
...
src/platforms/symbian.cpp
View file @
4da24843
/**
*
* @file symbian.cpp
*
* Part of the OpenJazz project
*
* @section Licence
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <eikenv.h>
#include <eikenv.h>
#include <eikapp.h>
#include <eikapp.h>
#include <eikappui.h>
#include <eikappui.h>
...
@@ -13,6 +31,7 @@ char KOpenJazzPath[256];
...
@@ -13,6 +31,7 @@ char KOpenJazzPath[256];
FILE
*
mystdout
=
NULL
;
FILE
*
mystdout
=
NULL
;
FILE
*
mystderr
=
NULL
;
FILE
*
mystderr
=
NULL
;
/// Symbian app
class
COpenJazzApp
:
public
CSDLApp
{
class
COpenJazzApp
:
public
CSDLApp
{
public
:
public
:
COpenJazzApp
();
COpenJazzApp
();
...
...
src/platforms/wiz.cpp
View file @
4da24843
/**
*
* @file wiz.cpp
*
* Part of the OpenJazz project
*
* @section Licence
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "wiz.h"
#include "wiz.h"
#if defined(WIZ) || defined(GP2X)
#if defined(WIZ) || defined(GP2X)
...
...
src/platforms/wiz.h
View file @
4da24843
/**
*
* @file wiz.h
*
* Part of the OpenJazz project
*
* @section Licence
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef _WIZ_H
#ifndef _WIZ_H
#define _WIZ_H
#define _WIZ_H
...
...
src/player/bird.cpp
View file @
4da24843
/*
/*
*
*
*
* bird.cpp
* @file bird.cpp
*
* 1st March 2009: Created bird.cpp from parts of events.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 1st March 2009: Created bird.cpp from parts of events.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
...
src/player/bird.h
View file @
4da24843
/*
/*
*
*
*
* bird.h
* @file bird.h
*
* 1st March 2009: Created bird.h from parts of events.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 1st March 2009: Created bird.h from parts of events.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -42,12 +43,13 @@
...
@@ -42,12 +43,13 @@
class
LevelPlayer
;
class
LevelPlayer
;
/// JJ1 bird companion
class
Bird
:
public
Movable
{
class
Bird
:
public
Movable
{
private
:
private
:
LevelPlayer
*
player
;
LevelPlayer
*
player
;
///< Player that rescued the bird
bool
fleeing
;
bool
fleeing
;
///< Flying away, player having been shot
unsigned
int
fireTime
;
unsigned
int
fireTime
;
///< Next time the bird will fire
public
:
public
:
Bird
(
LevelPlayer
*
player
,
unsigned
char
gX
,
unsigned
char
gY
);
Bird
(
LevelPlayer
*
player
,
unsigned
char
gX
,
unsigned
char
gY
);
...
...
src/player/bonusplayer.cpp
View file @
4da24843
/*
/*
*
*
*
* bonusplayer.cpp
* @file bonusplayer.cpp
*
* 24th June 2010: Created bonusplayer.cpp from parts of player.cpp and
* playerframe.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 24th June 2010: Created bonusplayer.cpp from parts of player.cpp and
* playerframe.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -18,9 +19,7 @@
...
@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with players in bonus levels.
* Deals with players in bonus levels.
*
*
*/
*/
...
@@ -59,7 +58,7 @@ BonusPlayer::BonusPlayer (Player* parent, Anim **newAnims, unsigned char startX,
...
@@ -59,7 +58,7 @@ BonusPlayer::BonusPlayer (Player* parent, Anim **newAnims, unsigned char startX,
for
(
count
=
0
;
count
<
256
;
count
++
)
for
(
count
=
0
;
count
<
256
;
count
++
)
palette
[
count
].
r
=
palette
[
count
].
g
=
palette
[
count
].
b
=
count
;
palette
[
count
].
r
=
palette
[
count
].
g
=
palette
[
count
].
b
=
count
;
//
TODO:
Custom colours
//
/ @todo
Custom colours
return
;
return
;
...
...
src/player/bonusplayer.h
View file @
4da24843
/*
/*
*
*
*
* bonusplayer.h
* @file bonusplayer.h
*
* 24th June 2010: Created bonusplayer.h from parts of player.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 24th June 2010: Created bonusplayer.h from parts of player.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -59,17 +60,21 @@
...
@@ -59,17 +60,21 @@
class
Anim
;
class
Anim
;
class
Bonus
;
class
Bonus
;
/// JJ1 bonus level player
class
BonusPlayer
{
class
BonusPlayer
{
private
:
private
:
SDL_Color
palette
[
256
];
SDL_Color
palette
[
256
];
///< Palette (for custom colours)
Anim
*
anims
[
BPANIMS
];
Anim
*
anims
[
BPANIMS
];
///< Animations
fixed
x
,
y
,
direction
,
dr
;
fixed
x
;
///< X-coordinate
unsigned
char
animType
;
fixed
y
;
///< Y-coordinate
int
gems
;
fixed
direction
;
///< Direction
fixed
dr
;
///< Forward speed
unsigned
char
animType
;
///< Current animation
int
gems
;
///< Number of gems collected
public
:
public
:
Player
*
player
;
Player
*
player
;
///< Corresponding game player
BonusPlayer
(
Player
*
parent
,
Anim
**
newAnims
,
unsigned
char
startX
,
unsigned
char
startY
);
BonusPlayer
(
Player
*
parent
,
Anim
**
newAnims
,
unsigned
char
startX
,
unsigned
char
startY
);
~
BonusPlayer
();
~
BonusPlayer
();
...
...
src/player/jj2levelplayer.cpp
View file @
4da24843
/*
/*
*
*
*
* jj2levelplayer.cpp
* @file jj2levelplayer.cpp
*
* 29th June 2010: Created jj2levelplayer.cpp from parts of levelplayer.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 29th June 2010: Created jj2levelplayer.cpp from parts of levelplayer.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -17,9 +18,7 @@
...
@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the creation and destruction of players in levels, and their
* Deals with the creation and destruction of players in levels, and their
* interactions with other level objects.
* interactions with other level objects.
*
*
...
@@ -555,10 +554,11 @@ bool JJ2LevelPlayer::touchEvent (JJ2Event* touched, unsigned int ticks, int msps
...
@@ -555,10 +554,11 @@ bool JJ2LevelPlayer::touchEvent (JJ2Event* touched, unsigned int ticks, int msps
}
}
/**
* Copy data to be sent to clients/server
*/
void
JJ2LevelPlayer
::
send
(
unsigned
char
*
buffer
)
{
void
JJ2LevelPlayer
::
send
(
unsigned
char
*
buffer
)
{
// Copy data to be sent to clients/server
buffer
[
9
]
=
bird
?
1
:
0
;
buffer
[
9
]
=
bird
?
1
:
0
;
buffer
[
23
]
=
energy
;
buffer
[
23
]
=
energy
;
buffer
[
25
]
=
shield
;
buffer
[
25
]
=
shield
;
...
@@ -586,10 +586,11 @@ void JJ2LevelPlayer::send (unsigned char *buffer) {
...
@@ -586,10 +586,11 @@ void JJ2LevelPlayer::send (unsigned char *buffer) {
}
}
/**
* Interpret data received from client/server
*/
void
JJ2LevelPlayer
::
receive
(
unsigned
char
*
buffer
)
{
void
JJ2LevelPlayer
::
receive
(
unsigned
char
*
buffer
)
{
// Interpret data received from client/server
switch
(
buffer
[
1
])
{
switch
(
buffer
[
1
])
{
case
MT_P_ANIMS
:
case
MT_P_ANIMS
:
...
...
src/player/jj2levelplayer.h
View file @
4da24843
/*
/*
*
*
*
* jj2levelplayer.h
* @file jj2levelplayer.h
*
* 29th June 2010: Created jj2levelplayer.h from parts of levelplayer.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 29th June 2010: Created jj2levelplayer.h from parts of levelplayer.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -226,12 +227,14 @@
...
@@ -226,12 +227,14 @@
// Enum
// Enum
/// JJ2 player reaction type
enum
JJ2PlayerReaction
{
enum
JJ2PlayerReaction
{
JJ2PR_NONE
,
JJ2PR_HURT
,
JJ2PR_KILLED
,
JJ2PR_INVINCIBLE
JJ2PR_NONE
,
JJ2PR_HURT
,
JJ2PR_KILLED
,
JJ2PR_INVINCIBLE
};
};
/// JJ2 shield type
enum
JJ2Shield
{
enum
JJ2Shield
{
JJ2S_NONE
=
0
,
JJ2S_FLAME
=
1
,
JJ2S_BUBBLE
=
2
,
JJ2S_PLASMA
=
3
,
JJ2S_LASER
=
4
JJ2S_NONE
=
0
,
JJ2S_FLAME
=
1
,
JJ2S_BUBBLE
=
2
,
JJ2S_PLASMA
=
3
,
JJ2S_LASER
=
4
...
@@ -244,37 +247,39 @@ enum JJ2Shield {
...
@@ -244,37 +247,39 @@ enum JJ2Shield {
class
Anim
;
class
Anim
;
class
JJ2Event
;
class
JJ2Event
;
/// JJ2 level player
class
JJ2LevelPlayer
:
public
Movable
{
class
JJ2LevelPlayer
:
public
Movable
{
private
:
private
:
bool
bird
;
// Placeholder for eventual JJ2Bird object
bool
bird
;
///< Placeholder for eventual JJ2Bird object
Anim
*
anims
;
Anim
*
anims
;
///< Animations
Anim
*
flippedAnims
;
Anim
*
flippedAnims
;
///< Animations (flipped)
JJ2Modifier
*
mod
;
JJ2Modifier
*
mod
;
///< Modifier currently affecting player
SDL_Color
palette
[
256
];
SDL_Color
palette
[
256
];
///< Palette (for custom colours)
int
energy
;
int
energy
;
///< 0 = dead, 3 or 5 = maximum
JJ2Shield
shield
;
JJ2Shield
shield
;
///< Current shield
int
floating
;
/* 0 = normal, 1 = helicopter ears, 2 = boarding */
int
floating
;
///< 0 = normal, 1 = helicopter ears, 2 = boarding
bool
facing
;
bool
facing
;
///< false = left, true = right
unsigned
char
animType
;
unsigned
char
animType
;
///< Current animation
PlayerEvent
event
;
PlayerEvent
event
;
///< Event type
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
JJ2PlayerReaction
reaction
;
JJ2PlayerReaction
reaction
;
///< Reaction type
unsigned
int
reactionTime
;
unsigned
int
reactionTime
;
///< Time reaction will end
unsigned
int
fireTime
;
unsigned
int
fireTime
;
///< The next time the player can fire
fixed
jumpHeight
;
fixed
jumpHeight
;
///< The height the player can reach when jumping
fixed
throwX
,
throwY
;
fixed
throwX
;
///< Having been thrown, the x-coordinate the player can reach
fixed
throwY
;
///< Having been thrown, the y-coordinate the player can reach
unsigned
int
fastFeetTime
;
unsigned
int
fastFeetTime
;
unsigned
int
stopTime
;
unsigned
int
stopTime
;
int
gems
[
4
];
int
gems
[
4
];
///< Gems collected
int
coins
;
int
coins
;
///< Value of coins collected
void
centreX
();
void
centreX
();
void
centreY
();
void
centreY
();
void
modify
(
JJ2Modifier
*
nextMod
,
unsigned
int
ticks
);
void
modify
(
JJ2Modifier
*
nextMod
,
unsigned
int
ticks
);
public
:
public
:
Player
*
player
;
Player
*
player
;
///< Corresponding game player
JJ2LevelPlayer
(
Player
*
parent
,
Anim
**
newAnims
,
unsigned
char
startX
,
unsigned
char
startY
,
bool
hasBird
);
JJ2LevelPlayer
(
Player
*
parent
,
Anim
**
newAnims
,
unsigned
char
startX
,
unsigned
char
startY
,
bool
hasBird
);
~
JJ2LevelPlayer
();
~
JJ2LevelPlayer
();
...
...
src/player/jj2levelplayerframe.cpp
View file @
4da24843
/*
/*
*
*
*
* jj2levelplayerframe.cpp
* @file jj2levelplayerframe.cpp
*
* 29th June 2010: Created jj2levelplayerframe.cpp from parts of
* levelplayerframe.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 29th June 2010: Created jj2levelplayerframe.cpp from parts of
* levelplayerframe.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -18,9 +19,7 @@
...
@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Provides the once-per-frame functions of players in levels.
* Provides the once-per-frame functions of players in levels.
*
*
*/
*/
...
@@ -178,14 +177,15 @@ void JJ2LevelPlayer::modify (JJ2Modifier* nextMod, unsigned int ticks) {
...
@@ -178,14 +177,15 @@ void JJ2LevelPlayer::modify (JJ2Modifier* nextMod, unsigned int ticks) {
}
}
/**
* Respond to controls, unless the player has been killed
*/
void
JJ2LevelPlayer
::
control
(
unsigned
int
ticks
,
int
msps
)
{
void
JJ2LevelPlayer
::
control
(
unsigned
int
ticks
,
int
msps
)
{
JJ2Modifier
*
nextMod
;
JJ2Modifier
*
nextMod
;
bool
drop
,
platform
;
bool
drop
,
platform
;
// Respond to controls, unless the player has been killed
// If the player has been killed, do not move
// If the player has been killed, do not move
if
(
!
energy
)
{
if
(
!
energy
)
{
...
@@ -449,7 +449,7 @@ void JJ2LevelPlayer::control (unsigned int ticks, int msps) {
...
@@ -449,7 +449,7 @@ void JJ2LevelPlayer::control (unsigned int ticks, int msps) {
// Make sure bullet position is taken from correct animation
// Make sure bullet position is taken from correct animation
if
(
platform
)
animType
=
PA_STANDSHOOT
;
if
(
platform
)
animType
=
PA_STANDSHOOT
;
//
TODO: Create new bullet
//
/ @todo Create new bullet when firing
// Set when the next bullet can be fired
// Set when the next bullet can be fired
if
(
player
->
fireSpeed
)
fireTime
=
ticks
+
(
1000
/
player
->
fireSpeed
);
if
(
player
->
fireSpeed
)
fireTime
=
ticks
+
(
1000
/
player
->
fireSpeed
);
...
@@ -748,12 +748,13 @@ void JJ2LevelPlayer::move (unsigned int ticks, int msps) {
...
@@ -748,12 +748,13 @@ void JJ2LevelPlayer::move (unsigned int ticks, int msps) {
}
}
/**
* Calculate viewport
*/
void
JJ2LevelPlayer
::
view
(
unsigned
int
ticks
,
int
mspf
)
{
void
JJ2LevelPlayer
::
view
(
unsigned
int
ticks
,
int
mspf
)
{
int
oldViewX
,
oldViewY
,
speed
;
int
oldViewX
,
oldViewY
,
speed
;
// Calculate viewport
// Record old viewport position for applying lag
// Record old viewport position for applying lag
oldViewX
=
viewX
;
oldViewX
=
viewX
;
oldViewY
=
viewY
;
oldViewY
=
viewY
;
...
@@ -847,7 +848,7 @@ void JJ2LevelPlayer::draw (unsigned int ticks, int change) {
...
@@ -847,7 +848,7 @@ void JJ2LevelPlayer::draw (unsigned int ticks, int change) {
if
(
reaction
==
JJ2PR_INVINCIBLE
)
{
if
(
reaction
==
JJ2PR_INVINCIBLE
)
{
//
TODO:
Show invincibility effect
//
/ @todo
Show invincibility effect
}
}
...
@@ -861,25 +862,25 @@ void JJ2LevelPlayer::draw (unsigned int ticks, int change) {
...
@@ -861,25 +862,25 @@ void JJ2LevelPlayer::draw (unsigned int ticks, int change) {
case
JJ2S_FLAME
:
case
JJ2S_FLAME
:
//
TODO:
Show shield effect
//
/ @todo
Show shield effect
break
;
break
;
case
JJ2S_BUBBLE
:
case
JJ2S_BUBBLE
:
//
TODO:
Show shield effect
//
/ @todo
Show shield effect
break
;
break
;
case
JJ2S_PLASMA
:
case
JJ2S_PLASMA
:
//
TODO:
Show shield effect
//
/ @todo
Show shield effect
break
;
break
;
case
JJ2S_LASER
:
case
JJ2S_LASER
:
//
TODO:
Show shield effect
//
/ @todo
Show shield effect
break
;
break
;
...
...
src/player/levelplayer.cpp
View file @
4da24843
/*
/*
*
*
*
* levelplayer.cpp
* @file levelplayer.cpp
*
* 24th June 2010: Created levelplayer.cpp from parts of player.cpp
* 29th June 2010: Created jj2levelplayer.cpp from parts of levelplayer.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 24th June 2010: Created levelplayer.cpp from parts of player.cpp
* 29th June 2010: Created jj2levelplayer.cpp from parts of levelplayer.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -18,9 +19,7 @@
...
@@ -18,9 +19,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the creation and destruction of players in levels, and their
* Deals with the creation and destruction of players in levels, and their
* interactions with other level objects.
* interactions with other level objects.
*
*
...
...
src/player/levelplayer.h
View file @
4da24843
/*
/*
*
*
*
* levelplayer.h
* @file levelplayer.h
*
* 24th June 2010: Created levelplayer.h from parts of player.h
* 29th June 2010: Created jj2levelplayer.h from parts of levelplayer.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 24th June 2010: Created levelplayer.h from parts of player.h
* 29th June 2010: Created jj2levelplayer.h from parts of levelplayer.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -135,6 +136,7 @@
...
@@ -135,6 +136,7 @@
// Enum
// Enum
/// JJ1 player reaction type
enum
PlayerReaction
{
enum
PlayerReaction
{
PR_NONE
,
PR_HURT
,
PR_KILLED
,
PR_INVINCIBLE
PR_NONE
,
PR_HURT
,
PR_KILLED
,
PR_INVINCIBLE
...
@@ -147,34 +149,37 @@ enum PlayerReaction {
...
@@ -147,34 +149,37 @@ enum PlayerReaction {
class
Anim
;
class
Anim
;
class
Bird
;
class
Bird
;
/// JJ1 level player
class
LevelPlayer
:
public
Movable
{
class
LevelPlayer
:
public
Movable
{
private
:
private
:
Bird
*
bird
;
Bird
*
bird
;
///< Bird companion
SDL_Color
palette
[
256
];
SDL_Color
palette
[
256
];
///< Palette (for custom colours)
Anim
*
anims
[
PANIMS
];
Anim
*
anims
[
PANIMS
];
///< Animations
int
energy
;
int
energy
;
///< 0 = dead, 4 = maximum
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
;
///< false = left, true = right
unsigned
char
animType
;
unsigned
char
animType
;
///< Current animation
unsigned
char
eventX
;
unsigned
char
eventX
;
///< X-coordinate (in tiles) of an event (spring, platform, bridge)
unsigned
char
eventY
;
/* Position of an event (spring, platform, bridge) */
unsigned
char
eventY
;
///< Y-coordinate (in tiles) of an event (spring, platform, bridge)
PlayerEvent
event
;
PlayerEvent
event
;
///< Event type
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
PlayerReaction
reaction
;
PlayerReaction
reaction
;
///< Reaction type
unsigned
int
reactionTime
;
unsigned
int
reactionTime
;
///< Time reaction will end
unsigned
int
fireTime
;
unsigned
int
fireTime
;
///< The next time the player can fire
fixed
jumpHeight
;
fixed
jumpHeight
;
///< The height the player can reach when jumping
fixed
jumpY
;
fixed
jumpY
;
///< Having started jumping, the y-coordinate the player can reach
unsigned
int
fastFeetTime
;
unsigned
int
fastFeetTime
;
///< Time fast feet will expire
unsigned
char
warpX
,
warpY
;
unsigned
char
warpX
;
///< X-coordinate (in tiles) player will warp to
unsigned
int
warpTime
;
unsigned
char
warpY
;
///< Y-coordinate (in tiles) player will warp to
int
enemies
,
items
;
unsigned
int
warpTime
;
///< Time the warp will happen
bool
gem
;
int
enemies
;
///< Number of enemies killed
int
items
;
///< Number of items collected
bool
gem
;
///< Bonus level gem collected
public
:
public
:
Player
*
player
;
Player
*
player
;
///< Corresponding game player
LevelPlayer
(
Player
*
parent
,
Anim
**
newAnims
,
unsigned
char
startX
,
unsigned
char
startY
,
bool
hasBird
);
LevelPlayer
(
Player
*
parent
,
Anim
**
newAnims
,
unsigned
char
startX
,
unsigned
char
startY
,
bool
hasBird
);
~
LevelPlayer
();
~
LevelPlayer
();
...
...
src/player/levelplayerframe.cpp
View file @
4da24843
/*
/*
*
*
*
* levelplayerframe.cpp
* @file levelplayerframe.cpp
*
* Part of the OpenJazz project
*
*
* @section History
* 18th July 2009: Created playerframe.cpp from parts of player.cpp
* 18th July 2009: Created playerframe.cpp from parts of player.cpp
* 24th June 2010: Renamed playerframe.cpp to levelplayerframe.cpp
* 24th June 2010: Renamed playerframe.cpp to levelplayerframe.cpp
* 29th June 2010: Created jj2levelplayerframe.cpp from parts of
* 29th June 2010: Created jj2levelplayerframe.cpp from parts of
* levelplayerframe.cpp
* levelplayerframe.cpp
*
*
* Part of the OpenJazz project
* @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -20,9 +21,7 @@
...
@@ -20,9 +21,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Provides the once-per-frame functions of players in levels.
* Provides the once-per-frame functions of players in levels.
*
*
*/
*/
...
@@ -43,12 +42,14 @@
...
@@ -43,12 +42,14 @@
#include "util.h"
#include "util.h"
/**
* Respond to controls, unless the player has been killed
*/
void
LevelPlayer
::
control
(
unsigned
int
ticks
,
int
msps
)
{
void
LevelPlayer
::
control
(
unsigned
int
ticks
,
int
msps
)
{
int
speed
;
int
speed
;
bool
platform
;
bool
platform
;
// Respond to controls, unless the player has been killed
// If the player has been killed, drop but otherwise do not move
// If the player has been killed, drop but otherwise do not move
if
(
!
energy
)
{
if
(
!
energy
)
{
...
@@ -619,12 +620,13 @@ void LevelPlayer::move (unsigned int ticks, int msps) {
...
@@ -619,12 +620,13 @@ void LevelPlayer::move (unsigned int ticks, int msps) {
}
}
/**
* Calculate viewport
*/
void
LevelPlayer
::
view
(
unsigned
int
ticks
,
int
mspf
)
{
void
LevelPlayer
::
view
(
unsigned
int
ticks
,
int
mspf
)
{
int
oldViewX
,
oldViewY
,
speed
;
int
oldViewX
,
oldViewY
,
speed
;
// Calculate viewport
// Record old viewport position for applying lag
// Record old viewport position for applying lag
oldViewX
=
viewX
;
oldViewX
=
viewX
;
oldViewY
=
viewY
;
oldViewY
=
viewY
;
...
...
src/player/player.cpp
View file @
4da24843
/*
/*
*
*
*
* player.cpp
*
@file
player.cpp
*
*
* Part of the OpenJazz project
*
* @section History
* 3rd February 2009: Created player.cpp
* 3rd February 2009: Created player.cpp
* 5th February 2009: Added parts of events.cpp and level.cpp to player.cpp
* 5th February 2009: Added parts of events.cpp and level.cpp to player.cpp
* 19th March 2009: Created sprite.cpp from parts of event.cpp and player.cpp
* 19th March 2009: Created sprite.cpp from parts of event.cpp and player.cpp
* 18th July 2009: Created playerframe.cpp from parts of player.cpp
* 18th July 2009: Created playerframe.cpp from parts of player.cpp
*
*
* Part of the OpenJazz project
* @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -20,9 +21,7 @@
...
@@ -20,9 +21,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the creation and destruction of players, and their interactions
* Deals with the creation and destruction of players, and their interactions
* with other objects.
* with other objects.
*
*
...
@@ -295,10 +294,11 @@ unsigned char Player::getTeam () {
...
@@ -295,10 +294,11 @@ unsigned char Player::getTeam () {
}
}
/**
* Copy data to be sent to clients/server
*/
void
Player
::
send
(
unsigned
char
*
buffer
)
{
void
Player
::
send
(
unsigned
char
*
buffer
)
{
// Copy data to be sent to clients/server
buffer
[
3
]
=
pcontrols
[
C_UP
];
buffer
[
3
]
=
pcontrols
[
C_UP
];
buffer
[
4
]
=
pcontrols
[
C_DOWN
];
buffer
[
4
]
=
pcontrols
[
C_DOWN
];
buffer
[
5
]
=
pcontrols
[
C_LEFT
];
buffer
[
5
]
=
pcontrols
[
C_LEFT
];
...
@@ -331,10 +331,11 @@ void Player::send (unsigned char *buffer) {
...
@@ -331,10 +331,11 @@ void Player::send (unsigned char *buffer) {
}
}
/**
* Interpret data received from client/server
*/
void
Player
::
receive
(
unsigned
char
*
buffer
)
{
void
Player
::
receive
(
unsigned
char
*
buffer
)
{
// Interpret data received from client/server
if
(
buffer
[
1
]
==
MT_P_TEMP
)
{
if
(
buffer
[
1
]
==
MT_P_TEMP
)
{
pcontrols
[
C_UP
]
=
buffer
[
3
];
pcontrols
[
C_UP
]
=
buffer
[
3
];
...
...
src/player/player.h
View file @
4da24843
/*
/*
*
*
*
* player.h
*
@file
player.h
*
*
* Part of the OpenJazz project
*
* @section History
* 31st January 2006: Created player.h from parts of OpenJazz.h
* 31st January 2006: Created player.h from parts of OpenJazz.h
* 24th June 2010: Created levelplayer.h from parts of player.h
* 24th June 2010: Created levelplayer.h from parts of player.h
* 24th June 2010: Created bonusplayer.h from parts of player.h
* 24th June 2010: Created bonusplayer.h from parts of player.h
*
*
* Part of the OpenJazz project
* @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -50,6 +51,7 @@
...
@@ -50,6 +51,7 @@
// Enums
// Enums
/// Player colours
enum
PlayerColour
{
enum
PlayerColour
{
PC_GREY
=
0
,
PC_GREY
=
0
,
...
@@ -69,6 +71,7 @@ enum PlayerColour {
...
@@ -69,6 +71,7 @@ enum PlayerColour {
};
};
/// Player event types
enum
PlayerEvent
{
enum
PlayerEvent
{
LPE_NONE
,
LPE_SPRING
,
LPE_FLOAT
,
LPE_PLATFORM
LPE_NONE
,
LPE_SPRING
,
LPE_FLOAT
,
LPE_PLATFORM
...
@@ -83,27 +86,28 @@ class LevelPlayer;
...
@@ -83,27 +86,28 @@ class LevelPlayer;
class
BonusPlayer
;
class
BonusPlayer
;
class
JJ2LevelPlayer
;
class
JJ2LevelPlayer
;
/// Game player
class
Player
{
class
Player
{
private
:
private
:
LevelPlayer
*
levelPlayer
;
LevelPlayer
*
levelPlayer
;
///< JJ1 level player
BonusPlayer
*
bonusPlayer
;
BonusPlayer
*
bonusPlayer
;
///< JJ1 bonus level player
JJ2LevelPlayer
*
jj2LevelPlayer
;
JJ2LevelPlayer
*
jj2LevelPlayer
;
///< JJ2 level player
char
*
name
;
char
*
name
;
///< Name
bool
pcontrols
[
PCONTROLS
];
bool
pcontrols
[
PCONTROLS
];
///< Control status
unsigned
char
cols
[
PCOLOURS
];
unsigned
char
cols
[
PCOLOURS
];
///< Character colours
int
ammo
[
4
];
int
ammo
[
4
];
///< Amount of ammo
int
ammoType
;
/
* -1 = blaster, 0 = toaster, 1 = missiles, 2 = bouncer 3 = TNT */
int
ammoType
;
/
//< Ammo type. -1 = blaster, 0 = toaster, 1 = missiles, 2 = bouncer 3 = TNT
int
score
;
int
score
;
///< Total score
int
lives
;
int
lives
;
///< Remaining lives
int
fireSpeed
;
int
fireSpeed
;
///< Rapid-fire rate
bool
bird
;
bool
bird
;
///< Accompanied by a bird
unsigned
char
team
;
unsigned
char
team
;
///< Team ID
void
addAmmo
(
int
type
,
int
amount
);
void
addAmmo
(
int
type
,
int
amount
);
public
:
public
:
int
teamScore
;
int
teamScore
;
///< Team's total score
Player
();
Player
();
~
Player
();
~
Player
();
...
...
src/scene/scene.cpp
View file @
4da24843
/*
/**
*
* @file scene.cpp
*
*
*
scene.cpp
*
Part of the OpenJazz project
*
*
* @section History
* 23rd August 2005: Created scene.c
* 23rd August 2005: Created scene.c
* 3rd February 2009: Created scene.h from parts of scene.c
* 3rd February 2009: Created scene.h from parts of scene.c
* 3rd February 2009: Renamed scene.c to scene.cpp
* 3rd February 2009: Renamed scene.c to scene.cpp
* 27th March 2010: Created sceneload.cpp from parts of scene.cpp
* 27th March 2010: Created sceneload.cpp from parts of scene.cpp
*
*
* Part of the OpenJazz project
* @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -20,9 +21,7 @@
...
@@ -20,9 +21,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the displaying and freeing of the cutscenes.
* Deals with the displaying and freeing of the cutscenes.
*
*
*/
*/
...
@@ -198,7 +197,7 @@ Scene::Scene (const char * fileName) {
...
@@ -198,7 +197,7 @@ Scene::Scene (const char * fileName) {
palettes
=
NULL
;
palettes
=
NULL
;
animations
=
NULL
;
animations
=
NULL
;
file
->
seek
(
ESignatureLength
,
true
);
// Skip Digital Dimensions header
file
->
seek
(
0x13
,
true
);
// Skip Digital Dimensions header
signed
long
int
dataOffset
=
file
->
loadInt
();
//get offset pointer to first data block
signed
long
int
dataOffset
=
file
->
loadInt
();
//get offset pointer to first data block
scriptItems
=
file
->
loadShort
();
// Get number of script items
scriptItems
=
file
->
loadShort
();
// Get number of script items
...
...
src/scene/scene.h
View file @
4da24843
/*
/**
*
* scene.h
*
*
*
3rd February 2009: Created scene.h from parts of scene.c
*
@file scene.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 3rd February 2009: Created scene.h from parts of scene.c
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -32,6 +33,7 @@
...
@@ -32,6 +33,7 @@
// Enums
// Enums
/**
/**
* Cutscene file animation headers
11
11
1L
1L
/0/0
/0/0
...
@@ -50,34 +52,26 @@ MX
...
@@ -50,34 +52,26 @@ MX
ST
ST
SL
SL
*/
*/
enum
ANIHeaders
enum
ANIHeaders
{
{
E11AniHeader
=
0x3131
,
// Background/start image
E11AniHeader
=
0x3131
,
//
/<
Background/start image
E1LAniHeader
=
0x4c31
,
E1LAniHeader
=
0x4c31
,
EPBAniHeader
=
0x4250
,
EPBAniHeader
=
0x4250
,
EFFAniHeader
=
0x4646
,
// Floodfill? or full frame?
EFFAniHeader
=
0x4646
,
//
/<
Floodfill? or full frame?
ERNAniHeader
=
0x4e52
,
ERNAniHeader
=
0x4e52
,
ERBAniHeader
=
0x4252
,
ERBAniHeader
=
0x4252
,
ERCAniHeader
=
0x4352
,
ERCAniHeader
=
0x4352
,
ERLAniHeader
=
0x4c52
,
ERLAniHeader
=
0x4c52
,
ERRAniHeader
=
0x5252
,
ERRAniHeader
=
0x5252
,
E_EHeader
=
0x455F
,
// ANI End
E_EHeader
=
0x455F
,
//
/<
ANI End
ESquareAniHeader
=
0x5b5d
,
ESquareAniHeader
=
0x5b5d
,
EMXAniHeader
=
0x584d
,
EMXAniHeader
=
0x584d
,
ESTAniHeader
=
0x5453
,
// Sound tag
ESTAniHeader
=
0x5453
,
//
/<
Sound tag
ESoundListAniHeader
=
0x4C53
,
ESoundListAniHeader
=
0x4C53
,
EPlayListAniHeader
=
0x4C50
EPlayListAniHeader
=
0x4C50
};
};
enum
/// Cutscene script types - these are the known types
{
ESignatureLength
=
0x13
,
EScriptStartTag
=
0x50
,
EAnimationData
=
0x4e41
};
// These are the known script types
enum
{
enum
{
ESceneYesNo
=
0x23
,
ESceneYesNo
=
0x23
,
ESceneMusic
=
0x2A
,
ESceneMusic
=
0x2A
,
...
@@ -111,6 +105,7 @@ enum {
...
@@ -111,6 +105,7 @@ enum {
class
Font
;
class
Font
;
/// Cutscene page text
class
SceneText
{
class
SceneText
{
public
:
public
:
...
@@ -127,6 +122,7 @@ class SceneText {
...
@@ -127,6 +122,7 @@ class SceneText {
};
};
/// Cutscene page
class
ScenePage
{
class
ScenePage
{
public
:
public
:
...
@@ -140,7 +136,7 @@ class ScenePage {
...
@@ -140,7 +136,7 @@ class ScenePage {
int
animIndex
;
int
animIndex
;
int
nextPageAfterAnim
;
int
nextPageAfterAnim
;
// Length of the scene in seconds, or if zero = anim complete, or 256 = user interaction
//
/
Length of the scene in seconds, or if zero = anim complete, or 256 = user interaction
int
pageTime
;
int
pageTime
;
SceneText
texts
[
100
];
SceneText
texts
[
100
];
int
nTexts
;
int
nTexts
;
...
@@ -153,6 +149,7 @@ class ScenePage {
...
@@ -153,6 +149,7 @@ class ScenePage {
};
};
/// Cutscene background image
class
SceneImage
{
class
SceneImage
{
public
:
public
:
...
@@ -165,6 +162,7 @@ class SceneImage {
...
@@ -165,6 +162,7 @@ class SceneImage {
};
};
/// Cutscene palette
class
ScenePalette
{
class
ScenePalette
{
public
:
public
:
...
@@ -177,6 +175,7 @@ class ScenePalette {
...
@@ -177,6 +175,7 @@ class ScenePalette {
};
};
/// Cutscene font
class
SceneFont
{
class
SceneFont
{
public
:
public
:
...
@@ -185,6 +184,7 @@ class SceneFont {
...
@@ -185,6 +184,7 @@ class SceneFont {
};
};
/// Cutscene animation frame
class
SceneFrame
class
SceneFrame
{
{
public
:
public
:
...
@@ -198,6 +198,7 @@ public:
...
@@ -198,6 +198,7 @@ public:
SceneFrame
*
prev
;
SceneFrame
*
prev
;
};
};
/// Cutscene animation
class
SceneAnimation
class
SceneAnimation
{
{
public
:
public
:
...
@@ -215,6 +216,7 @@ public:
...
@@ -215,6 +216,7 @@ public:
int
reverseAnimation
;
int
reverseAnimation
;
};
};
/// Cutscene
class
Scene
{
class
Scene
{
private
:
private
:
...
@@ -228,7 +230,7 @@ class Scene {
...
@@ -228,7 +230,7 @@ class Scene {
signed
long
int
*
scriptStarts
;
signed
long
int
*
scriptStarts
;
signed
long
int
*
dataOffsets
;
signed
long
int
*
dataOffsets
;
// Scripts all information needed to render script pages, text etc
//
/
Scripts all information needed to render script pages, text etc
ScenePage
*
pages
;
ScenePage
*
pages
;
void
loadScripts
(
File
*
f
);
void
loadScripts
(
File
*
f
);
...
...
src/scene/sceneload.cpp
View file @
4da24843
/*
/**
*
* sceneload.cpp
*
*
*
27th March 2010: Created sceneload.cpp from parts of scene
.cpp
*
@file sceneload
.cpp
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 27th March 2010: Created sceneload.cpp from parts of scene.cpp
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -17,9 +18,7 @@
...
@@ -17,9 +18,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Deals with the loading of cutscene data.
* Deals with the loading of cutscene data.
*
*
*/
*/
...
@@ -454,7 +453,7 @@ void Scene::loadData (File *f) {
...
@@ -454,7 +453,7 @@ void Scene::loadData (File *f) {
LOG
(
"Data dataLen"
,
dataLen
);
LOG
(
"Data dataLen"
,
dataLen
);
// AN
// AN
if
(
dataLen
==
EAnimationData
)
{
if
(
dataLen
==
0x4e41
)
{
LOG
(
"Data Type"
,
"ANI"
);
LOG
(
"Data Type"
,
"ANI"
);
animations
=
new
SceneAnimation
(
animations
);
animations
=
new
SceneAnimation
(
animations
);
...
@@ -532,7 +531,7 @@ void Scene::loadScripts (File *f) {
...
@@ -532,7 +531,7 @@ void Scene::loadScripts (File *f) {
bool
textRectValid
=
false
;
bool
textRectValid
=
false
;
f
->
seek
(
scriptStarts
[
loop
],
true
);
// Seek to data start
f
->
seek
(
scriptStarts
[
loop
],
true
);
// Seek to data start
if
(
f
->
loadChar
()
==
EScriptStartTag
)
{
// Script tag
if
(
f
->
loadChar
()
==
0x50
)
{
// Script tag
unsigned
short
int
scriptid
=
f
->
loadShort
();
unsigned
short
int
scriptid
=
f
->
loadShort
();
LOG
(
"Script id"
,
scriptid
);
LOG
(
"Script id"
,
scriptid
);
...
...
src/util.cpp
View file @
4da24843
/*
/*
*
*
*
* util.cpp
*
@file
util.cpp
*
*
* Part of the OpenJazz project
*
* @section History
* 22nd July 2008: Created util.c from parts of main.c
* 22nd July 2008: Created util.c from parts of main.c
* 3rd February 2009: Renamed util.c to util.cpp
* 3rd February 2009: Renamed util.c to util.cpp
* 3rd February 2009: Created file.cpp from parts of util.cpp
* 3rd February 2009: Created file.cpp from parts of util.cpp
* 4th February 2009: Created palette.cpp from parts of main.cpp and util.cpp
* 4th February 2009: Created palette.cpp from parts of main.cpp and util.cpp
* 13th July 2009: Created graphics.cpp from parts of util.cpp
* 13th July 2009: Created graphics.cpp from parts of util.cpp
*
*
* Part of the OpenJazz project
* @section Licence
*
*
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -21,9 +22,7 @@
...
@@ -21,9 +22,7 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
* @section Description
/*
* Contains core utility functions.
* Contains core utility functions.
*
*
*/
*/
...
...
src/util.h
View file @
4da24843
/*
/*
*
*
*
* util.h
* @file util.h
*
* 30th April 2010: Created util.h from parts of OpenJazz.h
*
*
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
* @section History
* 30th April 2010: Created util.h from parts of OpenJazz.h
*
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
...
@@ -29,7 +30,7 @@
...
@@ -29,7 +30,7 @@
// Variable
// Variable
// Trigonometric function look-up table
//
/
Trigonometric function look-up table
EXTERN
fixed
sinLut
[
1024
];
EXTERN
fixed
sinLut
[
1024
];
...
...
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