diff --git a/Evade2/CMakeLists.txt b/Evade2/CMakeLists.txt index 85a8524..af1169f 100644 --- a/Evade2/CMakeLists.txt +++ b/Evade2/CMakeLists.txt @@ -29,7 +29,7 @@ SET(EVADE2_INCLUDE_DIRS ${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 # ${CMAKE_SOURCE_DIR}/src/GameState/environment # ${CMAKE_SOURCE_DIR}/src/GameState/player # ${CMAKE_SOURCE_DIR}/src/GameState/inventory @@ -46,7 +46,7 @@ SET(EVADE2_INCLUDE_DIRS # ${CMAKE_SOURCE_DIR}/src/VictoryState # ${CMAKE_SOURCE_DIR}/src/MainMenuState # ${CMAKE_SOURCE_DIR}/src/MainOptionsState -# ${CMAKE_SOURCE_DIR}/src/SplashState + ${CMAKE_SOURCE_DIR}/src/SplashState # ${CMAKE_SOURCE_DIR}/src/CreditsState # ${CMAKE_SOURCE_DIR}/src/ResetState ${CMAKE_BINARY_DIR}/usr/local/include @@ -65,7 +65,7 @@ ADD_EXECUTABLE( Resources.bin ${CREATIVE_ENGINE_SOURCE_FILES} ${EVADE2_SRC} - src/GameState/GGameState.cpp src/GameState/GGameState.h src/GameState/GGamePlayfield.cpp src/GameState/GGamePlayfield.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/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) ProcessorCount(N) if (NOT N EQUAL 0) diff --git a/Evade2/old/GameState/enemies/GBossSprite.cpp b/Evade2/old/GameState/enemies/GBossSprite.cpp index 280171e..55f2be8 100644 --- a/Evade2/old/GameState/enemies/GBossSprite.cpp +++ b/Evade2/old/GameState/enemies/GBossSprite.cpp @@ -2,7 +2,7 @@ #include "GResources.h" #include "GBossSprite.h" #include "GPlayer.h" -#include "GameState/GCamera.h" +#include "common/GCamera.h" static const TFloat z_dist = 256; static const TFloat frames = 32; diff --git a/Evade2/old/GameState/enemies/GEnemySprite.cpp b/Evade2/old/GameState/enemies/GEnemySprite.cpp index 5648c71..265d4e9 100644 --- a/Evade2/old/GameState/enemies/GEnemySprite.cpp +++ b/Evade2/old/GameState/enemies/GEnemySprite.cpp @@ -2,7 +2,7 @@ #include "GResources.h" #include "GEnemySprite.h" #include "GPlayer.h" -#include "GameState/GCamera.h" +#include "common/GCamera.h" const TInt8 *enemy_graphic(TInt16 n) { diff --git a/Evade2/old/GameState/player/GPlayerProcess.cpp b/Evade2/old/GameState/player/GPlayerProcess.cpp index 09cdb61..b897b60 100644 --- a/Evade2/old/GameState/player/GPlayerProcess.cpp +++ b/Evade2/old/GameState/player/GPlayerProcess.cpp @@ -1,7 +1,7 @@ #include "GPlayerProcess.h" #include "GPlayer.h" #include "GPlayerSprite.h" -#include "GGamePlayfield.h" +#include "GStarfield.h" #include "GStatProcess.h" #include "GResources.h" #include "GPlayerBulletProcess.h" diff --git a/Evade2/old/SplashState/Splash.cpp b/Evade2/old/SplashState/Splash.cpp deleted file mode 100644 index e0b04ef..0000000 --- a/Evade2/old/SplashState/Splash.cpp +++ /dev/null @@ -1,66 +0,0 @@ -//#define DEBUGME -////#undef DEBUGME -// -//#include "Evade2.h" -// -//BOOL Splash::attract_mode = TRUE; -// -//struct splash_data { -//#ifdef ENABLE_ROTATING_TEXT -// FLOAT theta; // angle of rotating text -//#endif -// WORD timer; -//}; -// -///** -// * Wait for the human to press the A button -// */ -//void Splash::wait(Process *me, Object *o) { -// splash_data *d = (splash_data *)&o->x; -// -// Font::scale = 2 * 0x200; -//#ifdef ENABLE_ROTATING_TEXT -// Font::print_string_rotatedx(SHMOO_COLOR, 60, 90, d->theta, "EVADE 2"); -// d->theta += 10; -// if (d->theta > 90 + 360 * 2) { -// d->theta = 90 + 360 * 2; -// } -//#else -// Font::printf(SHMOO_COLOR, 60, 90, "EVADE 2"); -//#endif -// Font::scale = 0x100; -// -// d->timer--; -// if (d->timer < 0 || Controls::debounced(BUTTON_START)) { -// game_mode = attract_mode ? MODE_ATTRACT : MODE_CREDITS; -// attract_mode = !attract_mode; -// ProcessManager::birth(Attract::entry); -// me->suicide(); -// return; -// } -// if (d->timer & 16) { -// Font::scale = 0x200; -// Font::printf(SHMOO_COLOR, 130, 155, "START"); -// } -// -// if (Controls::debounced(BUTTON_A) || Controls::debounced(BUTTON_B)) { -// ProcessManager::birth(Game::entry); -// me->suicide(); -// return; -// } -// me->sleep(1); -//} -// -//void Splash::entry(Process *me, Object *o) { -// splash_data *d = (splash_data *)&o->x; -// -// game_mode = MODE_SPLASH; -//#ifdef ENABLE_ROTATING_TEXT -// d->theta = 90; -//#endif -// d->timer = 240; -// -// Camera::vz = CAMERA_VZ; -// Sound::play_score(INTRO_SONG); -// me->sleep(1, Splash::wait); -//} diff --git a/Evade2/old/SplashState/Splash.h b/Evade2/old/SplashState/Splash.h deleted file mode 100644 index d9a5148..0000000 --- a/Evade2/old/SplashState/Splash.h +++ /dev/null @@ -1,20 +0,0 @@ -//#ifndef SPLASH_H -//#define SPLASH_H -// -//#include "Evade2.h" -// -//class Splash { -//private: -// static BOOL attract_mode; -// -//private: -// // states -// static void show_logo(Process *me); -// static void wait(Process *me, Object *o); -// -//public: -// // initial state -// static void entry(Process *me, Object *o); -//}; -// -//#endif diff --git a/Evade2/src/AttractState/GAttractProcess.cpp b/Evade2/src/AttractState/GAttractProcess.cpp new file mode 100644 index 0000000..6bd5b5e --- /dev/null +++ b/Evade2/src/AttractState/GAttractProcess.cpp @@ -0,0 +1,226 @@ +// +// Created by Michael Schwartz on 11/4/20. +// + +#include "GAttractProcess.h" +#include "GEnemyProcess.h" + + +static const TInt8 TYPEWRITER_SPEED = 10; +static const TInt8 LINE_HEIGHT = 26; + +static const char scout_text[] = "SCOUT"; +static const char bomber_text[] = "BOMBER"; +static const char assault_text[] = "ASSAULT"; + +static const char credits1[] = "CRAFTED BY:\nMODUS CREATE\nDECEMBER 2017"; +static const char credits2[] = "MUSIC and SFX:\nJ. GARCIA"; +static const char credits3[] = + "ART:\nM. TINTIUC\nJV DALEN\nJD JONES\nJ. GARCIA"; +static const char credits4[] = + "PROGRAMMING:\nM. SCHWARTZ\nJ. GARCIA\nM. TINTIUC\n"; +static const char credits5[] = + "PROGRAMMING:\nD. BRIGNOLI\nS. LEMMONS\nA. DENNIS"; +static const char credits6[] = "PROGRAMMING:\nV. POPA\nL. STILL\nG. GRISOGONO"; + +const TInt8 MAX_SCREEN = 2; +const TInt8 MAX_CREDITS = 5; + +enum { + STATE_TYPEWRITER, + STATE_NEXT, +}; + +GAttractProcess::GAttractProcess() : BProcess() { +// mSprite = new GVectorSprite(); +// gGameEngine->AddSprite(mSprite); + auto *ad = (TAttractData *) &mData; + ad->screen = 0; + InitScreen(); +// Sound::play_sound(SFX_NEXT_ATTRACT_SCREEN); + mState = STATE_TYPEWRITER; +} + +GAttractProcess::~GAttractProcess() { + // +} + +TBool GAttractProcess::RunBefore() { + return ETrue; +} + +TBool GAttractProcess::RunAfter() { + switch (mState) { + case STATE_TYPEWRITER: + return TypewriterState(); + case STATE_NEXT: + return NextState(); + default: + Panic("invalid state: mState(%d)", mState); + } + + return ETrue; +} + +void GAttractProcess::InitScreen(TInt16 x, TInt16 y) { + auto *ad = &mData; + if (gGame->GetState() == GAME_STATE_ATTRACT_MODE) { + switch (ad->screen) { + case 0: + ad->enemy = ENEMY_SCOUT; + ad->text = scout_text; + x = 125; + y = 60; + break; + case 1: + ad->enemy = ENEMY_BOMBER; + ad->text = bomber_text; + x = 117; + y = 60; + break; + case 2: + ad->enemy = ENEMY_ASSAULT; + ad->text = assault_text; + x = 110; + y = 60; + break; + } + } else { + ad->enemy = -1; + switch (ad->screen) { + case 0: + ad->text = credits1; + break; + case 1: + ad->text = credits2; + break; + case 2: + ad->text = credits3; + break; + case 3: + ad->text = credits4; + break; + case 4: + ad->text = credits5; + break; + case 5: + ad->text = credits6; + break; + } + } + + ad->offset = 1; + ad->x = x; + ad->y = y; + ad->timer = TYPEWRITER_SPEED; + ad->done = EFalse; +} + +TBool GAttractProcess::NextState() { + auto *ad = (TAttractData *) &mData; + TInt game_mode = gGame->GetState(); + + 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)) { + gGame->SetState(GAME_STATE_CREDITS); + return EFalse; + } else { +// Sound::play_sound(SFX_NEXT_ATTRACT_SCREEN); + InitScreen(); + mState = STATE_TYPEWRITER; + return ETrue; + } + } else { + return ETrue; + } +} + +TBool GAttractProcess::TypewriterState() { + auto *ad = (TAttractData *) &mData; + TInt game_mode = gGame->GetState(); + + ad->timer--; + + if (gControls.WasPressed(CONTROL_FIRE)) { + gGame->SetState(GAME_STATE_GAME); + return EFalse; + } + if (gControls.WasPressed(BUTTON_START)) { + ad->timer = -1; +// me->sleep(1, next); + return EFalse; + } + + if (ad->timer < 0) { + if (ad->done) { + ad->timer = 50; +// me->sleep(1, next); + mState = STATE_NEXT; + return ETrue; + } + ad->timer = TYPEWRITER_SPEED; + ad->offset++; +// Sound::play_sound(SFX_NEXT_ATTRACT_CHAR); + } + + switch (ad->enemy) { + case ENEMY_ASSAULT: + GVectorSprite::DrawVectorGraphic(GEnemyProcess::Graphic(ad->enemy), + TFloat(SCREEN_WIDTH) / 2, TFloat(SCREEN_HEIGHT) / 2, 0.0, + .75, // Originally 2.0 + ASSAULT_COLOR); + break; + case ENEMY_BOMBER: + GVectorSprite::DrawVectorGraphic(GEnemyProcess::Graphic(ad->enemy), + TFloat(SCREEN_WIDTH) / 2, TFloat(SCREEN_HEIGHT) / 2, 0.0, + .75, // Originally 2.0 + BOMBER_COLOR); + break; + case ENEMY_SCOUT: + GVectorSprite::DrawVectorGraphic(GEnemyProcess::Graphic(ad->enemy), + TFloat(SCREEN_WIDTH) / 2, TFloat(SCREEN_HEIGHT) / 2, 0.0, + .75, // Originally 2.0 + SCOUT_COLOR); + break; + } + if (game_mode == GAME_STATE_CREDITS) { + gVectorFont->scale = 2.0; + } + + const char *p = ad->text; + TInt16 x = ad->x, + y = ad->y; + + for (TInt8 i = 0; i < ad->offset;) { + char c = *p++; + if (c == '\0') { + if (!ad->done) { + ad->timer = 60; // 2 seconds + ad->done = ETrue; + } + break; + } else if (c == '\n') { + x = 20; + y += LINE_HEIGHT; + } else { + x += gVectorFont->write(x, y, c); + i++; + } + } + // if (game_mode == MODE_CREDITS) { + gVectorFont->scale = 2; + // } + return ETrue; +} + +//void Attract::entry() { +// TAttractData *ad = (TAttractData *) &mData; +// ad->screen = 0; +// InitScreen(); +// Sound::play_sound(SFX_NEXT_ATTRACT_SCREEN); +// +// me->sleep(1, typewriter); +//} diff --git a/Evade2/src/AttractState/GAttractProcess.h b/Evade2/src/AttractState/GAttractProcess.h new file mode 100644 index 0000000..31865a4 --- /dev/null +++ b/Evade2/src/AttractState/GAttractProcess.h @@ -0,0 +1,45 @@ +// +// Created by Michael Schwartz on 11/4/20. +// + +#ifndef EVADE2_GATTRACTPROCESS_H +#define EVADE2_GATTRACTPROCESS_H + +#include "Game.h" +#include "GVectorSprite.h" + +struct TAttractData { + TInt8 screen; + TInt8 x; + TInt8 y; + TInt8 offset; + TInt16 timer; + TBool done; + const char *text; + TInt8 enemy; +}; + +class GAttractProcess : public BProcess { +public: + GAttractProcess(); + + ~GAttractProcess(); + +public: + TBool RunBefore() OVERRIDE; + + TBool RunAfter() OVERRIDE; + +protected: + void InitScreen(TInt16 x = 20, TInt16 y = 30) ; + TBool NextState(); + TBool TypewriterState(); + +protected: + TInt mState; + TAttractData mData; + GVectorSprite *mSprite; +}; + + +#endif //EVADE2_GATTRACTPROCESS_H diff --git a/Evade2/src/AttractState/GAttractState.cpp b/Evade2/src/AttractState/GAttractState.cpp new file mode 100644 index 0000000..d892685 --- /dev/null +++ b/Evade2/src/AttractState/GAttractState.cpp @@ -0,0 +1,34 @@ +// +// Created by Michael Schwartz on 11/4/20. +// + +#include "Game.h" +#include "GAttractState.h" +#include "GGame.h" +#include "GEnemyProcess.h" +#include "GAttractProcess.h" +#include "GStarfield.h" +#include "GCamera.h" + +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); +} + +GAttractState::~GAttractState() noexcept { +} + diff --git a/Evade2/src/AttractState/GAttractState.h b/Evade2/src/AttractState/GAttractState.h new file mode 100644 index 0000000..b8f7923 --- /dev/null +++ b/Evade2/src/AttractState/GAttractState.h @@ -0,0 +1,18 @@ +// +// Created by Michael Schwartz on 11/4/20. +// + +#ifndef EVADE2_GATTRACTSTATE_H +#define EVADE2_GATTRACTSTATE_H + +#include "Game.h" + +class GAttractState : public BGameEngine { +public: + GAttractState(); + + ~GAttractState() OVERRIDE; +}; + + +#endif //EVADE2_GATTRACTSTATE_H diff --git a/Evade2/src/GGame.cpp b/Evade2/src/GGame.cpp index 670308b..561437c 100644 --- a/Evade2/src/GGame.cpp +++ b/Evade2/src/GGame.cpp @@ -1,16 +1,16 @@ #include "Game.h" #include "GGame.h" //#include "GPlayer.h" -#include "GameState/GCamera.h" +#include "common/GCamera.h" #include "GResources.h" + +// states #include "./GameState/GGameState.h" +#include "./SplashState/GSplashState.h" +#include "./AttractState/GAttractState.h" static TUint32 start; -BFont *gFont8x8, *gFont16x16; - -BViewPort gFullViewPort; - #ifdef DEBUG_MODE //TBool GGame::mDebug = ETrue; TBool GGame::mDebug = EFalse; @@ -23,64 +23,16 @@ TBool GGame::mDebug = EFalse; *******************************************************************************/ GGame::GGame() { + gGame = this; printf("Construct GGame\n"); - mDifficulty = 1; - mState = GAME_STATE_GAME; -#if 0 - mLocalData = ENull; - mLocalDataSize = 0; - - gFullViewPort.SetRect(TRect (0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1)); - - // Load Game Options -#ifdef ENABLE_OPTIONS - gOptions = new TOptions(); -#endif - -#ifdef ENABLE_AUDIO - gSoundPlayer.Init(6 /*channels*/); -#endif - - 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); - Camera::mZ = CAMERA_VZ; - -// const TUint8 BULLET_COLOR = 217; -// const TUint8 EBULLET_COLOR = 218; -// const TUint8 BOSS_COLOR = 219; -// const TUint8 SCOUT_COLOR = 222; -// const TUint8 STAR_COLOR = 223; - // preload bitmaps - // MAX_BITMAP is defined in GResource.h. - // for (TInt16 slot = 0; slot <= MAX_BBITMAP; slot++) { - // gResourceManager.PreloadBitmap(slot); - // } - - gResourceManager.LoadBitmap(CHARSET_8X8_BMP, FONT_8x8_SLOT, IMAGE_8x8); - gResourceManager.CacheBitmapSlot(FONT_8x8_SLOT); - gFont8x8 = new BFont(gResourceManager.GetBitmap(FONT_8x8_SLOT), FONT_8x8); - gResourceManager.LoadBitmap(CHARSET_16X16_BMP, FONT_16x16_SLOT, IMAGE_16x16); - gResourceManager.CacheBitmapSlot(FONT_16x16_SLOT); - gFont16x16 = new BFont(gResourceManager.GetBitmap(FONT_16x16_SLOT), FONT_16x16); - - gViewPort = new BViewPort(); - gViewPort->SetRect(TRect(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1)); - gViewPort->Offset(0, 0); - - mState = mNextState = -1; - gGameEngine = ENull; - mGameMenu = ENull; - mDebugMenu = ENull; - mInventory = ENull; -// SetState(GAME_STATE_SPLASH); <-- DEFAULT - SetState(GAME_STATE_MAIN_MENU); // <--- For debugging - start = Milliseconds(); - mShmoo.Set(0, 0, 0); - - mStarField = new GStarFieldProcess(); -#endif + mWave = 1; + mKills = 0; + mDifficulty = 1; + gVectorFont = new GVectorFont(); + gGameEngine = ENull; + mState = 0; + SetState(GAME_STATE_SPLASH); +// SetState(GAME_STATE_GAME); } GGame::~GGame() { @@ -96,126 +48,48 @@ GGame::~GGame() { ******************************************************************************* *******************************************************************************/ -BGameEngine *GGame::CurrentState() { -#if 0 - if (gGameEngine->IsPaused()) { - if (mGameMenu) return mGameMenu; - else if (mInventory) return mInventory; - else if (mDebugMenu) return mDebugMenu; - } -#endif - return gGameEngine; -} - -#if 0 -void GGame::ToggleInGameMenu() { - if (GPlayer::mGameOver || mDebugMenu || mInventory) { - return; - } - if (mGameMenu) { - delete mGameMenu; - mGameMenu = ENull; - gGameEngine->Resume(); - } - else { - mGameMenu = new GGameMenuState((GGameState *)gGameEngine); - gGameEngine->Pause(); - } - gControls.dKeys = 0; -} - -#endif - -#if 0 -void GGame::ToggleDebugMenu() { - if (GPlayer::mGameOver || mGameMenu || mInventory) { - return; - } - if (mDebugMenu) { - delete mDebugMenu; - mDebugMenu = ENull; - gGameEngine->Resume(); - } - else { - mDebugMenu = new GDebugMenuState(); - gGameEngine->Pause(); - } - gControls.dKeys = 0; -} -#endif - -/******************************************************************************* - ******************************************************************************* - *******************************************************************************/ - -#if 0 -void GGame::ToggleInventory() { -// if (GPlayer::mGameOver || mGameMenu) { -// return; -// } -// if (mInventory) { -// delete mInventory; -// mInventory = ENull; -// if (!mDebugMenu) { -// gGameEngine->Resume(); -// } -// } -// else { -// gGameEngine->Pause(); -// } -// gControls.dKeys = 0; -} -#endif +//BGameEngine *GGame::CurrentState() { +// return gGameEngine; +//} -/******************************************************************************* - ******************************************************************************* - *******************************************************************************/ -#if 0 -void GGame::SetState(TInt aNewState, TAny *aLocalData, TUint32 aSize) { - mNextState = aNewState; - if (aLocalData) { - delete (TUint8 *)mLocalData; - mLocalDataSize = aSize; - mLocalData = new TUint8[mLocalDataSize]; - memcpy((TUint8 *)mLocalData, (TUint8 *)aLocalData, mLocalDataSize); - } - else { - delete (TUint8 *)mLocalData; - mLocalData = ENull; - mLocalDataSize = 0; - } -} -#endif - -TInt GGame::GetState() { +TInt GGame::GetState() const { return mState; } -void GGame::StartGame(char *aGameName) { -#if 0 -#ifdef DEBUG_MODE - printf("START GAME (%s)\n", aGameName); -#endif - SetState( - mState == GAME_STATE_RESUME_GAME ? GAME_STATE_LOAD_SAVEGAME : GAME_STATE_RESUME_GAME, - aGameName, - strlen(aGameName)+1 - ); -#endif -} - -TBool GGame::IsGameState() { - TBool state = mState == GAME_STATE_RESUME_GAME || - mState == GAME_STATE_GAME || - mState == GAME_STATE_LOAD_SAVEGAME; - - if (!state) { - return EFalse; +void GGame::SetState(GAMESTATE aNewState) { + delete gGameEngine; + mState = aNewState; + switch (aNewState) { + case GAME_STATE_SPLASH: + printf("new State SPLASH\n"); + gGameEngine = new GSplashState(); + break; + case GAME_STATE_ATTRACT_MODE: + printf("new State ATTRACT\n"); + gGameEngine = new GAttractState(); + break; + case GAME_STATE_GAME: + printf("new State GAME\n"); + gGameEngine = new GGameState(); + break; + case GAME_STATE_MAIN_MENU: + printf("new State MAIN MENU\n"); + gGameEngine = new GGameState(); + break; + case GAME_STATE_VICTORY: + printf("new State VICTORY\n"); + gGameEngine = new GGameState(); + break; + case GAME_STATE_CREDITS: + printf("new State CREDITS\n"); + gGameEngine = new GAttractState(); + break; } - return ETrue; -// GGameState *s = (GGameState *)gGameEngine; -// return !s->IsGameOver(); +}; + +TBool GGame::IsGameState() const { + return mState == GAME_STATE_GAME; } /******************************************************************************* @@ -223,8 +97,6 @@ TBool GGame::IsGameState() { *******************************************************************************/ void GGame::Run() { - printf("run\n"); - gGameEngine = new GGameState(); TBool done = EFalse; while (!done) { Random(); // randomize diff --git a/Evade2/src/GGame.h b/Evade2/src/GGame.h index 0759679..97a3d06 100644 --- a/Evade2/src/GGame.h +++ b/Evade2/src/GGame.h @@ -9,18 +9,17 @@ class BGameEngine; class BFont; -enum { +enum GAMESTATE { GAME_STATE_SPLASH, GAME_STATE_MAIN_MENU, - GAME_STATE_LOAD_GAME, - GAME_STATE_MAIN_OPTIONS, - GAME_STATE_RESET_OPTIONS, +// GAME_STATE_LOAD_GAME, +// GAME_STATE_MAIN_OPTIONS, +// GAME_STATE_RESET_OPTIONS, GAME_STATE_ATTRACT_MODE, - GAME_STATE_RESET_GAME, +// GAME_STATE_RESET_GAME, GAME_STATE_GAME, - GAME_STATE_RESUME_GAME, - GAME_STATE_LOAD_SAVEGAME, - GAME_STATE_QUIT, +// GAME_STATE_RESUME_GAME, +// GAME_STATE_LOAD_SAVEGAME, GAME_STATE_VICTORY, GAME_STATE_CREDITS, }; @@ -35,27 +34,21 @@ class GGame : public BApplication { void Run(); public: -// void SetState(TInt aNewState, TAny *aLocalData = ENull, TUint32 aSize = 0); - void StartGame(char *aGameName); + void SetState(GAMESTATE aNewStae); - TInt GetState(); + TInt GetState() const; - TBool IsGameState(); + TBool IsGameState() const; - BGameEngine *CurrentState(); - - TUint16 mWave; - TUint16 mKills; +public: TUint8 mDifficulty; + TInt16 mKills; + TInt16 mWave; static TBool mDebug; protected: - TInt mState; - TInt mNextState; - BGameEngine *mGameMenu; - TRGB mShmoo; - -// GStarFieldProcess *mStarField; + TInt mState; + TRGB mShmoo; }; extern GGame *gGame; diff --git a/Evade2/src/GResources.h b/Evade2/src/GResources.h index 431723b..cc3740a 100644 --- a/Evade2/src/GResources.h +++ b/Evade2/src/GResources.h @@ -10,6 +10,7 @@ const TUint16 EVENT_SPELL_PROCESS_EXIT = 1; enum { FONT_8x8_SLOT, FONT_16x16_SLOT, + BKG_SLOT, SLOT_MAX, }; @@ -94,8 +95,9 @@ const TUint16 IMG_DAMAGE_UP = 40; const TUint8 COLOR_BLACK = 0; const TUint8 COLOR_WHITE = 1; const TUint8 COLOR_TEXT = 2; -const TUint8 COLOR_STAR = 3; -const TUint8 COLOR_HUD = 4; +const TUint8 COLOR_TEXT_BG = 3; +const TUint8 COLOR_STAR = 4; +const TUint8 COLOR_HUD = 5; const TUint8 COLOR_BLUE = 201; const TUint8 COLOR_GREEN = 202; diff --git a/Evade2/src/Game.h b/Evade2/src/Game.h index 2f4f11a..99eaa4b 100644 --- a/Evade2/src/Game.h +++ b/Evade2/src/Game.h @@ -23,7 +23,7 @@ const TFloat COLLISION_RADIUS = 64; #undef FRAME_RATE_INFO #define ENABLE_AUDIO -//#undef ENABLE_AUDIO +#undef ENABLE_AUDIO #define ENABLE_ROTATING_TEXT //#undef ENABLE_ROTATING_TEXT diff --git a/Evade2/src/GameState/GEnemyProcess.cpp b/Evade2/src/GameState/GEnemyProcess.cpp index 3670f7d..11e90ef 100644 --- a/Evade2/src/GameState/GEnemyProcess.cpp +++ b/Evade2/src/GameState/GEnemyProcess.cpp @@ -13,6 +13,20 @@ #define FIRE_TIME (60 / gGame->mDifficulty + Random(1, 60 / gGame->mDifficulty)) +const TInt8 *GEnemyProcess::Graphic(TInt aType) { + switch (aType) { + case ENEMY_ASSAULT: + return (const TInt8 *)&enemy_assault_1_img; + case ENEMY_BOMBER: + return (const TInt8 *)&enemy_heavy_bomber_1_img; + case ENEMY_SCOUT: + return (const TInt8 *)&enemy_scout_1_img; + default: + Panic("Invalid enemy type: %d\n", aType); + } + return ENull; +} + GEnemyProcess::GEnemyProcess() { mSprite = new GVectorSprite(STYPE_ENEMY); gGameEngine->AddSprite(mSprite); @@ -154,7 +168,6 @@ TBool GEnemyProcess::StateSeek() { if (o->z - GCamera::z < Random(256, 512)) { o->mState = -1; mState = ESTATE_RUNAWAY; -// me->sleep(1, run_away); return ETrue; } @@ -166,12 +179,10 @@ TBool GEnemyProcess::StateEvade() { if (o->z - GCamera::z > 512) { o->mState = 1; mState = ESTATE_RUNAWAY; -// me->sleep(1, run_away); return ETrue; } if (death()) { mState = ESTATE_EXPLODE; -// me->sleep(1, explode); return ETrue; } bank(15); @@ -213,7 +224,6 @@ TBool GEnemyProcess::StateOrbit() { o->z = GCamera::z + sin(rad) * 256; } -// me->sleep(1); return ETrue; } @@ -226,7 +236,6 @@ TBool GEnemyProcess::StateWaitInit() { o->mTimer = 1; } o->mTimer--; -// me->sleep(1); return ETrue; } @@ -245,12 +254,10 @@ TBool GEnemyProcess::StateRunAway() { } if (death()) { mState = ESTATE_EXPLODE; -// me->sleep(1, explode); return ETrue; } bank(); fire(); -// me->sleep(1); return ETrue; } diff --git a/Evade2/src/GameState/GEnemyProcess.h b/Evade2/src/GameState/GEnemyProcess.h index 5e47fcb..761f835 100644 --- a/Evade2/src/GameState/GEnemyProcess.h +++ b/Evade2/src/GameState/GEnemyProcess.h @@ -24,20 +24,32 @@ enum EState { class GEnemyProcess : public BProcess { public: GEnemyProcess(); - ~GEnemyProcess(); + + ~GEnemyProcess() OVERRIDE; + +public: + static const TInt8 *Graphic(TInt aType); public: - TBool RunBefore(); - TBool RunAfter(); + TBool RunBefore() OVERRIDE; + + TBool RunAfter() OVERRIDE; private: void init_assault(TBool left); + void init_scout(); + void init_bomber(); + void init(); + void respawn(); + TBool death(); + void fire(); + void bank(TInt16 delta = 45); protected: @@ -45,11 +57,17 @@ class GEnemyProcess : public BProcess { protected: TBool StateSeek(); + TBool StateEvade(); + TBool StateOrbit(); + TBool StateWaitInit(); + TBool StateRunAway(); + TBool StateExplode(); + protected: EState mState; diff --git a/Evade2/src/GameState/GGameState.cpp b/Evade2/src/GameState/GGameState.cpp index 37c1cc6..5ad85ad 100644 --- a/Evade2/src/GameState/GGameState.cpp +++ b/Evade2/src/GameState/GGameState.cpp @@ -3,7 +3,7 @@ // #include "GGameState.h" -#include "GGamePlayfield.h" +#include "GStarfield.h" #include "GPlayerProcess.h" #include "GEnemyProcess.h" @@ -12,7 +12,7 @@ GGameState *gGameState; GGameState::GGameState() : BGameEngine(gViewPort) { gGameEngine = this; gGameState = this; - mPlayfield = new GGamePlayfield(); + mPlayfield = new GStarfield(); // set colors gDisplay.SetColor(COLOR_BLACK, 0,0,0); for (TInt i=1; i<256; i++) { diff --git a/Evade2/src/MainMenuState/GMainMenu.cpp b/Evade2/src/MainMenuState/GMainMenu.cpp new file mode 100644 index 0000000..fe91034 --- /dev/null +++ b/Evade2/src/MainMenuState/GMainMenu.cpp @@ -0,0 +1,12 @@ +// +// Created by Michael Schwartz on 11/4/20. +// + +#include "GMainMenu.h" +#include "GStarfield.h" + +GMainMenu::GMainMenu() : BGameEngine(gViewPort) { + mPlayfield = new GStarfield(); +} + +GMainMenu::~GMainMenu() noexcept {} \ No newline at end of file diff --git a/Evade2/src/MainMenuState/GMainMenu.h b/Evade2/src/MainMenuState/GMainMenu.h new file mode 100644 index 0000000..5c52ac5 --- /dev/null +++ b/Evade2/src/MainMenuState/GMainMenu.h @@ -0,0 +1,18 @@ +// +// Created by Michael Schwartz on 11/4/20. +// + +#ifndef EVADE2_GMAINMENU_H +#define EVADE2_GMAINMENU_H + +#include "Game.h" + +class GMainMenu : public BGameEngine { +public: + GMainMenu(); + + ~GMainMenu() OVERRIDE; +}; + + +#endif //EVADE2_GMAINMENU_H diff --git a/Evade2/src/MainMenuState/GMainMenuProcess.cpp b/Evade2/src/MainMenuState/GMainMenuProcess.cpp new file mode 100644 index 0000000..18c15df --- /dev/null +++ b/Evade2/src/MainMenuState/GMainMenuProcess.cpp @@ -0,0 +1,5 @@ +// +// Created by Michael Schwartz on 11/4/20. +// + +#include "GMainMenuProcess.h" diff --git a/Evade2/src/MainMenuState/GMainMenuProcess.h b/Evade2/src/MainMenuState/GMainMenuProcess.h new file mode 100644 index 0000000..56ed2d0 --- /dev/null +++ b/Evade2/src/MainMenuState/GMainMenuProcess.h @@ -0,0 +1,24 @@ +// +// Created by Michael Schwartz on 11/4/20. +// + +#ifndef EVADE2_GMAINMENUPROCESS_H +#define EVADE2_GMAINMENUPROCESS_H + +#include "Game.h" + +class GMainMenuProcess : public BProcess { +public: + GMainMenuProcess(); + + ~GMainMenuProcess(); + +public: + TBool RunBefore(); + + TBool RunAfter(); + +}; + + +#endif //EVADE2_GMAINMENUPROCESS_H diff --git a/Evade2/old/SplashState/GSplashPlayfield.cpp b/Evade2/src/SplashState/GSplashPlayfield.cpp similarity index 100% rename from Evade2/old/SplashState/GSplashPlayfield.cpp rename to Evade2/src/SplashState/GSplashPlayfield.cpp diff --git a/Evade2/old/SplashState/GSplashPlayfield.h b/Evade2/src/SplashState/GSplashPlayfield.h similarity index 100% rename from Evade2/old/SplashState/GSplashPlayfield.h rename to Evade2/src/SplashState/GSplashPlayfield.h diff --git a/Evade2/old/SplashState/GSplashProcess.cpp b/Evade2/src/SplashState/GSplashProcess.cpp similarity index 91% rename from Evade2/old/SplashState/GSplashProcess.cpp rename to Evade2/src/SplashState/GSplashProcess.cpp index 277d5dd..5a797bc 100644 --- a/Evade2/old/SplashState/GSplashProcess.cpp +++ b/Evade2/src/SplashState/GSplashProcess.cpp @@ -4,8 +4,8 @@ //static const char *splash_message2 = "Press any button"; GSplashProcess::GSplashProcess() : BProcess() { - mColor = 0; - mState = STATE_FADEIN; + mColor = 0; + mState = STATE_FADEIN; // mFont = new BFont(gResourceManager.GetBitmap(FONT_16x16_SLOT), FONT_16x16); // mCurrentText = splash_message1; } @@ -65,12 +65,12 @@ void GSplashProcess::RenderText() { TBool GSplashProcess::RunAfter() { if (gControls.WasPressed(BUTTON_ANY)) { // } || --mTimer <= 0) { - gGame->SetState(GAME_STATE_MAIN_MENU); -// gGame->SetState(GAME_STATE_VICTORY); + gGame->SetState(GAME_STATE_ATTRACT_MODE); #ifdef ENABLE_AUDIO - //gSoundPlayer.SfxStartGame(); + gSoundPlayer.SfxStartGame(); #endif + return EFalse; } // switch (mState) { diff --git a/Evade2/old/SplashState/GSplashProcess.h b/Evade2/src/SplashState/GSplashProcess.h similarity index 100% rename from Evade2/old/SplashState/GSplashProcess.h rename to Evade2/src/SplashState/GSplashProcess.h diff --git a/Evade2/old/SplashState/GSplashState.cpp b/Evade2/src/SplashState/GSplashState.cpp similarity index 62% rename from Evade2/old/SplashState/GSplashState.cpp rename to Evade2/src/SplashState/GSplashState.cpp index 931fd42..91f31bf 100644 --- a/Evade2/old/SplashState/GSplashState.cpp +++ b/Evade2/src/SplashState/GSplashState.cpp @@ -1,11 +1,16 @@ #include "Game.h" #include "GSplashPlayfield.h" #include "GSplashProcess.h" +#include "GSplashState.h" GSplashState::GSplashState() : BGameEngine(gViewPort) { + gGameEngine = this; mPlayfield = new GSplashPlayfield(); AddProcess(new GSplashProcess()); } -GSplashState::~GSplashState() = default; +GSplashState::~GSplashState() { + delete mPlayfield; + mPlayfield = ENull; +} diff --git a/Evade2/old/SplashState/GSplashState.h b/Evade2/src/SplashState/GSplashState.h similarity index 86% rename from Evade2/old/SplashState/GSplashState.h rename to Evade2/src/SplashState/GSplashState.h index 96286e2..0735338 100644 --- a/Evade2/old/SplashState/GSplashState.h +++ b/Evade2/src/SplashState/GSplashState.h @@ -7,7 +7,7 @@ class GSplashState : public BGameEngine { public: GSplashState(); - virtual ~GSplashState(); + ~GSplashState() OVERRIDE; }; diff --git a/Evade2/src/GameState/GCamera.cpp b/Evade2/src/common/GCamera.cpp similarity index 100% rename from Evade2/src/GameState/GCamera.cpp rename to Evade2/src/common/GCamera.cpp diff --git a/Evade2/src/GameState/GCamera.h b/Evade2/src/common/GCamera.h similarity index 100% rename from Evade2/src/GameState/GCamera.h rename to Evade2/src/common/GCamera.h diff --git a/Evade2/src/GameState/GGamePlayfield.cpp b/Evade2/src/common/GStarfield.cpp similarity index 86% rename from Evade2/src/GameState/GGamePlayfield.cpp rename to Evade2/src/common/GStarfield.cpp index dde66e1..b7cf405 100644 --- a/Evade2/src/GameState/GGamePlayfield.cpp +++ b/Evade2/src/common/GStarfield.cpp @@ -2,20 +2,20 @@ // Created by Michael Schwartz on 10/29/20. // -#include "GGamePlayfield.h" +#include "GStarfield.h" #include "GCamera.h" -GGamePlayfield::GGamePlayfield() : BPlayfield() { +GStarfield::GStarfield() : BPlayfield() { for (TInt i = 0; i < NUM_STARS; i++) { InitStar(i); } } -GGamePlayfield::~GGamePlayfield() noexcept { +GStarfield::~GStarfield() noexcept { } -void GGamePlayfield::Render() { +void GStarfield::Render() { gDisplay.renderBitmap->Clear(0); TFloat cz = GCamera::z, sw = TFloat(SCREEN_WIDTH), @@ -50,7 +50,7 @@ void GGamePlayfield::Render() { } } -void GGamePlayfield::InitStar(TInt aIndex) { +void GStarfield::InitStar(TInt aIndex) { mStarX[aIndex] = TFloat(256) - Random(0, 512) + GCamera::x; mStarY[aIndex] = TFloat(256) - Random(0, 512) + GCamera::y; mStarZ[aIndex] = GCamera::z + Random(200, 512); diff --git a/Evade2/src/GameState/GGamePlayfield.h b/Evade2/src/common/GStarfield.h similarity index 60% rename from Evade2/src/GameState/GGamePlayfield.h rename to Evade2/src/common/GStarfield.h index 19c662d..cca0e8f 100644 --- a/Evade2/src/GameState/GGamePlayfield.h +++ b/Evade2/src/common/GStarfield.h @@ -2,18 +2,18 @@ // Created by Michael Schwartz on 10/29/20. // -#ifndef EVADE2_GGAMEPLAYFIELD_H -#define EVADE2_GGAMEPLAYFIELD_H +#ifndef EVADE2_GSTARFIELD_H +#define EVADE2_GSTARFIELD_H #include const int NUM_STARS = 128; -class GGamePlayfield : public BPlayfield { +class GStarfield : public BPlayfield { public: - GGamePlayfield(); + GStarfield(); - ~GGamePlayfield(); + ~GStarfield(); public: void Render() OVERRIDE; @@ -26,4 +26,4 @@ class GGamePlayfield : public BPlayfield { }; -#endif //EVADE2_GGAMEPLAYFIELD_H +#endif //EVADE2_GSTARFIELD_H diff --git a/Evade2/src/common/GVectorFont.cpp b/Evade2/src/common/GVectorFont.cpp index 502a98e..32f307f 100644 --- a/Evade2/src/common/GVectorFont.cpp +++ b/Evade2/src/common/GVectorFont.cpp @@ -7,196 +7,37 @@ * See: https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Print.cpp */ +#include "Game.h" #include "charset.h" -#include - -const TInt8 *charset[] = { - ENull, // space - font_emark, -#ifdef FULL_CHARSET - font_dquote, -#else - ENull, -#endif -#ifdef FULL_CHARSET - font_pound, // # -#else - ENull, -#endif -#ifdef FULL_CHARSET - font_dollar, // $ -#else - ENull, -#endif -#ifdef FULL_CHARSET - font_percent, // % -#else - ENull, -#endif -#ifdef FULL_CHARSET - font_amp, // & -#else - ENull, -#endif -#ifdef FULL_CHARSET - font_squote, // ' -#else - ENull, -#endif -#ifdef FULL_CHARSET - font_lparen, // ( -#else - ENull, -#endif -#ifdef FULL_CHARSET - font_rparen, // ) -#else - ENull, -#endif -#ifdef FULL_CHARSET - font_asterisk, // * -#else - ENull, -#endif -#ifdef FULL_CHARSET - font_plus, -#else - ENull, -#endif -#ifdef FULL_CHARSET - font_comma, -#else - ENull, -#endif -#ifdef FULL_CHARSET - font_minus, -#else - ENull, -#endif - font_period, - font_fslash, - font_0, - font_1, - font_2, - font_3, - font_4, - font_5, - font_6, - font_7, - font_8, - font_9, - font_colon, -#ifdef full_charset - font_semicolon, -#else - ENull, -#endif -#ifdef full_charset - font_lt, // < -#else - ENull, -#endif -#ifdef full_charset - font_eq, // = -#else - ENull, -#endif -#ifdef full_charset - font_gt, // > -#else - ENull, -#endif -#ifdef full_charset - font_qmark, -#else - ENull, -#endif -#ifdef full_charset - font_at, // @ -#else - ENull, -#endif - font_a, - font_b, - font_c, - font_d, - font_e, - font_f, - font_g, - font_h, - font_i, - font_j, - font_k, - font_l, - font_m, - font_n, - font_o, - font_p, - font_q, - font_r, - font_s, - font_t, - font_u, - font_v, - font_w, - font_x, - font_y, - font_z, -#ifdef full_charset - font_lt, // [ -#else - ENull, -#endif -#ifdef full_charset - font_bslash, // '\' -#else - ENull, -#endif -#ifdef full_charset - font_gt, // ] -#else - ENull, -#endif -#ifdef full_charset - font_caret, // ^ -#else - ENull, -#endif -#ifdef full_charset - font_uscore, // _ -#else - ENull, -#endif - ENull, // `` -}; +GVectorFont *gVectorFont; +// constructor GVectorFont::GVectorFont() { - scale = 0x100; + scale = 1.0; color = COLOR_TEXT; + gVectorFont = this; } #ifdef ENABLE_ROTATING_TEXT -TInt8 GVectorFont::print_string_rotatedx(TInt8 x, TInt8 y, TFloat theta, const char *s) { +TInt16 GVectorFont::print_string_rotatedx(TFloat x, TFloat y, TFloat theta, const char *s) { theta = float(theta) * 3.1415926 / 180; TFloat cost = cos(theta), sint = sin(theta); const char *p = s; - TFloat fscale = TFloat(scale >> 8) + TFloat(scale & 0xff) / 256.0; - - const TInt8 size = 9; + const TInt16 size = 9; - TInt8 xo = x; + TInt16 xo = x; while (char c = *p++) { - const TInt8 *glyph = charset[toupper(c) - 32]; + auto *glyph = (const TInt16 *)charset[toupper(c) - 32]; if (glyph) { - TInt8 lines = *glyph++; + TInt16 lines = *glyph++; - for (TInt8 i = 0; i < lines; i++) { - TFloat x0 = (TInt8)*glyph++ * fscale + x, - y0 = (TInt8)*glyph++ * fscale + y, - x1 = (TInt8)*glyph++ * fscale + x, - y1 = (TInt8)*glyph++ * fscale + y; + for (TInt16 i = 0; i < lines; i++) { + TFloat x0 = *glyph++ * scale + x, + y0 = *glyph++ * scale + y, + x1 = *glyph++ * scale + x, + y1 = *glyph++ * scale + y; gDisplay.renderBitmap->DrawLine( gViewPort, @@ -206,26 +47,25 @@ TInt8 GVectorFont::print_string_rotatedx(TInt8 x, TInt8 y, TFloat theta, const c ((y1 - y) * sint + cost + y), color); } - x += size * fscale; + x += size * scale; } else { - x += 6 * fscale; + x += 6 * scale; } } return x - xo; } #endif -TInt8 GVectorFont::write(TInt8 x, TInt8 y, char c) { +TInt16 GVectorFont::write(TFloat x, TFloat y, char c) { const TInt8 *glyph; - const TInt8 width = 9; + const TInt16 width = 9; - TFloat fscale = TFloat(scale >> 8) + TFloat(scale & 0xff) / 256.0; - glyph = charset[toupper(c) - 32]; + glyph = (TInt8 *)charset[toupper(c) - 32]; if (glyph) { TInt8 lines = *glyph++; - for (TInt8 i = 0; i < lines; i++) { + for (TInt16 i = 0; i < lines; i++) { TInt8 x0 = *glyph++, y0 = *glyph++, x1 = *glyph++, @@ -233,24 +73,24 @@ TInt8 GVectorFont::write(TInt8 x, TInt8 y, char c) { gDisplay.renderBitmap->DrawLine( gViewPort, - x + x0 * fscale, y + y0 * fscale, - x + x1 * fscale, y + y1 * fscale, + x + x0 * scale, y + y0 * scale, + x + x1 * scale, y + y1 * scale, color); } } - return width * fscale; + return width * scale; } -TInt8 GVectorFont::print_string(TInt8 x, TInt8 y, char *s) { - TInt8 xx = x; +TInt16 GVectorFont::print_string(TFloat x, TFloat y, char *s) { + TInt16 xx = x; while (char c = *s++) { - TInt8 width = write(x, y, c); + TInt16 width = write(x, y, c); x += width; } return x - xx; // width of string printed } -TInt8 GVectorFont::print_long(TInt8 x, TInt8 y, TInt64 n, TInt8 base) { +TInt16 GVectorFont::print_long(TFloat x, TFloat y, TInt64 n, TInt16 base) { char buf[8 * sizeof(TInt64) + 1]; // Assumes 8-bit chars plus zero byte. char *str = &buf[sizeof(buf) - 1]; @@ -271,8 +111,8 @@ TInt8 GVectorFont::print_long(TInt8 x, TInt8 y, TInt64 n, TInt8 base) { } #ifdef PRINTF_TFloat -TInt8 GVectorFont::print_float(TInt8 x, TInt8 y, double number, TInt8 digits) { - TInt8 xx = x; +TInt16 GVectorFont::print_float(TInt16 x, TInt16 y, double number, TInt16 digits) { + TInt16 xx = x; if (isnan(number)) { x += write(x, y, 'n'); x += write(x, y, 'a'); @@ -327,9 +167,9 @@ TInt8 GVectorFont::print_float(TInt8 x, TInt8 y, double number, TInt8 digits) { } #endif -TInt8 GVectorFont::printf(TInt8 x, TInt8 y, const char *s, ...) { +TInt16 GVectorFont::printf(TFloat x, TFloat y, const char *s, ...) { va_list ap; - TInt8 xx = x; + TInt16 xx = x; char c; const char *p = s; va_start(ap, s); diff --git a/Evade2/src/common/GVectorFont.h b/Evade2/src/common/GVectorFont.h index 8153289..dca252c 100644 --- a/Evade2/src/common/GVectorFont.h +++ b/Evade2/src/common/GVectorFont.h @@ -8,19 +8,21 @@ class GVectorFont{ GVectorFont(); public: - TUint16 scale; // 8.8 fixed point + TFloat scale; TUint8 color; // color to render text in public: // these routine return the width of whatever is printed to the screen - TInt8 write(TInt8 x, TInt8 y, char c); - TInt8 printf(TInt8 x, TInt8 y, const char *s, ...); + TInt16 write(TFloat x, TFloat y, char c); + TInt16 printf(TFloat x, TFloat y, const char *s, ...); #ifdef ENABLE_ROTATING_TEXT - TInt8 print_string_rotatedx(TInt8 x, TInt8 y, TFloat angle, const char *s); + TInt16 print_string_rotatedx(TFloat x, TFloat y, TFloat angle, const char *s); #endif - TInt8 print_string(TInt8 x, TInt8 y, char *s); - TInt8 print_long(TInt8 x, TInt8 y, TInt64 n, TInt8 base = 10); - TInt8 print_float(TInt8 x, TInt8 y, TFloat number, TInt8 digits = 2); + TInt16 print_string(TFloat x, TFloat y, char *s); + TInt16 print_long(TFloat x, TFloat y, TInt64 n, TInt16 base = 10); +// TInt16 print_float(TInt16 x, TInt16 y, TFloat number, TInt16 digits = 2); }; +extern GVectorFont *gVectorFont; + #endif diff --git a/Evade2/src/common/GVectorSprite.cpp b/Evade2/src/common/GVectorSprite.cpp index d0f9f7b..7714cea 100644 --- a/Evade2/src/common/GVectorSprite.cpp +++ b/Evade2/src/common/GVectorSprite.cpp @@ -1,5 +1,5 @@ #include "GVectorSprite.h" -#include "GameState/GCamera.h" +#include "GCamera.h" void GVectorSprite::SetLines(const TInt8 *aLines) { mLines = aLines; diff --git a/Evade2/src/common/GVectorSprite.h b/Evade2/src/common/GVectorSprite.h index 8d8930d..2386f52 100644 --- a/Evade2/src/common/GVectorSprite.h +++ b/Evade2/src/common/GVectorSprite.h @@ -18,7 +18,7 @@ struct vec_segment_u8 { class GVectorSprite : public BSprite { public: - GVectorSprite(TUint64 aType = STYPE_DEFAULT) : BSprite(0 , 0, ENull, aType) { + explicit GVectorSprite(TUint64 aType = STYPE_DEFAULT) : BSprite(0 , 0, ENull, aType) { mColor = COLOR_WHITE; mPad = 0; x = y = z = 0; @@ -28,15 +28,11 @@ class GVectorSprite : public BSprite { mLines = ENull; } - void StartAnimation() { - printf("GVectorSprite::StartAnimation()\n"); - } - - TBool DrawVectorGraphic(const TInt8 *graphic, TFloat x, TFloat y, TFloat theta, TFloat scaleFactor, TUint8 color) { + static TBool DrawVectorGraphic(const TInt8 *graphic, TFloat x, TFloat y, TFloat theta, TFloat scaleFactor, TUint8 color) { return ExplodeVectorGraphic(graphic, x, y, theta, scaleFactor, 0, color); } - TBool ExplodeVectorGraphic(const TInt8 *graphic, TFloat x, TFloat y, + static TBool ExplodeVectorGraphic(const TInt8 *graphic, TFloat x, TFloat y, TFloat theta, TFloat scaleFactor, TInt8 step, TUint8 color); TBool Render(BViewPort *aViewPort) OVERRIDE; diff --git a/Evade2/src/common/charset.h b/Evade2/src/common/charset.h index 56a1ad4..bcdff3e 100644 --- a/Evade2/src/common/charset.h +++ b/Evade2/src/common/charset.h @@ -762,4 +762,164 @@ const TInt8 font_amp[] = { }; #endif +const TInt8 *charset[] = { + ENull, // space + font_emark, +#ifdef FULL_CHARSET + font_dquote, +#else + ENull, +#endif +#ifdef FULL_CHARSET + font_pound, // # +#else + ENull, +#endif +#ifdef FULL_CHARSET + font_dollar, // $ +#else + ENull, +#endif +#ifdef FULL_CHARSET + font_percent, // % +#else + ENull, +#endif +#ifdef FULL_CHARSET + font_amp, // & +#else + ENull, +#endif +#ifdef FULL_CHARSET + font_squote, // ' +#else + ENull, +#endif +#ifdef FULL_CHARSET + font_lparen, // ( +#else + ENull, +#endif +#ifdef FULL_CHARSET + font_rparen, // ) +#else + ENull, +#endif +#ifdef FULL_CHARSET + font_asterisk, // * +#else + ENull, +#endif +#ifdef FULL_CHARSET + font_plus, +#else + ENull, +#endif +#ifdef FULL_CHARSET + font_comma, +#else + ENull, +#endif +#ifdef FULL_CHARSET + font_minus, +#else + ENull, +#endif + font_period, + font_fslash, + font_0, + font_1, + font_2, + font_3, + font_4, + font_5, + font_6, + font_7, + font_8, + font_9, + font_colon, +#ifdef full_charset + font_semicolon, +#else + ENull, +#endif +#ifdef full_charset + font_lt, // < +#else + ENull, +#endif +#ifdef full_charset + font_eq, // = +#else + ENull, +#endif +#ifdef full_charset + font_gt, // > +#else + ENull, +#endif +#ifdef full_charset + font_qmark, +#else + ENull, +#endif +#ifdef full_charset + font_at, // @ +#else + ENull, +#endif + font_a, + font_b, + font_c, + font_d, + font_e, + font_f, + font_g, + font_h, + font_i, + font_j, + font_k, + font_l, + font_m, + font_n, + font_o, + font_p, + font_q, + font_r, + font_s, + font_t, + font_u, + font_v, + font_w, + font_x, + font_y, + font_z, +#ifdef full_charset + font_lt, // [ +#else + ENull, +#endif +#ifdef full_charset + font_bslash, // '\' +#else + ENull, +#endif +#ifdef full_charset + font_gt, // ] +#else + ENull, +#endif +#ifdef full_charset + font_caret, // ^ +#else + ENull, +#endif +#ifdef full_charset + font_uscore, // _ +#else + ENull, +#endif + ENull, // `` +}; + #endif diff --git a/Evade2/src/img/README.md b/Evade2/src/img/README.md new file mode 100644 index 0000000..c552948 --- /dev/null +++ b/Evade2/src/img/README.md @@ -0,0 +1,4 @@ +# Vector images + +This directory contains vector images used in the game. They were created as SVG, and converted into +code suitable for our rendering routines.