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
806e2402
Commit
806e2402
authored
Oct 03, 2010
by
alistert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created LocalGame class from parts of the Game class.
parent
4da24843
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
184 additions
and
127 deletions
+184
-127
Makefile
Makefile
+1
-1
Makefile.arm
Makefile.arm
+1
-1
Makefile.debian
Makefile.debian
+1
-1
Makefile.dingoo
Makefile.dingoo
+2
-2
game.cpp
src/game/game.cpp
+10
-112
game.h
src/game/game.h
+24
-9
localgame.cpp
src/game/localgame.cpp
+144
-0
gamemenu.cpp
src/menu/gamemenu.cpp
+1
-1
No files found.
Makefile
View file @
806e2402
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
objects
=
src/bonus/bonus.o
\
objects
=
src/bonus/bonus.o
\
src/game/clientgame.o src/game/game.o src/game/gamemode.o
\
src/game/clientgame.o src/game/game.o src/game/gamemode.o
\
src/game/servergame.o
\
src/game/
localgame.o src/game/
servergame.o
\
src/io/gfx/anim.o src/io/gfx/font.o src/io/gfx/paletteeffects.o
\
src/io/gfx/anim.o src/io/gfx/font.o src/io/gfx/paletteeffects.o
\
src/io/gfx/sprite.o src/io/gfx/video.o
\
src/io/gfx/sprite.o src/io/gfx/video.o
\
src/io/gfx/scale2x/getopt.o src/io/gfx/scale2x/pixel.o
\
src/io/gfx/scale2x/getopt.o src/io/gfx/scale2x/pixel.o
\
...
...
Makefile.arm
View file @
806e2402
...
@@ -45,7 +45,7 @@ endif
...
@@ -45,7 +45,7 @@ endif
OBJS
=
src/bonus/bonus.o
\
OBJS
=
src/bonus/bonus.o
\
src/game/clientgame.o src/game/game.o src/game/gamemode.o
\
src/game/clientgame.o src/game/game.o src/game/gamemode.o
\
src/game/servergame.o
\
src/game/
localgame.o src/game/
servergame.o
\
src/io/gfx/anim.o src/io/gfx/font.o src/io/gfx/paletteeffects.o
\
src/io/gfx/anim.o src/io/gfx/font.o src/io/gfx/paletteeffects.o
\
src/io/gfx/sprite.o src/io/gfx/video.o
\
src/io/gfx/sprite.o src/io/gfx/video.o
\
src/io/gfx/scale2x/getopt.o src/io/gfx/scale2x/pixel.o
\
src/io/gfx/scale2x/getopt.o src/io/gfx/scale2x/pixel.o
\
...
...
Makefile.debian
View file @
806e2402
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
objects
=
src/bonus/bonus.o
\
objects
=
src/bonus/bonus.o
\
src/game/clientgame.o src/game/game.o src/game/gamemode.o
\
src/game/clientgame.o src/game/game.o src/game/gamemode.o
\
src/game/servergame.o
\
src/game/
localgame.o src/game/
servergame.o
\
src/io/gfx/anim.o src/io/gfx/font.o src/io/gfx/paletteeffects.o
\
src/io/gfx/anim.o src/io/gfx/font.o src/io/gfx/paletteeffects.o
\
src/io/gfx/sprite.o src/io/gfx/video.o
\
src/io/gfx/sprite.o src/io/gfx/video.o
\
src/io/gfx/scale2x/getopt.o src/io/gfx/scale2x/pixel.o
\
src/io/gfx/scale2x/getopt.o src/io/gfx/scale2x/pixel.o
\
...
...
Makefile.dingoo
View file @
806e2402
...
@@ -6,7 +6,7 @@ INCLUDE=/opt/mipsel-linux-uclibc/usr/include
...
@@ -6,7 +6,7 @@ INCLUDE=/opt/mipsel-linux-uclibc/usr/include
objects
=
src/bonus/bonus.o
\
objects
=
src/bonus/bonus.o
\
src/game/clientgame.o src/game/game.o src/game/gamemode.o
\
src/game/clientgame.o src/game/game.o src/game/gamemode.o
\
src/game/servergame.o
\
src/game/
localgame.o src/game/
servergame.o
\
src/io/gfx/anim.o src/io/gfx/font.o src/io/gfx/paletteeffects.o
\
src/io/gfx/anim.o src/io/gfx/font.o src/io/gfx/paletteeffects.o
\
src/io/gfx/sprite.o src/io/gfx/video.o
\
src/io/gfx/sprite.o src/io/gfx/video.o
\
src/io/gfx/scale2x/getopt.o src/io/gfx/scale2x/pixel.o
\
src/io/gfx/scale2x/getopt.o src/io/gfx/scale2x/pixel.o
\
...
...
src/game/game.cpp
View file @
806e2402
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
* 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
* 3rd October 2010: Created localgame.cpp from parts of game.cpp
*
*
* @section Licence
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
...
@@ -28,14 +29,11 @@
...
@@ -28,14 +29,11 @@
#include "gamemode.h"
#include "gamemode.h"
#include "bonus/bonus.h"
#include "bonus/bonus.h"
#include "io/controls.h"
#include "io/gfx/font.h"
#include "io/gfx/video.h"
#include "io/gfx/video.h"
#include "io/sound.h"
#include "io/sound.h"
#include "jj2level/jj2level.h"
#include "jj2level/jj2level.h"
#include "level/level.h"
#include "level/level.h"
#include "planet/planet.h"
#include "planet/planet.h"
#include "player/bonusplayer.h"
#include "player/levelplayer.h"
#include "player/levelplayer.h"
#include "util.h"
#include "util.h"
...
@@ -56,30 +54,6 @@ Game::Game () {
...
@@ -56,30 +54,6 @@ 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
)
{
levelFile
=
createString
(
firstLevel
);
difficulty
=
gameDifficulty
;
mode
=
new
SingleGameMode
();
// Create the player
nPlayers
=
1
;
localPlayer
=
players
=
new
Player
[
1
];
localPlayer
->
init
(
characterName
,
NULL
,
0
);
return
;
}
/**
/**
* Destroy game
* Destroy game
*/
*/
...
@@ -145,25 +119,6 @@ GameMode* Game::getMode () {
...
@@ -145,25 +119,6 @@ GameMode* Game::getMode () {
}
}
/**
* Set the next level
*
* @param fileName The file name of the next level
*
* @return Error code
*/
int
Game
::
setLevel
(
char
*
fileName
)
{
if
(
levelFile
)
delete
[]
levelFile
;
if
(
fileName
)
levelFile
=
createString
(
fileName
);
else
levelFile
=
NULL
;
return
E_NONE
;
}
/**
/**
* Play the game
* Play the game
*
*
...
@@ -171,9 +126,6 @@ int Game::setLevel (char *fileName) {
...
@@ -171,9 +126,6 @@ int Game::setLevel (char *fileName) {
*/
*/
int
Game
::
play
()
{
int
Game
::
play
()
{
Planet
*
planet
;
Bonus
*
bonus
;
char
*
fileName
;
bool
multiplayer
;
bool
multiplayer
;
bool
checkpoint
;
bool
checkpoint
;
int
ret
;
int
ret
;
...
@@ -195,6 +147,8 @@ int Game::play () {
...
@@ -195,6 +147,8 @@ int Game::play () {
if
(
!
strncasecmp
(
levelFile
,
F_BONUSMAP
,
8
))
{
if
(
!
strncasecmp
(
levelFile
,
F_BONUSMAP
,
8
))
{
Bonus
*
bonus
;
try
{
try
{
baseLevel
=
bonus
=
new
Bonus
(
levelFile
,
difficulty
,
multiplayer
);
baseLevel
=
bonus
=
new
Bonus
(
levelFile
,
difficulty
,
multiplayer
);
...
@@ -218,6 +172,8 @@ int Game::play () {
...
@@ -218,6 +172,8 @@ int Game::play () {
}
else
if
(
ret
==
WON
)
{
}
else
if
(
ret
==
WON
)
{
char
*
fileName
;
// Go to next level
// Go to next level
fileName
=
createFileName
(
F_BONUSMAP
,
(
levelFile
[
10
]
*
10
)
+
levelFile
[
11
]
-
527
);
fileName
=
createFileName
(
F_BONUSMAP
,
(
levelFile
[
10
]
*
10
)
+
levelFile
[
11
]
-
527
);
setLevel
(
fileName
);
setLevel
(
fileName
);
...
@@ -287,7 +243,9 @@ int Game::play () {
...
@@ -287,7 +243,9 @@ int Game::play () {
if
(
!
multiplayer
)
{
if
(
!
multiplayer
)
{
planet
=
NULL
;
Planet
*
planet
;
char
*
fileName
;
fileName
=
createFileName
(
F_PLANET
,
level
->
getWorld
());
fileName
=
createFileName
(
F_PLANET
,
level
->
getWorld
());
try
{
try
{
...
@@ -296,7 +254,7 @@ int Game::play () {
...
@@ -296,7 +254,7 @@ int Game::play () {
}
catch
(
int
e
)
{
}
catch
(
int
e
)
{
// Do nothing
planet
=
NULL
;
}
}
...
@@ -381,66 +339,6 @@ void Game::view (int change) {
...
@@ -381,66 +339,6 @@ 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
)
{
// Do nothing
return
;
}
/**
* Game iteration
*
* @param ticks Current time
*
* @return Error code
*/
int
Game
::
step
(
unsigned
int
ticks
)
{
// Do nothing
return
E_NONE
;
}
/**
* Assign point to team
*
* @param team Team to receive point
*/
void
Game
::
score
(
unsigned
char
team
)
{
// Do nothing
return
;
}
/**
* 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
)
{
checkX
=
gridX
;
checkY
=
gridY
;
return
;
}
/**
/**
* Make a player restart the level from the beginning/last checkpoint
* Make a player restart the level from the beginning/last checkpoint
*
*
...
...
src/game/game.h
View file @
806e2402
...
@@ -84,7 +84,7 @@
...
@@ -84,7 +84,7 @@
class
Anim
;
class
Anim
;
class
File
;
class
File
;
///
Handling for single-player games and base class for multiplaye
r game handling classes
///
Base class fo
r game handling classes
class
Game
{
class
Game
{
protected
:
protected
:
...
@@ -101,23 +101,38 @@ class Game {
...
@@ -101,23 +101,38 @@ class Game {
GameMode
*
createMode
(
GameModeType
modeType
);
GameMode
*
createMode
(
GameModeType
modeType
);
public
:
public
:
Game
(
char
*
firstLevel
,
int
gameDifficulty
);
virtual
~
Game
();
virtual
~
Game
();
GameMode
*
getMode
();
GameMode
*
getMode
();
virtual
int
setLevel
(
char
*
fileName
);
virtual
int
setLevel
(
char
*
fileName
)
=
0
;
int
play
();
int
play
();
void
view
(
int
change
);
void
view
(
int
change
);
virtual
void
send
(
unsigned
char
*
buffer
);
virtual
void
send
(
unsigned
char
*
buffer
)
=
0
;
virtual
int
step
(
unsigned
int
ticks
);
virtual
int
step
(
unsigned
int
ticks
)
=
0
;
virtual
void
score
(
unsigned
char
team
);
virtual
void
score
(
unsigned
char
team
)
=
0
;
virtual
void
setCheckpoint
(
unsigned
char
gridX
,
unsigned
char
gridY
);
virtual
void
setCheckpoint
(
unsigned
char
gridX
,
unsigned
char
gridY
)
=
0
;
void
resetPlayer
(
Player
*
player
);
void
resetPlayer
(
Player
*
player
);
void
resetPlayer
(
Player
*
player
,
LevelType
levelType
,
Anim
**
anims
);
void
resetPlayer
(
Player
*
player
,
LevelType
levelType
,
Anim
**
anims
);
};
};
/// Game handling for single-player local play
class
LocalGame
:
public
Game
{
public
:
LocalGame
(
char
*
firstLevel
,
int
gameDifficulty
);
~
LocalGame
();
int
setLevel
(
char
*
fileName
);
void
send
(
unsigned
char
*
buffer
);
int
step
(
unsigned
int
ticks
);
void
score
(
unsigned
char
team
);
void
setCheckpoint
(
unsigned
char
gridX
,
unsigned
char
gridY
);
};
/// Game handling for multiplayer servers
/// Game handling for multiplayer servers
class
ServerGame
:
public
Game
{
class
ServerGame
:
public
Game
{
...
...
src/game/localgame.cpp
0 → 100644
View file @
806e2402
/**
*
* @file localgame.cpp
*
* Part of the OpenJazz project
*
* @section History
* 3rd October 2010: Created localgame.cpp from parts of game.cpp
*
* @section Licence
* Copyright (c) 2005-2010 Alister Thomson
*
* 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 "game.h"
#include "gamemode.h"
#include "player/player.h"
#include "util.h"
/**
* Create a single-player local game
*
* @param firstLevel File name of the first level to play
* @param gameDifficulty Difficulty setting
*/
LocalGame
::
LocalGame
(
char
*
firstLevel
,
int
gameDifficulty
)
{
levelFile
=
createString
(
firstLevel
);
difficulty
=
gameDifficulty
;
mode
=
new
SingleGameMode
();
// Create the player
nPlayers
=
1
;
localPlayer
=
players
=
new
Player
[
1
];
localPlayer
->
init
(
characterName
,
NULL
,
0
);
return
;
}
/**
* Destroy local game
*/
LocalGame
::~
LocalGame
()
{
delete
mode
;
return
;
}
/**
* Set the next level
*
* @param fileName The file name of the next level
*
* @return Error code
*/
int
LocalGame
::
setLevel
(
char
*
fileName
)
{
if
(
levelFile
)
delete
[]
levelFile
;
if
(
fileName
)
levelFile
=
createString
(
fileName
);
else
levelFile
=
NULL
;
return
E_NONE
;
}
/**
* No data is sent in local games
*
* @param buffer Data that will not be sent. First byte indicates length.
*/
void
LocalGame
::
send
(
unsigned
char
*
buffer
)
{
// Do nothing
return
;
}
/**
* Game iteration - nothing to be done in local games
*
* @param ticks Current time
*
* @return Error code
*/
int
LocalGame
::
step
(
unsigned
int
ticks
)
{
// Do nothing
return
E_NONE
;
}
/**
* No points are assigned to teams in local games
*
* @param team Team to receive point
*/
void
LocalGame
::
score
(
unsigned
char
team
)
{
// Do nothing
return
;
}
/**
* Set the checkpoint
*
* @param gridX X-coordinate (in tiles) of the checkpoint
* @param gridY Y-coordinate (in tiles) of the checkpoint
*/
void
LocalGame
::
setCheckpoint
(
unsigned
char
gridX
,
unsigned
char
gridY
)
{
checkX
=
gridX
;
checkY
=
gridY
;
return
;
}
src/menu/gamemenu.cpp
View file @
806e2402
...
@@ -156,7 +156,7 @@ int GameMenu::newGameDifficulty (GameModeType mode, char* firstLevel) {
...
@@ -156,7 +156,7 @@ int GameMenu::newGameDifficulty (GameModeType mode, char* firstLevel) {
try
{
try
{
game
=
new
Game
(
firstLevel
,
difficulty
);
game
=
new
Local
Game
(
firstLevel
,
difficulty
);
}
catch
(
int
e
)
{
}
catch
(
int
e
)
{
...
...
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