diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Game.h | 341 | ||||
-rw-r--r-- | src/GameInitDispose.cpp | 21 | ||||
-rw-r--r-- | src/Main.cpp | 22 | ||||
-rw-r--r-- | src/Textures.h | 6 |
4 files changed, 200 insertions, 190 deletions
diff --git a/src/Game.h b/src/Game.h index 8d3d7fc..154fbc3 100644 --- a/src/Game.h +++ b/src/Game.h @@ -1,5 +1,26 @@ -#ifndef _GAME_H_ -#define _GAME_H_ +// Game object +// Copyright (C) 2002 David Rosen +// Copyright (C) 2003 Steven Fuller +// Copyright (C) 2003 Zachary Jack Slater +// Copyright (C) 2021 Nguyễn Gia Phong +// +// This file is part of Black Shades. +// +// Black Shades is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Black Shades is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Black Shades. If not, see <https://www.gnu.org/licenses/>. + +#ifndef BLACKSHADES_GAME_H +#define BLACKSHADES_GAME_H #include <GL/gl.h> #include <GL/glu.h> @@ -30,174 +51,150 @@ #define max_people 90 #define max_people_block 20 -class Game -{ - void saveHighScore(); - void updateSong(); - void handleMenu(); - public: - //Eventloop - Boolean gQuit; - float gamespeed; - double multiplier2,multiplier3,multiplier4,multiplier5,end,start,timetaken,framespersecond; - timer theTimer; - float sps; - int maxfps; - - //Graphics - int screenwidth,screenheight; - float viewdistance; - - //GL functions - GLvoid ReSizeGLScene(float fov, float near); - int DrawGLScene(void); - int InitGL(void); - void LoadingScreen(float percent); - - //Game Functions - void HandleKeyDown( char theChar ); - void EventLoop( void ); - void Tick(); - void Splat(int k); - void InitGame(); - void Dispose(); - - //Mouse - Point mouseloc; - Point oldmouseloc; - - float mouserotation,mouserotation2; - float oldmouserotation,oldmouserotation2; - float mousesensitivity; - float usermousesensitivity; - - //keyboard - - bool tabkeydown; - - //Project Specific - int cityrotation[num_blocks][num_blocks]; - int citytype[num_blocks][num_blocks]; - int citypeoplenum[num_blocks][num_blocks]; - bool drawn[num_blocks][num_blocks]; - int onblockx,onblocky; - bool cubetest; - bool disttest; - bool oldbutton; - - bool initialized; - - float flashamount; - float flashr,flashg,flashb; - - int enemystate; - - int cycle; - - bool whacked; - - float losedelay; - - XYZ bodycoords; - - FRUSTUM frustum; - Model blocks[4]; - Model blockwalls[4]; - Model blockcollide[4]; - Model blocksimplecollide[4]; - Model blockroofs[4]; - Model blockocclude; - Model sidewalkcollide; - Model street; - Model Bigstreet; - Model path; - Model blocksimple; - XYZ boundingpoints[8]; - Files files; - Text text; - int goodkills; - int badkills; - int civkills; - int machinegunsoundloop; - - bool lasersight; - bool debug; - bool vblsync; - - bool blur; - bool blurness; - - bool paused; - - int mainmenu; - - bool reloadtoggle; - - bool aimtoggle; - - Point olddrawmouse; - - XYZ vipgoal; - - XYZ aimer[2]; - - double eqn[4]; - - float oldrot,oldrot2; - - XYZ lastshot[2]; - bool zoom; - bool oldzoom; - - int numpeople; - float spawndelay; - - bool customlevels; - - bool musictoggle; - - float psychicpower; - - int type; - - bool slomokeydown; - - int mouseoverbutton; - int oldmouseoverbutton; - - Person person[max_people]; - - GLuint personspritetextureptr; - GLuint deadpersonspritetextureptr; - GLuint scopetextureptr; - GLuint flaretextureptr; - - bool killedinnocent; - bool gameinprogress; - bool beatgame; - bool mainmenuness; - int murderer; - float timeremaining; - int whichsong; - int oldscore; - int highscore; - int score; - int mission; - int nummissions; - int numpossibleguns; - int possiblegun[6]; - int evilprobability; - float difficulty; - bool azertykeyboard; - bool oldvisionkey; - - ~Game() { - glDeleteTextures( 1, (const GLuint *)personspritetextureptr ); - glDeleteTextures( 1, (const GLuint *)deadpersonspritetextureptr ); - glDeleteTextures( 1, (const GLuint *)scopetextureptr ); - glDeleteTextures( 1, (const GLuint *)flaretextureptr ); - } - +class Game { + void saveHighScore(); + void updateSong(); + void handleMenu(); +public: + // Event loop + Boolean gQuit; + float gamespeed; + double multiplier2, multiplier3, multiplier4, multiplier5; + double end, start, timetaken, framespersecond; + timer theTimer; + float sps; + int maxfps; + + // Graphics + int screenwidth, screenheight; + float viewdistance; + + // Mouse + Point mouseloc; + Point oldmouseloc; + float mouserotation,mouserotation2; + float oldmouserotation,oldmouserotation2; + float mousesensitivity; + float usermousesensitivity; + + // Keyboard + bool tabkeydown; + + // Project specific + int cityrotation[num_blocks][num_blocks]; + int citytype[num_blocks][num_blocks]; + int citypeoplenum[num_blocks][num_blocks]; + bool drawn[num_blocks][num_blocks]; + int onblockx, onblocky; + bool cubetest; + bool disttest; + bool oldbutton; + + bool initialized; + + float flashamount; + float flashr,flashg,flashb; + + int enemystate; + int cycle; + bool whacked; + float losedelay; + XYZ bodycoords; + + FRUSTUM frustum; + Model blocks[4]; + Model blockwalls[4]; + Model blockcollide[4]; + Model blocksimplecollide[4]; + Model blockroofs[4]; + Model blockocclude; + Model sidewalkcollide; + Model street; + Model Bigstreet; + Model path; + Model blocksimple; + XYZ boundingpoints[8]; + Files files; + Text text; + int goodkills; + int badkills; + int civkills; + int machinegunsoundloop; + + bool lasersight; + bool debug; + bool vblsync; + + bool blur; + bool blurness; + + bool paused; + int mainmenu; + + bool reloadtoggle; + bool aimtoggle; + + Point olddrawmouse; + XYZ vipgoal; + XYZ aimer[2]; + + double eqn[4]; + float oldrot, oldrot2; + + XYZ lastshot[2]; + bool zoom; + bool oldzoom; + + int numpeople; + float spawndelay; + + bool customlevels; + bool musictoggle; + float psychicpower; + int type; + bool slomokeydown; + + int mouseoverbutton; + int oldmouseoverbutton; + + Person person[max_people]; + + GLuint personspritetextureptr; + GLuint deadpersonspritetextureptr; + GLuint scopetextureptr; + GLuint flaretextureptr; + + bool killedinnocent; + bool gameinprogress; + bool beatgame; + bool mainmenuness; + int murderer; + float timeremaining; + int whichsong; + int oldscore; + int highscore; + int score; + int mission; + int nummissions; + int numpossibleguns; + int possiblegun[6]; + int evilprobability; + float difficulty; + bool azertykeyboard; + bool oldvisionkey; + + // GL functions + GLvoid ReSizeGLScene(float fov, float near); + int DrawGLScene(); + int InitGL(); + void LoadingScreen(float percent); + + // Game functions + void HandleKeyDown(char theChar); + void EventLoop(); + void Tick(); + void Splat(int k); + void InitGame(); + ~Game(); }; - -#endif +#endif // BLACKSHADES_GAME_H diff --git a/src/GameInitDispose.cpp b/src/GameInitDispose.cpp index 8725f40..9a0435d 100644 --- a/src/GameInitDispose.cpp +++ b/src/GameInitDispose.cpp @@ -13,7 +13,6 @@ extern Skeleton testskeleton; extern Sprites sprites; extern Decals decals; -/*********************> InitGame()<*****/ extern Model skeletonmodels[10]; extern Model gunmodels[10]; extern Costume costume[10]; @@ -2131,8 +2130,6 @@ void Game::InitGame() oldscore=score; } -/*********************> InitGL() <*****/ - int Game::InitGL(void) { //Config @@ -2292,15 +2289,6 @@ int Game::InitGL(void) return TRUE; } -//***************> Dispose() <******/ -void Game::Dispose() -{ - //Delete sound sources - alDeleteSources(100, gSourceID); -} - -//***************> ResizeGLScene() <******/ - GLvoid Game::ReSizeGLScene(float fov, float near) { if (screenheight==0) @@ -2313,3 +2301,12 @@ GLvoid Game::ReSizeGLScene(float fov, float near) glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } + +Game::~Game() +{ + alDeleteSources(100, gSourceID); // delete sound sources + glDeleteTextures(1, (const GLuint*) personspritetextureptr); + glDeleteTextures(1, (const GLuint*) deadpersonspritetextureptr); + glDeleteTextures(1, (const GLuint*) scopetextureptr); + glDeleteTextures(1, (const GLuint*) flaretextureptr); +} diff --git a/src/Main.cpp b/src/Main.cpp index 46f7c12..5873425 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1,8 +1,25 @@ -/********************> Headers <*****/ +// Main function +// Copyright (C) 2002 David Rosen +// Copyright (C) 2021 Nguyễn Gia Phong +// +// This file is part of Black Shades. +// +// Black Shades is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Black Shades is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Black Shades. If not, see <https://www.gnu.org/licenses/>. #include "Game.h" -/********************> Globals <*****/ +// Globals are zero-initialized. Game game; int main(int argc, char *argv[]) @@ -10,5 +27,4 @@ int main(int argc, char *argv[]) game.InitGL(); game.InitGame(); game.EventLoop(); - game.Dispose(); } diff --git a/src/Textures.h b/src/Textures.h index 4332d26..9c1a60f 100644 --- a/src/Textures.h +++ b/src/Textures.h @@ -16,8 +16,8 @@ // You should have received a copy of the GNU General Public License // along with Black Shades. If not, see <https://www.gnu.org/licenses/>. -#ifndef TEXTURES_H -#define TEXTURES_H +#ifndef BLACKSHADES_TEXTURES_H +#define BLACKSHADES_TEXTURES_H #include <SDL/SDL.h> #include <GL/gl.h> @@ -25,4 +25,4 @@ GLuint loadTexture(const char* filename, GLenum minFilter = GL_LINEAR, GLenum magFilter = GL_LINEAR, bool mipmaps = true); -#endif // TEXTURES_H +#endif // BLACKSHADES_TEXTURES_H |