Skip to content

Commit

Permalink
almost done... need to test Boss, need to implement asteroids, need t…
Browse files Browse the repository at this point in the history
…o respawn enemies/etc. after boss, needs game over
  • Loading branch information
mschwartz committed Nov 7, 2020
1 parent 1a5c6aa commit bced345
Show file tree
Hide file tree
Showing 28 changed files with 989 additions and 252 deletions.
69 changes: 30 additions & 39 deletions Evade2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,63 +25,54 @@ INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/creative-engine/CreativeEngine.cmake)


SET(EVADE2_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/resources
${CMAKE_SOURCE_DIR}/src/common
# ${CMAKE_SOURCE_DIR}/src/LoadGameState
${CMAKE_SOURCE_DIR}/src/GameState
# ${CMAKE_SOURCE_DIR}/src/GameState/environment
# ${CMAKE_SOURCE_DIR}/src/GameState/player
# ${CMAKE_SOURCE_DIR}/src/GameState/inventory
# ${CMAKE_SOURCE_DIR}/src/GameState/enemies
# ${CMAKE_SOURCE_DIR}/src/GameState/enemies/final-boss
# ${CMAKE_SOURCE_DIR}/src/GameState/enemies/grunts
# ${CMAKE_SOURCE_DIR}/src/GameState/enemies/mid-bosses
# ${CMAKE_SOURCE_DIR}/src/GameState/status
# ${CMAKE_SOURCE_DIR}/src/img/
# ${CMAKE_SOURCE_DIR}/src/AttractState
# ${CMAKE_SOURCE_DIR}/src/GameMenuState
# ${CMAKE_SOURCE_DIR}/src/DebugMenuState
# ${CMAKE_SOURCE_DIR}/src/GameOverState
# ${CMAKE_SOURCE_DIR}/src/VictoryState
# ${CMAKE_SOURCE_DIR}/src/MainMenuState
# ${CMAKE_SOURCE_DIR}/src/MainOptionsState
${CMAKE_SOURCE_DIR}/src/SplashState
# ${CMAKE_SOURCE_DIR}/src/CreditsState
# ${CMAKE_SOURCE_DIR}/src/ResetState
${CMAKE_BINARY_DIR}/usr/local/include
)
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/resources
${CMAKE_SOURCE_DIR}/src/common
${CMAKE_SOURCE_DIR}/src/SplashState
${CMAKE_SOURCE_DIR}/src/AttractState
${CMAKE_SOURCE_DIR}/src/MainMenuState
${CMAKE_SOURCE_DIR}/src/GameState
# ${CMAKE_SOURCE_DIR}/src/img/
# ${CMAKE_SOURCE_DIR}/src/GameMenuState
# ${CMAKE_SOURCE_DIR}/src/DebugMenuState
# ${CMAKE_SOURCE_DIR}/src/GameOverState
# ${CMAKE_SOURCE_DIR}/src/VictoryState
# ${CMAKE_SOURCE_DIR}/src/MainOptionsState
# ${CMAKE_SOURCE_DIR}/src/CreditsState
# ${CMAKE_SOURCE_DIR}/src/ResetState
${CMAKE_BINARY_DIR}/usr/local/include
)

INCLUDE_DIRECTORIES(
${EVADE2_INCLUDE_DIRS}
${CREATIVE_ENGINE_INCLUDE_DIRS}
${EVADE2_INCLUDE_DIRS}
${CREATIVE_ENGINE_INCLUDE_DIRS}
)

# gather Modite 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/GMainMenu.cpp src/MainMenuState/GMainMenu.h src/MainMenuState/GMainMenuProcess.cpp src/MainMenuState/GMainMenuProcess.h)
${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)

ProcessorCount(N)
if (NOT N EQUAL 0)
set(${PROJECT_NAME}_FLAGS -j${N})
set(${PROJECT_NAME}_BUILD_FLAGS -j${N})
set(${PROJECT_NAME}_args ${${PROJECT_NAME}_args} PARALLEL_LEVEL ${N})
set(${PROJECT_NAME}_FLAGS -j${N})
set(${PROJECT_NAME}_BUILD_FLAGS -j${N})
set(${PROJECT_NAME}_args ${${PROJECT_NAME}_args} PARALLEL_LEVEL ${N})
endif ()

BUILD_COMMAND(
$(MAKE) --silent
$(MAKE) --silent
)

# make Modite.app
if (APPLE)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE TRUE)
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ".")
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE TRUE)
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ".")
endif (APPLE)

TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${CREATIVE_ENGINE_LINK_LIBRARIES})
Expand Down
21 changes: 11 additions & 10 deletions Evade2/src/AttractState/GAttractProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,19 @@ TBool GAttractProcess::NextState() {
ad->timer--;
if (ad->timer < 0) {
ad->screen++;
if ((game_mode == GAME_STATE_ATTRACT_MODE && ad->screen > MAX_SCREEN) ||
(game_mode == GAME_STATE_CREDITS && ad->screen > MAX_CREDITS)) {
if ((game_mode == GAME_STATE_ATTRACT_MODE && ad->screen > MAX_SCREEN)) {
gGame->SetState(GAME_STATE_CREDITS);
return EFalse;
} else {
// Sound::play_sound(SFX_NEXT_ATTRACT_SCREEN);
InitScreen();
mState = STATE_TYPEWRITER;
return ETrue;
}
} else {
return ETrue;
if (game_mode == GAME_STATE_CREDITS && ad->screen > MAX_CREDITS) {
gGame->SetState(GAME_STATE_MAIN_MENU);
return EFalse;
}
// Sound::play_sound(SFX_NEXT_ATTRACT_SCREEN);
InitScreen();
mState = STATE_TYPEWRITER;
}
return ETrue;
}

TBool GAttractProcess::TypewriterState() {
Expand All @@ -148,9 +148,10 @@ TBool GAttractProcess::TypewriterState() {
gGame->SetState(GAME_STATE_GAME);
return EFalse;
}

if (gControls.WasPressed(BUTTON_START)) {
ad->timer = -1;
// me->sleep(1, next);
gGame->SetState(GAME_STATE_GAME);
return EFalse;
}

Expand Down
15 changes: 2 additions & 13 deletions Evade2/src/AttractState/GAttractState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,8 @@ GAttractState::GAttractState() : BGameEngine(gViewPort) {
gGameEngine = this;
mPlayfield = new GStarfield();
AddProcess(new GAttractProcess());
GCamera::vx = GCamera::vy = 0;
GCamera::vz = 2;

gDisplay.SetColor(COLOR_BLACK, 0,0,0);
for (TInt i=1; i<256; i++) {
gDisplay.SetColor(i, 255,255,255);
}
gDisplay.SetColor(COLOR_WHITE, 255, 255, 255);
gDisplay.SetColor(ASSAULT_COLOR, 255, 50, 50);
gDisplay.SetColor(BOMBER_COLOR, 50, 255, 50);
gDisplay.SetColor(SCOUT_COLOR, 255, 50, 255);
gDisplay.SetColor(EBULLET_COLOR, 50, 50, 255);
gDisplay.SetColor(BOMB_COLOR, 255, 255, 50);
gCamera->vx = gCamera->vy = 0;
gCamera->vz = 2;
}

GAttractState::~GAttractState() noexcept {
Expand Down
43 changes: 34 additions & 9 deletions Evade2/src/GGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// states
#include "./GameState/GGameState.h"
#include "./SplashState/GSplashState.h"
#include "./MainMenuState/GMainMenuState.h"
#include "./AttractState/GAttractState.h"

static TUint32 start;
Expand All @@ -25,12 +26,10 @@ TBool GGame::mDebug = EFalse;
GGame::GGame() {
gGame = this;
printf("Construct GGame\n");
mWave = 1;
mKills = 0;
mDifficulty = 1;
gVectorFont = new GVectorFont();
gGameEngine = ENull;
mState = 0;
gVectorFont = new GVectorFont();
mDifficulty = 1;
gGameEngine = ENull;
mState = 0;
SetState(GAME_STATE_SPLASH);
// SetState(GAME_STATE_GAME);
}
Expand Down Expand Up @@ -58,33 +57,57 @@ TInt GGame::GetState() const {
}

void GGame::SetState(GAMESTATE aNewState) {
delete gGameEngine;
for (TInt i = 0; i < 256; i++) {
gDisplay.SetColor(i, 255, 255, 255);
}

gDisplay.SetColor(COLOR_BLACK, 0, 0, 0);
gDisplay.SetColor(COLOR_WHITE, 255, 255, 255);

gDisplay.SetColor(COLOR_STAR, 255,255,255);

gDisplay.SetColor(ASSAULT_COLOR, 255, 50, 50);
gDisplay.SetColor(BOMBER_COLOR, 50, 255, 50);
gDisplay.SetColor(SCOUT_COLOR, 255, 50, 255);

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");
gGameEngine = new GGameState();
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;
}
};

Expand All @@ -98,13 +121,15 @@ TBool GGame::IsGameState() const {

void GGame::Run() {
TBool done = EFalse;

while (!done) {
Random(); // randomize
mShmoo.Set(TUint8(mShmoo.r + 16), TUint8(mShmoo.g + 16), TUint8(mShmoo.b + 16));
gDisplay.displayBitmap->SetColor(COLOR_SHMOO, mShmoo);
GCamera::Move();
gCamera->Move();
gGameEngine->GameLoop();
gDisplay.Update();

if (gControls.WasPressed(BUTTONQ)) {
done = ETrue;
}
Expand Down
13 changes: 2 additions & 11 deletions Evade2/src/GGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@ class BFont;
enum GAMESTATE {
GAME_STATE_SPLASH,
GAME_STATE_MAIN_MENU,
// GAME_STATE_LOAD_GAME,
// GAME_STATE_MAIN_OPTIONS,
// GAME_STATE_RESET_OPTIONS,
GAME_STATE_ATTRACT_MODE,
// GAME_STATE_RESET_GAME,
GAME_STATE_GAME,
// GAME_STATE_RESUME_GAME,
// GAME_STATE_LOAD_SAVEGAME,
// GAME_STATE_NEXT_WAVE,
GAME_STATE_VICTORY,
GAME_STATE_CREDITS,
};
Expand All @@ -40,11 +35,7 @@ class GGame : public BApplication {

TBool IsGameState() const;

public:
TUint8 mDifficulty;
TInt16 mKills;
TInt16 mWave;

TUint8 mDifficulty;
static TBool mDebug;
protected:
TInt mState;
Expand Down
2 changes: 2 additions & 0 deletions Evade2/src/Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
//#define SCREEN_DEPTH 8

const TFloat CAMERA_VZ = 2; // 4;
const TFloat CAMERA_WARP_VZ = 4;
const TFloat DELTACONTROL = 6; // 11;
const TInt8 MAX_BULLETS = 6;
const TFloat BULLET_VZ = 8; // 15;
const TFloat ALERT_TOP = 30;

// COLLISION_RADIUS = distance from player bullet to enemy required for a hit
const TFloat COLLISION_RADIUS = 64;
Expand Down
Loading

0 comments on commit bced345

Please sign in to comment.