Skip to content

Commit

Permalink
Merge pull request jaygarcia#4 from ModusCreateOrg/work
Browse files Browse the repository at this point in the history
seems done.  Boss needs to be tested.  Code is in, but not sure it works
  • Loading branch information
jaygarcia authored Nov 11, 2020
2 parents 3b3a340 + 210f817 commit 79344b0
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 183 deletions.
7 changes: 3 additions & 4 deletions Evade2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ include(ProcessorCount)

SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/creative-engine/cmake.files)


#ADD_COMPILE_DEFINITIONS(__DINGUX__=true)
ADD_COMPILE_DEFINITIONS(__MODUS_TARGET_SDL2_AUDIO__=true)
ADD_COMPILE_DEFINITIONS(__MODUS_TARGET_DESKTOP_CONTROLS__=true)
Expand Down Expand Up @@ -48,15 +47,15 @@ INCLUDE_DIRECTORIES(
${CREATIVE_ENGINE_INCLUDE_DIRS}
)

# gather Modite sources
# gather Evade 2 sources
FILE(GLOB_RECURSE EVADE2_SRC RELATIVE ${CMAKE_SOURCE_DIR} "src/*.cpp")

ADD_EXECUTABLE(
${PROJECT_NAME}
Resources.bin
${CREATIVE_ENGINE_SOURCE_FILES}
${EVADE2_SRC}
src/GameState/GGameState.cpp src/GameState/GGameState.h src/common/GStarfield.cpp src/common/GStarfield.h src/GameState/GPlayerBulletProcess.cpp src/GameState/GPlayerBulletProcess.h src/main.cpp src/GameState/GEnemyProcess.cpp src/GameState/GEnemyProcess.h src/GameState/GEnemyBulletProcess.cpp src/GameState/GEnemyBulletProcess.h src/AttractState/GAttractState.cpp src/AttractState/GAttractState.h src/AttractState/GAttractProcess.cpp src/AttractState/GAttractProcess.h src/MainMenuState/GMainMenuState.cpp src/MainMenuState/GMainMenuState.h src/MainMenuState/GMainMenuProcess.cpp src/MainMenuState/GMainMenuProcess.h src/GameState/GNextWaveProcess.cpp src/GameState/GNextWaveProcess.h src/GameState/GBossProcess.cpp src/GameState/GBossProcess.h)
src/GameState/GGameState.cpp src/GameState/GGameState.h src/common/GStarfield.cpp src/common/GStarfield.h src/GameState/GPlayerBulletProcess.cpp src/GameState/GPlayerBulletProcess.h src/main.cpp src/GameState/GEnemyProcess.cpp src/GameState/GEnemyProcess.h src/GameState/GEnemyBulletProcess.cpp src/GameState/GEnemyBulletProcess.h src/AttractState/GAttractState.cpp src/AttractState/GAttractState.h src/AttractState/GAttractProcess.cpp src/AttractState/GAttractProcess.h src/MainMenuState/GMainMenuState.cpp src/MainMenuState/GMainMenuState.h src/MainMenuState/GMainMenuProcess.cpp src/MainMenuState/GMainMenuProcess.h src/GameState/GNextWaveProcess.cpp src/GameState/GNextWaveProcess.h src/GameState/GBossProcess.cpp src/GameState/GBossProcess.h src/GameState/GGameOverProcess.cpp src/GameState/GGameOverProcess.h)

ProcessorCount(N)
if (NOT N EQUAL 0)
Expand All @@ -69,7 +68,7 @@ BUILD_COMMAND(
$(MAKE) --silent
)

# make Modite.app
# make Evade2.app
if (APPLE)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE TRUE)
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ".")
Expand Down
168 changes: 19 additions & 149 deletions Evade2/src/GGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ GGame::GGame() {
mDifficulty = 1;
gGameEngine = ENull;
mState = 0;
mNextState = GAME_STATE_NONE;
SetState(GAME_STATE_SPLASH);
// SetState(GAME_STATE_GAME);
}
Expand Down Expand Up @@ -74,42 +75,7 @@ void GGame::SetState(GAMESTATE aNewState) {
gDisplay.SetColor(EBULLET_COLOR, 50, 50, 255);
gDisplay.SetColor(BOMB_COLOR, 255, 255, 50);

mState = aNewState;
switch (aNewState) {
case GAME_STATE_SPLASH:
printf("new State SPLASH\n");
delete gGameEngine;
gGameEngine = new GSplashState();
break;
case GAME_STATE_ATTRACT_MODE:
printf("new State ATTRACT\n");
delete gGameEngine;
gGameEngine = new GAttractState();
break;
case GAME_STATE_GAME:
printf("new State GAME\n");
delete gGameEngine;
gGameEngine = new GGameState();
break;
case GAME_STATE_MAIN_MENU:
printf("new State MAIN MENU\n");
delete gGameEngine;
gGameEngine = new GMainMenuState();
break;
case GAME_STATE_VICTORY:
printf("new State VICTORY\n");
delete gGameEngine;
gGameEngine = new GGameState();
break;
case GAME_STATE_CREDITS:
printf("new State CREDITS\n");
delete gGameEngine;
gGameEngine = new GAttractState();
break;
// case GAME_STATE_NEXT_WAVE:
// printf("new State NEXT WAVE\n");
// break;
}
mNextState = aNewState;
};

TBool GGame::IsGameState() const {
Expand All @@ -128,148 +94,52 @@ void GGame::Run() {
mShmoo.Set(TUint8(mShmoo.r + 16), TUint8(mShmoo.g + 16), TUint8(mShmoo.b + 16));
gDisplay.displayBitmap->SetColor(COLOR_SHMOO, mShmoo);
gCamera->Move();
gGameEngine->GameLoop();
gDisplay.Update();

if (gControls.WasPressed(BUTTONQ)) {
done = ETrue;
}
}

#if 0
#ifdef ENABLE_OPTIONS
TBool muted = gOptions->muted;
#endif


TBool done = EFalse;
while (!done) {
Random(); // randomize
mShmoo.Set(TUint8(mShmoo.r + 16), TUint8(mShmoo.g + 16), TUint8(mShmoo.b + 16));
Camera::Move();

gDisplay.displayBitmap->SetColor(COLOR_SHMOO, mShmoo);
gDisplay.displayBitmap->SetColor(COLOR_SHMOO_RED, mShmoo.r, 20, 20);
gDisplay.displayBitmap->SetColor(COLOR_SHMOO_GREEN, 20, mShmoo.g, 20);

// TODO: Add all the basic colors here
gDisplay.SetColor(STAR_COLOR, 180, 180, 180);
gDisplay.SetColor(COLOR_SPACE, 0, 0, 0);

// The master game loop needs to clear the screen because the star field is ALWAYS running
gDisplay.renderBitmap->Clear(COLOR_SPACE);

mStarField->Render();

if (mNextState != mState) {
mState = mNextState;
switch (mNextState) {
case GAME_STATE_SPLASH:
printf("new State SPLASH\n");
delete gGameEngine;
gGameEngine = new GSplashState();
break;
case GAME_STATE_MAIN_MENU:
delete gGameEngine;
gGameEngine = new GMainMenuState((GGameState *)gGameEngine);
break;
case GAME_STATE_MAIN_OPTIONS:
delete gGameEngine;
gGameEngine = new GMainOptionsState();
break;
case GAME_STATE_RESET_OPTIONS:
delete gGameEngine;
gGameEngine = new GResetOptionsState();
break;
case GAME_STATE_ATTRACT_MODE:
printf("new State ATTRACT\n");
delete gGameEngine;
gGameEngine = new GAttractModeState();
gGameEngine = new GAttractState();
break;
case GAME_STATE_RESET_GAME:
case GAME_STATE_GAME:
printf("new State GAME\n");
delete gGameEngine;
gGameEngine = new GGameState();
break;
case GAME_STATE_LOAD_SAVEGAME:
case GAME_STATE_RESUME_GAME:
case GAME_STATE_MAIN_MENU:
printf("new State MAIN MENU\n");
delete gGameEngine;
gGameEngine = new GGameState((char *)mLocalData);
gGameEngine = new GMainMenuState();
break;

case GAME_STATE_VICTORY:
printf("new State VICTORY\n");
delete gGameEngine;
gGameEngine = new GVictoryState((GGameState *)gGameEngine);
gGameEngine = new GGameState();
break;

case GAME_STATE_CREDITS:
printf("new State CREDITS\n");
delete gGameEngine;
gGameEngine = new GCreditsState((GGameState *)gGameEngine);
gGameEngine = new GAttractState();
break;

case GAME_STATE_QUIT:
done = ETrue;
default:
continue;
// case GAME_STATE_NEXT_WAVE:
// printf("new State NEXT WAVE\n");
// break;
}
// reset dKeys so next state doesn't react to any keys already pressed
gControls.dKeys = 0;
mState = mNextState;
}



if (mInventory) {
mInventory->GameLoop();
}
else if (mGameMenu) {
gGameEngine->GameLoop();
mGameMenu->GameLoop();
}
else if (mDebugMenu) {
gGameEngine->GameLoop();
mDebugMenu->GameLoop();
}
else {
gGameEngine->GameLoop();
}

gGameEngine->GameLoop();
gDisplay.Update();
TUint32 now = Milliseconds();
start = now;

#ifdef FRAME_RATE_INFO
TUint32 elapsed = now - start;
printf("elapsed %4d\r", elapsed);
#endif

#ifdef DEBUG_MODE
if (gControls.WasPressed(CONTROL_DEBUG)) {
if (IsGameState()) {
ToggleDebugMenu();
}
}
#endif

if (IsGameState() && gControls.WasPressed(BUTTON_START)) {
ToggleInGameMenu();
}

// right shoulder button brings up inventory
if (IsGameState() && gControls.WasPressed(CONTROL_INVENTORY)) {
ToggleInventory();
}

// TODO: @Jay there is no BUTTONQ on device... maybe we want to exit the game on device by some keys?
if (gControls.WasPressed(BUTTONQ)) {
done = ETrue;
}
#ifdef ENABLE_OPTIONS
if (gControls.WasPressed(BUTTON2)) {
muted = !muted;
gOptions->muted = muted;
gOptions->Save();
#ifdef ENABLE_AUDIO
// //gSoundPlayer.MuteMusic(muted);
#endif
}
#endif
}
#endif
}
7 changes: 4 additions & 3 deletions Evade2/src/GGame.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#ifndef BRICKOUT_GGAME_H
#define BRICKOUT_GGAME_H

//#include "Game.h"
#include <BApplication.h>
//#include "GStarFieldProcess.h"

class BGameEngine;

class BFont;

enum GAMESTATE {
GAME_STATE_NONE,
GAME_STATE_SPLASH,
GAME_STATE_MAIN_MENU,
GAME_STATE_ATTRACT_MODE,
Expand Down Expand Up @@ -37,7 +36,9 @@ class GGame : public BApplication {

TUint8 mDifficulty;
static TBool mDebug;

protected:
TInt mNextState;
TInt mState;
TRGB mShmoo;
};
Expand All @@ -46,4 +47,4 @@ extern GGame *gGame;
extern BGameEngine *gGameEngine;
extern BFont *gFont8x8, *gFont16x16;

#endif //BRICKOUT_GGAME_H
#endif //GGame.h
39 changes: 39 additions & 0 deletions Evade2/src/GameState/GGameOverProcess.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Created by Michael Schwartz on 11/10/20.
//

#include "GGameOverProcess.h"
#include "GGameState.h"
#include "GMainMenuState.h"
#include "GCamera.h"

GGameOverProcess::GGameOverProcess() : BProcess() {
gGameState->mState = STATE_GAME_OVER;
mTheta = 0;
mTimer = 200;
gCamera->vx = gCamera->vy = 0;
gCamera->vz = CAMERA_WARP_VZ;
gControls.Reset();
// TODO: @Jay game over sound here
}

GGameOverProcess::~GGameOverProcess() noexcept = default;

TBool GGameOverProcess::RunBefore() {
if (mTimer-- < 0) {
gGame->SetState(GAME_STATE_MAIN_MENU);
return EFalse;
}
return ETrue;
}

TBool GGameOverProcess::RunAfter() {
mTheta += 6;
gVectorFont->scale = 3;
gVectorFont->color = COLOR_SHMOO;
gVectorFont->print_string_rotatedx(53, 80, mTheta, "GAME OVER");
gVectorFont->scale = 1.5;
gVectorFont->color = COLOR_WHITE;
gVectorFont->printf(gGameState->mWave < 9 ? 50 : 45, 160, "WAVES SURVIVED: %d", gGameState->mWave - 1);
return ETrue;
}
24 changes: 24 additions & 0 deletions Evade2/src/GameState/GGameOverProcess.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Created by Michael Schwartz on 11/10/20.
//

#ifndef EVADE2_GGAMEOVERPROCESS_H
#define EVADE2_GGAMEOVERPROCESS_H

#include "Game.h"

class GGameOverProcess : public BProcess {
public:
GGameOverProcess();
~GGameOverProcess();

public:
TBool RunBefore();
TBool RunAfter();
protected:
TFloat mTheta;
TInt16 mTimer;
};


#endif //EVADE2_GGAMEOVERPROCESS_H
2 changes: 1 addition & 1 deletion Evade2/src/GameState/GGameState.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum {
STATE_PLAY,
STATE_BOSS,
STATE_NEXT_WAVE,
STATE_GAME_OVER
};

class GPlayerProcess;
Expand All @@ -29,7 +30,6 @@ class GGameState : public BGameEngine {
TInt32 mState;
TInt16 mKills;
TInt16 mWave;

};

extern GGameState *gGameState;
Expand Down
Loading

0 comments on commit 79344b0

Please sign in to comment.