aboutsummaryrefslogtreecommitdiff
path: root/src/GameLoop.cpp
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2021-06-21 18:11:55 +0700
committerNguyễn Gia Phong <mcsinyx@disroot.org>2021-06-21 21:31:11 +0700
commit325dca9f212f9fd44cd10a8180529970c7a08c72 (patch)
treee1cfaec078dfa49f4d51d05eef8a5b0967843a41 /src/GameLoop.cpp
parent10f5376de856ecead4e8bbf66f19157f36f7a382 (diff)
downloadblackshades-325dca9f212f9fd44cd10a8180529970c7a08c72.tar.gz
Remove trailing whitespaces and duplicated blank lines1.2.0
Diffstat (limited to 'src/GameLoop.cpp')
-rw-r--r--src/GameLoop.cpp84
1 files changed, 25 insertions, 59 deletions
diff --git a/src/GameLoop.cpp b/src/GameLoop.cpp
index 8a72b4b..eec916c 100644
--- a/src/GameLoop.cpp
+++ b/src/GameLoop.cpp
@@ -1,6 +1,4 @@
-#include "Game.h"
-
-
+#include "Game.h"
extern double multiplier;
@@ -25,20 +23,17 @@ extern int slomo;
void Game::HandleKeyDown( char theChar )
{
-
XYZ facing;
-
-
if(!mainmenu){
switch( theChar )
{
- case 'l':
- if(!lasersight==1){lasersight=1;}else{lasersight=0;}
-
+ case 'l':
+ if(!lasersight==1){lasersight=1;}else{lasersight=0;}
+
break;
case 'k':
@@ -47,8 +42,6 @@ void Game::HandleKeyDown( char theChar )
break;
-
-
case 'b':
if(debug){
@@ -66,7 +59,6 @@ void Game::HandleKeyDown( char theChar )
alSourcef(gSourceID[shootsong], AL_PITCH, (ALfloat)(.5));
alSourcef(gSourceID[zombiesong], AL_PITCH, (ALfloat)(.5));
-
}
if(!slomo){
@@ -103,13 +95,11 @@ void Game::HandleKeyDown( char theChar )
facing.z=-1;
-
-
facing=DoRotation(facing,-camera.rotation2,0,0);
facing=DoRotation(facing,0,0-camera.rotation,0);
- for(int i=1;i<numpeople;i++){
+ for(int i=1;i<numpeople;i++){
if(person[i].skeleton.free!=1){
@@ -171,21 +161,15 @@ void Game::HandleKeyDown( char theChar )
}
-
-
/********************> DoEvent() <*****/
-#ifdef OS9
+#ifdef OS9
void Game::DoEvent( EventRecord *event )
{
-
-
char theChar;
-
-
switch ( event->what )
{
@@ -202,14 +186,10 @@ void Game::DoEvent( EventRecord *event )
}
-
-
-
-
}
#endif
-#ifndef OS9
+#ifndef OS9
static int mapinit = 0;
static int sdlkeymap[SDLK_LAST];
@@ -218,11 +198,11 @@ static unsigned char ourkeys[16];
static void init_sdlkeymap()
{
int i;
-
+
for (i = 0; i < SDLK_LAST; i++) {
sdlkeymap[i] = -1;
}
-
+
sdlkeymap[SDLK_1] = MAC_1_KEY;
sdlkeymap[SDLK_2] = MAC_2_KEY;
sdlkeymap[SDLK_3] = MAC_3_KEY;
@@ -306,7 +286,7 @@ static void init_sdlkeymap()
sdlkeymap[SDLK_DOWN] = MAC_ARROW_DOWN_KEY;
sdlkeymap[SDLK_LEFT] = MAC_ARROW_LEFT_KEY;
sdlkeymap[SDLK_RIGHT] = MAC_ARROW_RIGHT_KEY;
-
+
mapinit = 1;
}
@@ -322,39 +302,37 @@ static void DoSDLKey(Game *g, SDL_Event *event)
int mackey;
int index;
int mask;
-
if (mapinit == 0) {
init_sdlkeymap();
}
-
+
mackey = sdlkeymap[event->key.keysym.sym];
-
+
if (mackey != -1) {
index = mackey / 8;
mask = 1 << (mackey % 8);
-
+
if (press) {
ourkeys[index] |= mask;
} else {
ourkeys[index] &= ~mask;
}
}
-
- if (event->key.keysym.unicode &&
+
+ if (event->key.keysym.unicode &&
!(event->key.keysym.unicode & 0xFF80)) {
-
+
/* hey, at least it was aleady public */
g->HandleKeyDown(event->key.keysym.unicode);
}
-
-
+
}
static void ProcessSDLEvents(Game *g)
{
SDL_Event event;
-
+
if (SDL_PollEvent(&event)) {
do {
switch(event.type) {
@@ -388,7 +366,7 @@ static void ProcessSDLEvents(Game *g)
}
} while (SDL_PollEvent(&event));
}
-}
+}
#endif
@@ -398,7 +376,7 @@ void Game::EventLoop( void )
{
-#ifdef OS9
+#ifdef OS9
EventRecord event;
#endif
@@ -414,25 +392,20 @@ void Game::EventLoop( void )
{
-#ifdef OS9
+#ifdef OS9
if ( GetNextEvent( everyEvent, &event ) )
DoEvent( &event );
#else
ProcessSDLEvents(this);
#endif
-
start=TimerGetTime(&theTimer);
-
-
colaccuracy=sps/framespersecond+1;
if(colaccuracy>sps){colaccuracy=sps;}
-
-
oldmult=multiplier;
multiplier/=colaccuracy;
@@ -445,11 +418,9 @@ void Game::EventLoop( void )
multiplier=oldmult;
-
-
if ( DrawGLScene())
-#ifdef OS9
+#ifdef OS9
aglSwapBuffers( gOpenGLContext );
#else
SDL_GL_SwapBuffers();
@@ -459,9 +430,7 @@ void Game::EventLoop( void )
gQuit = true;
- oldmult=multiplier;
-
-
+ oldmult=multiplier;
end=TimerGetTime(&theTimer);
@@ -509,8 +478,8 @@ void Game::EventLoop( void )
highscore=score;
-#ifdef OS9
- ofstream opstream(":Data:Highscore");
+#ifdef OS9
+ ofstream opstream(":Data:Highscore");
#else
/* TODO */
ofstream opstream("Data/Highscore");
@@ -532,8 +501,6 @@ void Game::EventLoop( void )
alSourcePause(gSourceID[rainsound]);
-
-
mainmenu=1;
alSourcePlay(gSourceID[souloutsound]);
@@ -569,5 +536,4 @@ void Game::EventLoop( void )
}
}
-
}