diff --git a/Evade2/CMakeLists.txt b/Evade2/CMakeLists.txt index 0950045..251b9eb 100644 --- a/Evade2/CMakeLists.txt +++ b/Evade2/CMakeLists.txt @@ -24,47 +24,47 @@ ADD_COMPILE_DEFINITIONS(__MODUS_TARGET_DESKTOP_DISPLAY__=true) INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/creative-engine/CreativeEngine.cmake) -SET(MODITE_INCLUDE_DIRS +SET(EVADE2_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/resources - ${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_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 ) INCLUDE_DIRECTORIES( - ${MODITE_INCLUDE_DIRS} + ${EVADE2_INCLUDE_DIRS} ${CREATIVE_ENGINE_INCLUDE_DIRS} ) # gather Modite sources -FILE(GLOB_RECURSE MODITE_SRC RELATIVE ${CMAKE_SOURCE_DIR} "src/*.cpp") +FILE(GLOB_RECURSE EVADE2_SRC RELATIVE ${CMAKE_SOURCE_DIR} "src/*.cpp") ADD_EXECUTABLE( ${PROJECT_NAME} Resources.bin ${CREATIVE_ENGINE_SOURCE_FILES} - ${MODITE_SRC} -) + ${EVADE2_SRC} + creative-engine/src/main.cpp src/GameState/GGameState.cpp src/GameState/GGameState.h src/GameState/GGamePlayfield.cpp src/GameState/GGamePlayfield.h) ProcessorCount(N) if (NOT N EQUAL 0) diff --git a/Evade2/src/AttractState/GAttractModeState.cpp b/Evade2/old/AttractState/GAttractModeState.cpp similarity index 100% rename from Evade2/src/AttractState/GAttractModeState.cpp rename to Evade2/old/AttractState/GAttractModeState.cpp diff --git a/Evade2/src/AttractState/GAttractModeState.h b/Evade2/old/AttractState/GAttractModeState.h similarity index 100% rename from Evade2/src/AttractState/GAttractModeState.h rename to Evade2/old/AttractState/GAttractModeState.h diff --git a/Evade2/src/CreditsState/GCreditsPlayfield.cpp b/Evade2/old/CreditsState/GCreditsPlayfield.cpp similarity index 100% rename from Evade2/src/CreditsState/GCreditsPlayfield.cpp rename to Evade2/old/CreditsState/GCreditsPlayfield.cpp diff --git a/Evade2/src/CreditsState/GCreditsPlayfield.h b/Evade2/old/CreditsState/GCreditsPlayfield.h similarity index 100% rename from Evade2/src/CreditsState/GCreditsPlayfield.h rename to Evade2/old/CreditsState/GCreditsPlayfield.h diff --git a/Evade2/src/CreditsState/GCreditsProcess.cpp b/Evade2/old/CreditsState/GCreditsProcess.cpp similarity index 100% rename from Evade2/src/CreditsState/GCreditsProcess.cpp rename to Evade2/old/CreditsState/GCreditsProcess.cpp diff --git a/Evade2/src/CreditsState/GCreditsProcess.h b/Evade2/old/CreditsState/GCreditsProcess.h similarity index 100% rename from Evade2/src/CreditsState/GCreditsProcess.h rename to Evade2/old/CreditsState/GCreditsProcess.h diff --git a/Evade2/src/CreditsState/GCreditsState.cpp b/Evade2/old/CreditsState/GCreditsState.cpp similarity index 100% rename from Evade2/src/CreditsState/GCreditsState.cpp rename to Evade2/old/CreditsState/GCreditsState.cpp diff --git a/Evade2/src/CreditsState/GCreditsState.h b/Evade2/old/CreditsState/GCreditsState.h similarity index 100% rename from Evade2/src/CreditsState/GCreditsState.h rename to Evade2/old/CreditsState/GCreditsState.h diff --git a/Evade2/src/DebugMenuState/GDebugButtonWidget.cpp b/Evade2/old/DebugMenuState/GDebugButtonWidget.cpp similarity index 100% rename from Evade2/src/DebugMenuState/GDebugButtonWidget.cpp rename to Evade2/old/DebugMenuState/GDebugButtonWidget.cpp diff --git a/Evade2/src/DebugMenuState/GDebugButtonWidget.h b/Evade2/old/DebugMenuState/GDebugButtonWidget.h similarity index 100% rename from Evade2/src/DebugMenuState/GDebugButtonWidget.h rename to Evade2/old/DebugMenuState/GDebugButtonWidget.h diff --git a/Evade2/src/DebugMenuState/GDebugMenuContainer.cpp b/Evade2/old/DebugMenuState/GDebugMenuContainer.cpp similarity index 100% rename from Evade2/src/DebugMenuState/GDebugMenuContainer.cpp rename to Evade2/old/DebugMenuState/GDebugMenuContainer.cpp diff --git a/Evade2/src/DebugMenuState/GDebugMenuContainer.h b/Evade2/old/DebugMenuState/GDebugMenuContainer.h similarity index 100% rename from Evade2/src/DebugMenuState/GDebugMenuContainer.h rename to Evade2/old/DebugMenuState/GDebugMenuContainer.h diff --git a/Evade2/src/DebugMenuState/GDebugMenuState.cpp b/Evade2/old/DebugMenuState/GDebugMenuState.cpp similarity index 100% rename from Evade2/src/DebugMenuState/GDebugMenuState.cpp rename to Evade2/old/DebugMenuState/GDebugMenuState.cpp diff --git a/Evade2/src/DebugMenuState/GDebugMenuState.h b/Evade2/old/DebugMenuState/GDebugMenuState.h similarity index 100% rename from Evade2/src/DebugMenuState/GDebugMenuState.h rename to Evade2/old/DebugMenuState/GDebugMenuState.h diff --git a/Evade2/src/DebugMenuState/GDebugWidget.cpp b/Evade2/old/DebugMenuState/GDebugWidget.cpp similarity index 100% rename from Evade2/src/DebugMenuState/GDebugWidget.cpp rename to Evade2/old/DebugMenuState/GDebugWidget.cpp diff --git a/Evade2/src/DebugMenuState/GDebugWidget.h b/Evade2/old/DebugMenuState/GDebugWidget.h similarity index 100% rename from Evade2/src/DebugMenuState/GDebugWidget.h rename to Evade2/old/DebugMenuState/GDebugWidget.h diff --git a/Evade2/src/GStarFieldProcess.h b/Evade2/old/GStarFieldProcess.h similarity index 100% rename from Evade2/src/GStarFieldProcess.h rename to Evade2/old/GStarFieldProcess.h diff --git a/Evade2/src/GVectorTitle.cpp b/Evade2/old/GVectorTitle.cpp similarity index 100% rename from Evade2/src/GVectorTitle.cpp rename to Evade2/old/GVectorTitle.cpp diff --git a/Evade2/src/GVectorTitle.h b/Evade2/old/GVectorTitle.h similarity index 100% rename from Evade2/src/GVectorTitle.h rename to Evade2/old/GVectorTitle.h diff --git a/Evade2/src/GameMenuState/GExitDungeonWidget.cpp b/Evade2/old/GameMenuState/GExitDungeonWidget.cpp similarity index 100% rename from Evade2/src/GameMenuState/GExitDungeonWidget.cpp rename to Evade2/old/GameMenuState/GExitDungeonWidget.cpp diff --git a/Evade2/src/GameMenuState/GExitDungeonWidget.h b/Evade2/old/GameMenuState/GExitDungeonWidget.h similarity index 100% rename from Evade2/src/GameMenuState/GExitDungeonWidget.h rename to Evade2/old/GameMenuState/GExitDungeonWidget.h diff --git a/Evade2/src/GameMenuState/GGameMenuContainer.cpp b/Evade2/old/GameMenuState/GGameMenuContainer.cpp similarity index 100% rename from Evade2/src/GameMenuState/GGameMenuContainer.cpp rename to Evade2/old/GameMenuState/GGameMenuContainer.cpp diff --git a/Evade2/src/GameMenuState/GGameMenuContainer.h b/Evade2/old/GameMenuState/GGameMenuContainer.h similarity index 100% rename from Evade2/src/GameMenuState/GGameMenuContainer.h rename to Evade2/old/GameMenuState/GGameMenuContainer.h diff --git a/Evade2/src/GameMenuState/GGameMenuState.cpp b/Evade2/old/GameMenuState/GGameMenuState.cpp similarity index 100% rename from Evade2/src/GameMenuState/GGameMenuState.cpp rename to Evade2/old/GameMenuState/GGameMenuState.cpp diff --git a/Evade2/src/GameMenuState/GGameMenuState.h b/Evade2/old/GameMenuState/GGameMenuState.h similarity index 100% rename from Evade2/src/GameMenuState/GGameMenuState.h rename to Evade2/old/GameMenuState/GGameMenuState.h diff --git a/Evade2/src/GameMenuState/GOptionsWidget.cpp b/Evade2/old/GameMenuState/GOptionsWidget.cpp similarity index 100% rename from Evade2/src/GameMenuState/GOptionsWidget.cpp rename to Evade2/old/GameMenuState/GOptionsWidget.cpp diff --git a/Evade2/src/GameMenuState/GOptionsWidget.h b/Evade2/old/GameMenuState/GOptionsWidget.h similarity index 100% rename from Evade2/src/GameMenuState/GOptionsWidget.h rename to Evade2/old/GameMenuState/GOptionsWidget.h diff --git a/Evade2/src/GameMenuState/GQuitWidget.cpp b/Evade2/old/GameMenuState/GQuitWidget.cpp similarity index 100% rename from Evade2/src/GameMenuState/GQuitWidget.cpp rename to Evade2/old/GameMenuState/GQuitWidget.cpp diff --git a/Evade2/src/GameMenuState/GQuitWidget.h b/Evade2/old/GameMenuState/GQuitWidget.h similarity index 100% rename from Evade2/src/GameMenuState/GQuitWidget.h rename to Evade2/old/GameMenuState/GQuitWidget.h diff --git a/Evade2/src/GameMenuState/GResumeWidget.cpp b/Evade2/old/GameMenuState/GResumeWidget.cpp similarity index 100% rename from Evade2/src/GameMenuState/GResumeWidget.cpp rename to Evade2/old/GameMenuState/GResumeWidget.cpp diff --git a/Evade2/src/GameMenuState/GResumeWidget.h b/Evade2/old/GameMenuState/GResumeWidget.h similarity index 100% rename from Evade2/src/GameMenuState/GResumeWidget.h rename to Evade2/old/GameMenuState/GResumeWidget.h diff --git a/Evade2/src/GameMenuState/GSaveWidget.cpp b/Evade2/old/GameMenuState/GSaveWidget.cpp similarity index 100% rename from Evade2/src/GameMenuState/GSaveWidget.cpp rename to Evade2/old/GameMenuState/GSaveWidget.cpp diff --git a/Evade2/src/GameMenuState/GSaveWidget.h b/Evade2/old/GameMenuState/GSaveWidget.h similarity index 100% rename from Evade2/src/GameMenuState/GSaveWidget.h rename to Evade2/old/GameMenuState/GSaveWidget.h diff --git a/Evade2/src/GameState/DungeonDefs.h b/Evade2/old/GameState/DungeonDefs.h similarity index 100% rename from Evade2/src/GameState/DungeonDefs.h rename to Evade2/old/GameState/DungeonDefs.h diff --git a/Evade2/src/GameState/GAnchorSprite.cpp b/Evade2/old/GameState/GAnchorSprite.cpp similarity index 99% rename from Evade2/src/GameState/GAnchorSprite.cpp rename to Evade2/old/GameState/GAnchorSprite.cpp index 59415f4..22e74ec 100644 --- a/Evade2/src/GameState/GAnchorSprite.cpp +++ b/Evade2/old/GameState/GAnchorSprite.cpp @@ -4,6 +4,7 @@ #include "GAnchorSprite.h" #include "GGamePlayfield.h" +#if 0 // constructor GAnchorSprite::GAnchorSprite(GGameState *aGameState, TInt aPri, TUint16 aBM, TUint16 aImg, TUint16 aType) : BAnimSprite(aPri, aBM, aImg, aType), mName("NO NAME") { @@ -376,3 +377,4 @@ void GAnchorSprite::Dump() { printf("%-16.16s: %d\n", "flags", flags); printf("\n"); } +#endif \ No newline at end of file diff --git a/Evade2/src/GameState/GAnchorSprite.h b/Evade2/old/GameState/GAnchorSprite.h similarity index 99% rename from Evade2/src/GameState/GAnchorSprite.h rename to Evade2/old/GameState/GAnchorSprite.h index 002d4a6..79bc458 100644 --- a/Evade2/src/GameState/GAnchorSprite.h +++ b/Evade2/old/GameState/GAnchorSprite.h @@ -1,6 +1,7 @@ #ifndef MODITE_GANCHORSPRITE_H #define MODITE_GANCHORSPRITE_H +#if 0 #include #include #include "Game.h" @@ -151,4 +152,6 @@ class GAnchorSprite : public BAnimSprite { char mName[64]; }; +#endif + #endif // MODITE_GANCHORSPRITE_H diff --git a/Evade2/old/GameState/GGamePlayfield.cpp b/Evade2/old/GameState/GGamePlayfield.cpp new file mode 100644 index 0000000..57507b6 --- /dev/null +++ b/Evade2/old/GameState/GGamePlayfield.cpp @@ -0,0 +1,25 @@ +#include "GGamePlayfield.h" +#include "GResources.h" +#include "GHud.h" + +GGamePlayfield::GGamePlayfield(BViewPort *aViewPort) : BPlayfield() { + +// gDisplay.SetPalette(this->mTileset, 0, 128); + + GHud::SetColors(); + + TRGB *source = gDisplay.renderBitmap->GetPalette(); + for (TInt color = 0; color < 255; color++) { + TRGB c = source[color]; + mSavedPalette[color] = c; + gDisplay.SetColor(color, 0,0,0); + } + +} + +//GGamePlayfield::~GGamePlayfield() = default; + +void GGamePlayfield::Render() { + BPlayfield::Render(); +} + diff --git a/Evade2/old/GameState/GGamePlayfield.h b/Evade2/old/GameState/GGamePlayfield.h new file mode 100644 index 0000000..91ffcc1 --- /dev/null +++ b/Evade2/old/GameState/GGamePlayfield.h @@ -0,0 +1,256 @@ +#ifndef EVADE2_GGAMEPLAYFIELD_H +#define EVADE2_GGAMEPLAYFIELD_H + +//#include "Game.h" + +#include + +class GGameState; + +class GGamePlayfield : public BPlayfield { +public: + GGamePlayfield(BViewPort *aViewPort); +public: + void Render(); +public: + TRGB mSavedPalette[256]; +}; + +#if 0 +//const TFloat GRAVITY = 15.0 / FRAMES_PER_SECOND; // for falling, arrow dropping, etc. + +//#include "object_layer_attributes.h" + +// these match the codes set for tiles in Pro Motion: + +//// MAP LAYER +// NOTE: Map layer is only used for tile numbers to render. The codes are ignored. + +//// MAP ATTRIBUTE LAYER +const TUint16 ATTR_ROTATE_90 = 1u << 0u; +const TUint16 ATTR_ROTATE_180 = 1u << 1u; +const TUint16 ATTR_INVERT = 1u << 2u; +const TUint16 ATTR_FULL_FLOOR = 0; +const TUint16 ATTR_LEDGE = 1; +const TUint16 ATTR_THIN_WALL = 2; +const TUint16 ATTR_CORNER_IN = 3; +const TUint16 ATTR_CORNER_OUT = 4; +const TUint16 ATTR_CORNER_DIAGONAL = 5; +const TUint16 ATTR_HORIZONTAL_DOOR_WALL = 6; +const TUint16 ATTR_VERTICAL_DOOR_WALL = 7; + +//const TUint16 ATTR_PROJECTILE_ARROW = 25; // not sure this is going to be used like a GEnemyProcess + +//// OBJECT LAYER VALUES +const TUint16 ATTR_GONE = 0; // thing is no longer in the world +const TUint16 ATTR_STONE_STAIRS_UP = 1; +const TUint16 ATTR_STONE_STAIRS_DOWN = 2; +const TUint16 ATTR_WOOD_STAIRS_UP = 3; +const TUint16 ATTR_WOOD_STAIRS_DOWN = 4; +const TUint16 ATTR_POT = 5; +const TUint16 ATTR_CHEST = 6; +const TUint16 ATTR_SPIKES = 7; +const TUint16 ATTR_WOOD_DOOR_H = 8; // horizontal +const TUint16 ATTR_WOOD_DOOR_V = 9; // vertical +const TUint16 ATTR_METAL_GATE_H = 10; // horizontal +const TUint16 ATTR_METAL_GATE_V = 11; // vertical +const TUint16 ATTR_LEVER = 12; // tri state lever +const TUint16 ATTR_FLOOR_SWITCH = 13; +const TUint16 ATTR_FLOOR_SWITCH_WOOD = 14; +const TUint16 ATTR_PLAYER_IN1 = 100; +const TUint16 ATTR_PLAYER_IN2 = 101; +const TUint16 ATTR_SPIDER = 17; +const TUint16 ATTR_BAT = 18; +const TUint16 ATTR_GOBLIN = 19; +const TUint16 ATTR_GOBLIN_SNIPER = 20; +const TUint16 ATTR_ORC = 21; +const TUint16 ATTR_RAT = 22; +const TUint16 ATTR_SLIME = 23; +const TUint16 ATTR_TROLL = 24; +const TUint16 ATTR_CHEST_OPEN = 25; +const TUint16 ATTR_POT_GONE = 26; +const TUint16 ATTR_DUNGEON_ENTRANCE = 27; +const TUint16 ATTR_DUNGEON_EXIT_FROM_LEVEL_1 = 28; +const TUint16 ATTR_TURRET = 29; +const TUint16 ATTR_SPAWN_SMALL_HEALTH = 30; +const TUint16 ATTR_SPAWN_LARGE_HEALTH = 31; +const TUint16 ATTR_SPAWN_SMALL_MANA = 32; +const TUint16 ATTR_SPAWN_LARGE_MANA = 33; +const TUint16 ATTR_SPAWN_HEART = 34; +// mid bosses +const TUint16 ATTR_MID_BOSS_EARTH = 1001; +const TUint16 ATTR_MID_BOSS_WATER = 1002; +const TUint16 ATTR_MID_BOSS_FIRE = 1003; +const TUint16 ATTR_MID_BOSS_ENERGY = 1004; +const TUint16 ATTR_WIZARD_EARTH = 1005; +const TUint16 ATTR_WIZARD_WATER = 1006; +const TUint16 ATTR_WIZARD_FIRE = 1007; +const TUint16 ATTR_WIZARD_ENERGY = 1008; +const TUint16 ATTR_FINAL_BOSS = 1009; +const TUint16 ATTR_FINAL_BOSS_EARTH = 1005; +const TUint16 ATTR_FINAL_BOSS_WATER = 1006; +const TUint16 ATTR_FINAL_BOSS_FIRE = 1007; +const TUint16 ATTR_FINAL_BOSS_ENERGY = 1008; + + + +// +const TUint16 ATTR_KEEP = 32767; // pass this to EndProgram to keep existing OBJECT_LAYER value + +//// OBJECT ATTRIBUTE LAYER VALUES +// Note: these values are unique per thing +// That is, stairs has its own 0-0xffff attributes and crate has its own, and so on. +// Some things, like a key, might be in a crate or simply on the floor, so those have +// to be considered/globally unique. + +// stairs (destinations) +const TUint16 ATTR_OW_LEVEL_ENTRANCE = 99; + +// items (can be inside crates, chests, inventory) +// RED = LEFT, BLUE = MAGIC +// SEE +const TUint16 ATTR_EMPTY = 0; +const TUint16 ATTR_BLUE_SPELLBOOK = 1; +const TUint16 ATTR_RED_SPELLBOOK = 2; +const TUint16 ATTR_GREEN_SPELLBOOK = 3; +const TUint16 ATTR_YELLOW_SPELLBOOK = 4; +const TUint16 ATTR_SILVER_KEY = 5; +const TUint16 ATTR_GOLD_KEY = 6; +const TUint16 ATTR_BLUE_RING = 7; +const TUint16 ATTR_RED_RING = 8; +const TUint16 ATTR_GREEN_RING = 9; +const TUint16 ATTR_YELLOW_RING = 10; +const TUint16 ATTR_BOOTS = 11; +const TUint16 ATTR_GLOVES = 12; +const TUint16 ATTR_SWORD = 13; +const TUint16 ATTR_BLUE_AMULET = 14; +const TUint16 ATTR_RED_AMULET = 15; +const TUint16 ATTR_GREEN_AMULET = 16; +const TUint16 ATTR_YELLOW_AMULET = 17; +const TUint16 ATTR_RED_POTION1 = 18; +const TUint16 ATTR_RED_POTION2 = 19; +const TUint16 ATTR_BLUE_POTION1 = 20; +const TUint16 ATTR_BLUE_POTION2 = 21; +const TUint16 ATTR_HEART = 22; + +const TUint16 ATTR_EMPTY_BOTTLE = 23; // empty bottle +const TUint16 ATTR_BLUE_BOTTLE1 = 24; // 25% full +const TUint16 ATTR_BLUE_BOTTLE2 = 25; // 50% full +const TUint16 ATTR_BLUE_BOTTLE3 = 26; // 75% full +const TUint16 ATTR_BLUE_BOTTLE4 = 27; // 100% full +const TUint16 ATTR_RED_BOTTLE1 = 28; // 25% full +const TUint16 ATTR_RED_BOTTLE2 = 29; // 50% full +const TUint16 ATTR_RED_BOTTLE3 = 30; // 75% full +const TUint16 ATTR_RED_BOTTLE4 = 31; // 100% full + +const TInt MOSAIC_DURATION = 0.5 * FRAMES_PER_SECOND; +const TInt MOSAIC_INTENSITY = 20; + +const TInt WALL_THICKNESS = 12; // minimum thickness of walls + +class GGamePlayfield : public BMapPlayfield { +public: + GGamePlayfield(BViewPort *aViewPort, TUint16 aTileMapId); + + ~GGamePlayfield() OVERRIDE; + +public: + void Render() OVERRIDE; + + void StartMosaicIn(); + + void StartMosaicOut(); + + TBool MosaicActive() { + return mMosaicTimer > 1; + } + + TBool MosaicDone() { + return mMosaicTimer == 1; + }; + + void Restore(); + + void DumpObjectProgram() { + for (TInt i=0; i> 16); + } + + TUint16 GetAttribute(TInt aRow, TInt aCol) { + return TUint16(GetCell(aRow, aCol) >> 16); + } + + TBool IsFloor(TFloat aWorldX, TFloat aWorldY) { + const TUint16 attr = GetAttribute(aWorldX, aWorldY); + const TInt col = TInt(FLOOR(aWorldX / TILESIZE)), + row = TInt(FLOOR(aWorldY / TILESIZE)); + TInt x = TInt(aWorldX) % TILESIZE, y = TInt(aWorldY) % TILESIZE, tmp; + if (row >= 0 && row <= mMapHeight - 1 && col >= 0 && col <= mMapWidth - 1) { + TBool inverted = attr & ATTR_INVERT; + if (attr & ATTR_ROTATE_90) { + tmp = x; + x = y; + y = TILESIZE - tmp; + } + if (attr & ATTR_ROTATE_180) { + x = TILESIZE - x; + y = TILESIZE - y; + } + switch (attr >> 3u) { + case ATTR_FULL_FLOOR: + default: + return !inverted; + case ATTR_THIN_WALL: + case ATTR_LEDGE: + return inverted ^ (x > WALL_THICKNESS); + case ATTR_CORNER_IN: + return inverted ^ (x > WALL_THICKNESS && y > WALL_THICKNESS); + case ATTR_CORNER_OUT: + return inverted ^ (x > WALL_THICKNESS || y > WALL_THICKNESS); + case ATTR_CORNER_DIAGONAL: + return inverted ^ (x + y < TILESIZE - WALL_THICKNESS); + case ATTR_HORIZONTAL_DOOR_WALL: + return y < 16; + case ATTR_VERTICAL_DOOR_WALL: + return x < 8 || x > 24; + } + } + else { + return (row == -1 && y > -WALL_THICKNESS) || + (row == mMapHeight && y <= WALL_THICKNESS) || + (col == -1 && x > -WALL_THICKNESS) || + (col == mMapWidth && x <= WALL_THICKNESS); + } + } + + TBool IsLedge(TFloat aWorldX, TFloat aWorldY) { + return GetAttribute(aWorldX, aWorldY) >> 3u == ATTR_LEDGE; + } + +public: + TBool mGroupState[16], mGroupDone[16]; + +public: + void WriteToStream(BMemoryStream &aStream); + + void ReadFromStream(BMemoryStream &aStream); + +protected: + GGameState *mGameState; + TUint32 mTileMapId; + TInt mMosaicTimer; + TBool mMosaicIn; + TRGB mSavedPalette[256]; +}; +#endif + +#endif //EVADE2_GGAMEPLAYFIELD_H diff --git a/Evade2/old/GameState/GGameState.cpp b/Evade2/old/GameState/GGameState.cpp new file mode 100644 index 0000000..9da2f3a --- /dev/null +++ b/Evade2/old/GameState/GGameState.cpp @@ -0,0 +1,1122 @@ +// Game State +#include "GGameState.h" +#include "GGamePlayfield.h" +#include "GResources.h" +#include "GameState/player/GGameOver.h" +#include "GameState/player/GPlayerProcess.h" +#include "GHud.h" + +#include "GPlayer.h" + +#include + +#define DEBUGME +//#undef DEBUGME + +// DEBUG_FINALBOSS causes wizard spawn to become final boss spawn so we can debug the final boss +#define DEBUG_FINALBOSS +#undef DEBUG_FINALBOSS + +// info about the dungeons +#include "DungeonDefs.h" +const TInt NUM_DUNGEONS = sizeof(gDungeonDefs) / sizeof(TDungeonInfo); + +/******************************************************************************* + ******************************************************************************* + *******************************************************************************/ + +void GGameState::Init() { + strcpy(mText, ""); + strcpy(mName, ""); + mLevel = 0; + mNextDungeon = mDungeon = 0; + mNextLevel = 0; + mTileMapId = 0; + mPlayerToLoad = ATTR_PLAYER_IN1; + + mNextTileMapId = 0; + mNextObjectsId = 0; + + mTimer = FRAMES_PER_SECOND * 1; + mCameraTimer = 0; + mGameOver = ENull; + + mGamePlayfield = mNextGamePlayfield = ENull; + + // Clear BObject programs +// GGamePlayfield::ResetCache(); + + + gViewPort->SetRect(TRect(0, 16, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1)); + gViewPort->Offset(0, 16); + gDisplay.SetColor(COLOR_TEXT_BG, 0, 0, 0); + gDisplay.SetColor(COLOR_TEXT, 255, 255, 255); + GPlayer::Init(); +} + +// Constructor +GGameState::GGameState() : BGameEngine(gViewPort) { + Init(); + for (TInt i = 2; i < SLOT_MAX; i++) { + if (gResourceManager.GetBitmap(i)) { + printf("Releasing slot %d\n", i); + gResourceManager.ReleaseBitmapSlot(i); + } + mSlotRemapState[i] = EFalse; + } + NextLevel(OVERWORLD_DUNGEON, 1); +} + +// Constructor +GGameState::GGameState(const char *aName) : BGameEngine(gViewPort) { + Init(); + for (TInt i = 2; i < SLOT_MAX; i++) { + if (gResourceManager.GetBitmap(i)) { + printf("Releasing slot %d\n", i); + gResourceManager.ReleaseBitmapSlot(i); + } + mSlotRemapState[i] = EFalse; + } + LoadState(aName); +} + +GGameState::~GGameState() = default; + +GProcess *GGameState::AddProcess(GProcess *p) { + mProcessList.AddProcess(p); + return p; +} + +void GGameState::TryAgain(TBool aExitDungeon) { + GPlayer::mGameOver = EFalse; + GPlayer::mHitPoints = GPlayer::mMaxHitPoints; + + if (aExitDungeon) { + NextLevel(OVERWORLD_DUNGEON, LastOverworldLevel()); + return; + } + + // Cache previous respawn coords, LoadLevel resets them + TFloat respawnAt[2] = { GPlayerProcess::mRespawnAt[0], GPlayerProcess::mRespawnAt[1] }; + + // Reset the level + LoadLevel(mName, mLevel, mTileMapId); + gDisplay.SetColor(COLOR_WHITE, 255, 255, 255); + + + // Restore respawn coords + GPlayerProcess::mRespawnAt[0] = respawnAt[0]; + GPlayerProcess::mRespawnAt[1] = respawnAt[1]; + + if (respawnAt[0] != '\0') { + GAnchorSprite *s = GPlayer::mProcess->Sprite(); + s->x = respawnAt[0]; + s->y = respawnAt[1]; +#ifdef DEBUG_MODE + printf("RESPAWNED AT %f %f\n", respawnAt[0], respawnAt[1]); +#endif + } +} + +TBool GGameState::IsBossRoom() { + TInt objectCount = mGamePlayfield->mObjectCount; + BObjectProgram *program = mGamePlayfield->mObjectProgram; + for (TInt ip = 0; ip < objectCount; ip++) { + TUint16 op = program[ip].mCode & TUint32(0xffff); + switch (op) { + case ATTR_MID_BOSS_EARTH: + case ATTR_MID_BOSS_ENERGY: + case ATTR_MID_BOSS_FIRE: + case ATTR_MID_BOSS_WATER: + case ATTR_WIZARD_EARTH: + case ATTR_WIZARD_ENERGY: + case ATTR_WIZARD_FIRE: + case ATTR_WIZARD_WATER: + case ATTR_FINAL_BOSS: + return ETrue; + default: + continue; + } + } + + return EFalse; +} + +/******************************************************************************* + ******************************************************************************* + *******************************************************************************/ + +void GGameState::PreRender() { + if (mNextLevel != mLevel || mNextDungeon != mDungeon) { + if (mLevel) { + mGamePlayfield->StartMosaicOut(); + + if (mGamePlayfield->MosaicDone()) { + LoadLevel(mName, mNextLevel, mNextTileMapId); + + } + } + else { + LoadLevel(mName, mNextLevel, mNextTileMapId); + } + } + gDisplay.SetColor(COLOR_WHITE, 255, 255, 255); +} + +/******************************************************************************* + ******************************************************************************* + *******************************************************************************/ + +void GGameState::PositionCamera() { + // position viewport to follow player + TFloat maxx = MapWidth(), + maxy = MapHeight(); + + // half viewport size + const TFloat ww = gViewPort->mRect.Width() / 2.0, + hh = gViewPort->mRect.Height() / 2.0; + TPoint playerCenter = GPlayer::mSprite->Center(); + + // upper left corner of desired viewport position + TFloat xx = playerCenter.x - ww, + yy = playerCenter.y - hh; + + if (mCameraTimer > 0) { + mCameraTimer--; + TFloat cameraInertia = exp(-FACTOR * TFloat(mCameraTimer) / TARGET_PAN_DURATION); + mWorldXX += (xx - mWorldXX) * cameraInertia; + mWorldYY += (yy - mWorldYY) * cameraInertia; + } else { + mWorldXX = xx; + mWorldYY = yy; + } + if (mWorldXX < 0) { + mWorldXX = 0; + } + else if (mWorldXX > maxx) { + mWorldXX = maxx; + } + if (mWorldYY < 0) { + mWorldYY = 0; + } + else if (mWorldYY > maxy) { + mWorldYY = maxy; + } + + gViewPort->mWorldX = TInt(mWorldXX); + gViewPort->mWorldY = TInt(mWorldYY); +} + +static void fuel_gauge(BViewPort *vp, TInt x, TInt y, TInt stat, TInt stat_max, TUint8 color) { +// BBitmap *screen = gDisplay.renderBitmap; +// +// // calculate fill percentage +// TRect r(0, 0, GAUGE_WIDTH, 8); +// +// // offset to display coordinates +// r.Offset(x, y); +// +// // draw frame +// screen->DrawRect(vp, r, COLOR_TEXT); +// +// // calculate percentage +// TFloat pct = stat_max ? (TFloat(stat)) / TFloat(stat_max) : 0.; +// TFloat gw = pct * GAUGE_WIDTH; +// +// // fill area +// TRect fill(0, 0, TInt(gw), 8); +// fill.x1 += 2; +// fill.y1 += 2; +// fill.x2 -= 2; +// fill.y2 -= 2; +// if (fill.x2 < fill.x1) { +// fill.x2 = fill.x1 + 1; +// } +// fill.Offset(x, y); +// screen->FillRect(vp, fill, color); +} + +void GGameState::PostRender() { + GHud::Render(); + + if (mGameOver) { + mGameOver->Run(); + if (mGamePlayfield->MosaicActive()) { + delete mGameOver; + mGameOver = ENull; + } else { + return; + } + } + + if (mGamePlayfield->MosaicActive()) { + gControls.Reset(); + Pause(); + } + else if (mGamePlayfield->MosaicDone()) { + Resume(); + } + +#ifdef DEBUG_MODE + if (mTimer-- < 0) { + mTimer = FRAMES_PER_SECOND * 1; + sprintf(mText, "%s Level %d", mName, mLevel); + } + + if (mText[0]) { + gDisplay.renderBitmap->DrawString(gViewPort, mText, gFont8x8, 4, 4, COLOR_TEXT, COLOR_TEXT_TRANSPARENT); + } +#endif +} + +/******************************************************************************* + ******************************************************************************* + *******************************************************************************/ + +TUint16 GGameState::MapWidth() { + return (mGamePlayfield->MapWidthTiles() - gViewPort->mRect.Width() / 32) * 32; +} + +TUint16 GGameState::MapHeight() { + return (mGamePlayfield->MapHeightTiles() - gViewPort->mRect.Height() / 32) * 32; +} + +void GGameState::GameLoop() { + for (bool &s : mGamePlayfield->mGroupState) { + s = ETrue; + } + + BGameEngine::GameLoop(); + + for (TInt s = 0; s < 16; s++) { + if (mGamePlayfield->mGroupState[s] == ETrue) { + mGamePlayfield->mGroupDone[s] = ETrue; + } + } +} + +/******************************************************************************* + ******************************************************************************* + *******************************************************************************/ + +/** + * This is safe to call from BProcess context. + * + * @param aDungeon ID of dungeon (in gDungeonDefs) + * @param aLevel Level in dungeon + */ +void GGameState::NextLevel(const TInt16 aDungeon, const TInt16 aLevel) { + if (aDungeon == -1) { + // -1 means stay in the same dungeon + mNextDungeon = mDungeon; + + if (mNextDungeon != OVERWORLD_DUNGEON) { + if (aLevel > mLevel) { + // Going up + mPlayerToLoad = ATTR_PLAYER_IN1; + } + else if (aLevel < mLevel) { + // Going Down + mPlayerToLoad = ATTR_PLAYER_IN2; + } + } + } + else { + mNextDungeon = aDungeon; + mPlayerToLoad = ATTR_PLAYER_IN1; + } + + mNextLevel = aLevel; + strcpy(mName, gDungeonDefs[mNextDungeon].name); + mNextTileMapId = gDungeonDefs[mNextDungeon].mInfo.map[aLevel]; + mNextObjectsId = gDungeonDefs[mNextDungeon].mInfo.objectsId; + + if (!mGamePlayfield) { + mPlayfield = mGamePlayfield = new GGamePlayfield(gViewPort, mNextTileMapId); + } + sprintf(mText, "%s Level %d", mName, aLevel); +} + +void GGameState::SetPlayfieldXYFromPlayer(TFloat aPlayerX, TFloat aPlayerY) { + TFloat maxx = MapWidth(), + maxy = MapHeight(); + + // upper left corner of desired viewport position + TFloat xx = gViewPort->mWorldX = aPlayerX, + yy = gViewPort->mWorldY = aPlayerY; + + if (xx < 0) { + gViewPort->mWorldX = 0; + } + else if (xx > maxx) { + gViewPort->mWorldX = maxx; + } + if (yy < 0) { + gViewPort->mWorldY = 0; + } + else if (yy > maxy) { + gViewPort->mWorldY = maxy; + } +} + +/** + * This is NOT safe to call from BProcess context + */ +void GGameState::LoadLevel(const char *aName, const TInt16 aLevel, TUint16 aTileMapId, TBool aSpawnObjects) { +// mNextGamePlayfield = new GGamePlayfield(gViewPort, mNextTileMapId); +// +// strcpy(mName, aName); +// +// const TUint16 overworld_exit = mNextDungeon == OVERWORLD_DUNGEON ? mDungeon : OVERWORLD_DUNGEON; +// const TUint16 exiting_level = mLevel; +// TBool is_same_dungeon = (mDungeon != OVERWORLD_DUNGEON) && (mNextDungeon == mDungeon); +// +// if (mDungeon == OVERWORLD_DUNGEON) { +// mLastOverworldLevel = mLevel; +// } +// +// mLevel = mNextLevel = aLevel; +// mDungeon = mNextDungeon; +// mTileMapId = aTileMapId; +// +// Reset(); // remove sprites and processes +// InitRemapSlots(); +// mPlayfield = mGamePlayfield = mNextGamePlayfield; +// gDisplay.SetPalette(mGamePlayfield->GetTilesBitmap(), 0, 128); +// mNextGamePlayfield = ENull; +// GPlayer::mProcess = ENull; +// +// RemapSlot(mNextObjectsId, ENVIRONMENT_SLOT, IMAGE_32x32); +//// RemapSlot(CHARA_HERO_BMP, PLAYER_SLOT); +//// RemapSlot(CHARA_HERO_HEAL_EFFECT_BMP, PLAYER_HEAL_SLOT, IMAGE_32x32); +//// RemapSlot(CHARA_HERO_SPELL_EFFECT_BMP, PLAYER_SPELL_SLOT, IMAGE_32x32); +//// RemapSlot(SPELL_EARTH_BMP, SPELL_EARTH_SLOT, IMAGE_64x64); +//// RemapSlot(SPELL_ELECTRICITY_BMP, SPELL_ELECTRICITY_SLOT, IMAGE_64x64); +//// RemapSlot(SPELL_FIRE_BMP, SPELL_FIRE_SLOT, IMAGE_64x64); +//// RemapSlot(SPELL_WATER_BMP, SPELL_WATER_SLOT, IMAGE_64x64); +//// RemapSlot(ENEMY_DEATH_BMP, ENEMY_DEATH_SLOT, IMAGE_32x32); +// +// GPlayer::mProcess = new GPlayerProcess(this); +// AddProcess(GPlayer::mProcess); +// +//#ifdef DEBUGME +// printf("Level loaded, colors used %d\n", mGamePlayfield->GetTilesBitmap()->CountUsedColors()); +//#endif +// +// TInt objectCount = mGamePlayfield->mObjectCount; +// BObjectProgram *program = mGamePlayfield->mObjectProgram; +// TInt eCount = 0; +// +// // Spikes operations +// // Reset spike group counter on level load +// memset(GSpikesProcess::mGroups, 0, sizeof(GSpikesProcess::mGroups)); +// TBool startedPlayer = EFalse; +// TInt spikesMatrix[70][70] = {{0}}; // max level size +// TInt16 spikeGroup = 1; +// +// // Set spikes matrix +// for (TInt ip = 0; ip < objectCount; ip++) { +// if ((program[ip].mCode & TUint32(0xffff)) == ATTR_SPIKES) { +// spikesMatrix[program[ip].mRow][program[ip].mCol] = spikeGroup; +// } +// } +// +// TInt16 spawnedBoss = -1; +// +// for (TInt ip = 0; ip < objectCount; ip++) { +//#ifdef DEBUGME +// printf("%5d: ", ip); +//#endif +// const TUint16 op = program[ip].mCode & TUint32(0xffff), +// params = program[ip].mCode >> TUint32(16), +// row = program[ip].mRow, +// col = program[ip].mCol; +// +// auto xx = TFloat(col * TILESIZE), +// yy = TFloat(row * TILESIZE); +// +// switch (op) { +// +// // +// // ENVIRONMENT +// // +// case ATTR_DUNGEON_EXIT_FROM_LEVEL_1: +//#ifdef DEBUGME +// printf("EXIT TO OVERWORLD at %.2f,%.2f %d,%d %d/%x\n", xx, yy, row, col, params, params); +//#endif +// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_RIGHT, " "); +// break; +// +// case ATTR_STONE_STAIRS_UP: +//#ifdef DEBUGME +// printf("STONE STAIRS UP at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_UP, "STONE"); +// break; +// +// case ATTR_OW_LEVEL_ENTRANCE: +//#ifdef DEBUGME +// printf("OVERWORLD LEVEL TRANSITION at %.2f,%.2f %d,%d %d/%x\n", xx, yy, row, col, params, params); +//#endif +// if (mDungeon == OVERWORLD_DUNGEON) { +// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_DOWN, "DUNGEON"); +// } +// +// break; +// +// case ATTR_STONE_STAIRS_DOWN: +//#ifdef DEBUGME +// printf("STONE STAIRS DOWN at %.2f,%.2f %d,%d %d/%x\n", xx, yy, row, col, params, params); +//#endif +// if (mDungeon == OVERWORLD_DUNGEON) { +// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_DOWN, "DUNGEON"); +// } +// else { +// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_DOWN, "STONE"); +// } +// break; +// +// case ATTR_WOOD_STAIRS_UP: +//#ifdef DEBUGME +// printf("WOOD STAIRS UP at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_UP, "WOOD"); +// break; +// +// case ATTR_WOOD_STAIRS_DOWN: +//#ifdef DEBUGME +// printf("WOOD STAIRS DOWN at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_DOWN, "WOOD"); +// break; +// +// case ATTR_POT: +//#ifdef DEBUGME +// printf("POT at %.2f,%.2f %d, %d\n", xx, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_DOWN, "POT"); +// break; +// +// case ATTR_POT_GONE: +//#ifdef DEBUGME +// printf("POT GONE at %.2f,%.2f %d, %d\n", xx, yy, row, col); +//#endif +// if (params) { +// GItemProcess::SpawnItem(this, ip, params, xx, yy + 32); +// } +// break; +// +// case ATTR_CHEST: +//#ifdef DEBUGME +// printf("CHEST CLOSED at %.2f,%.2f %d, %d\n", xx, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_DOWN, "CHEST"); +// break; +// +// case ATTR_CHEST_OPEN: +//#ifdef DEBUGME +// printf("CHEST OPEN at %.2f,%.2f %d,%d ATTR: %d\n", xx, yy, row, col, params); +//#endif +// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_DOWN, "CHEST"); +// break; +// +// case ATTR_SPIKES: +//#ifdef DEBUGME +// printf("SPIKES at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// // Check the surrounding tiles to the left and top for spikes +// // if there aren't any increment group counter and set all spike tiles to it +// if ( +// spikesMatrix[row-1][col] == 0 && +// spikesMatrix[row][col-1] == 0 && +// spikesMatrix[row-1][col-1] == 0 && +// spikesMatrix[row-1][col+1] == 0) +// { +// // Check adjecent node that wasn't processed yet, but could've been set +// if (spikesMatrix[row+1][col-1] == 0) { +// if (++spikeGroup > MAX_SPIKE_GROUPS) { +// Panic("Reached spike group limit!\n"); +// } +// } +// spikesMatrix[row][col] = spikeGroup; +// } +// +// if (spikesMatrix[row+1][col] > 0) spikesMatrix[row+1][col] = spikesMatrix[row][col]; +// if (spikesMatrix[row][col + 1] > 0) spikesMatrix[row][col+1] = spikesMatrix[row][col]; +// if (spikesMatrix[row+1][col + 1] > 0) spikesMatrix[row+1][col+1] = spikesMatrix[row][col]; +// if (spikesMatrix[row+1][col - 1] > 0) spikesMatrix[row+1][col-1] = spikesMatrix[row][col]; +// +// GProcess::Spawn(this, op, ip, xx, yy, spikesMatrix[row][col], DIRECTION_DOWN, "SPIKES"); +// break; +// +// case ATTR_METAL_GATE_H: +//#ifdef DEBUGME +// printf("METAL DOOR H at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx, yy + 30, params, DIRECTION_DOWN, "METAL DOOR HORIZONTAL"); +// break; +// +// case ATTR_METAL_GATE_V: +//#ifdef DEBUGME +// printf("METAL DOOR V at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx, yy + 30, params, DIRECTION_DOWN, "METAL DOOR VERTICAL"); +// break; +// +// case ATTR_WOOD_DOOR_H: +//#ifdef DEBUGME +// printf("WOOD DOOR H at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx, yy + 30, params, DIRECTION_DOWN, "WOOD DOOR HORIZONTAL"); +// break; +// +// case ATTR_WOOD_DOOR_V: +//#ifdef DEBUGME +// printf("WOOD DOOR V at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx, yy + 30, params, DIRECTION_DOWN, "WOOD DOOR VERTICAL"); +// break; +// +// case ATTR_LEVER: +//#ifdef DEBUGME +// printf("LEVER at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx, yy + 30, params, DIRECTION_DOWN, "LEVER"); +// break; +// +// case ATTR_FLOOR_SWITCH: +//#ifdef DEBUGME +// printf("FLOOR_SWITCH at %.2f,%.2f %d,%d params: %x\n", xx, yy, row, col, params); +//#endif +// GProcess::Spawn(this, op, ip, xx, yy + 32, params, DIRECTION_DOWN, "STONE FLOOR SWITCH"); +// break; +// +// case ATTR_FLOOR_SWITCH_WOOD: +//#ifdef DEBUGME +// printf("FLOOR_SWITCH at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx, yy + 32, params, DIRECTION_DOWN, "WOOD FLOOR SWITCH"); +// break; +// +// // +// // PLAYER +// // +// // This case is used for the player 1 entrance for dungeon levels AND overworld entrance auto-detection. +// case ATTR_PLAYER_IN1: +// if (!aSpawnObjects || mPlayerToLoad != ATTR_PLAYER_IN1) { +// break; +// } +//#ifdef DEBUGME +// printf("PLAYER IN1 at %.2f,%.2f\n", xx, yy); +//#endif +// if (mDungeon == OVERWORLD_DUNGEON) { +// GPlayer::mProcess->StartLevel(mGamePlayfield, xx - 16, yy + 32, overworld_exit, exiting_level); +// SetPlayfieldXYFromPlayer(xx - 16, yy + 32); +// } +// else { +// GPlayer::mProcess->StartLevel(mGamePlayfield, xx - 16, yy + 28, overworld_exit, exiting_level); +// SetPlayfieldXYFromPlayer(xx - 16, yy + 28); +// } +// startedPlayer = ETrue; +// break; +// +// // This case is used for the player 2 entrance for levels within dungeons only! +// case ATTR_PLAYER_IN2: +// if (mPlayerToLoad != ATTR_PLAYER_IN2) { +// break; +// } +//#ifdef DEBUGME +// printf("PLAYER IN2 at %.2f,%.2f\n", xx, yy); +//#endif +// GPlayer::mProcess->StartLevel(mGamePlayfield, xx - 16, yy + 32, overworld_exit, exiting_level); +// SetPlayfieldXYFromPlayer(xx - 16, yy - 32); +// +// startedPlayer = ETrue; +// break; +// +// // +// // ENEMIES +// // +// case ATTR_SPIDER: +// RemapSlot(CHARA_SPIDER_BMP, SPIDER_SLOT); +// +// if (!aSpawnObjects) { +// break; +// } +//#ifdef DEBUGME +// printf("SPIDER at %.2f,%.2f %d,%d\n", xx - 32, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx - 16, yy + 32, params, DIRECTION_DOWN, "ENEMY SPIDER"); +// break; +// +// case ATTR_BAT: +// RemapSlot(CHARA_BAT_BMP, BAT_SLOT); +// +//#ifdef DEBUGME +// printf("BAT at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx - 16, yy + 32, params, DIRECTION_DOWN, "ENEMY BAT"); +// break; +// +// case ATTR_GOBLIN: +// RemapSlot(CHARA_GOBLIN_BMP, GOBLIN_SLOT); +// if (!aSpawnObjects) { +// break; +// } +//#ifdef DEBUGME +// printf("GOBLIN at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx - 16, yy + 32, params, DIRECTION_DOWN, "ENEMY GOBLIN"); +// break; +// +// case ATTR_GOBLIN_SNIPER: +// RemapSlot(CHARA_GOBLIN_SNIPER_BMP, GOBLIN_SNIPER_SLOT); +// RemapSlot(PROJECTILE_ARROW_BMP, PROJECTILE_ARROW_SLOT, IMAGE_32x32); +// if (!aSpawnObjects) { +// break; +// } +//#ifdef DEBUGME +// printf("GOBLIN_SNIPER at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx - 16, yy + 32, params, DIRECTION_DOWN, "ENEMY GOBLIN SNIPER"); +// break; +// +// case ATTR_ORC: +// RemapSlot(CHARA_ORC_BMP, ORC_SLOT); +// if (!aSpawnObjects) { +// break; +// } +//#ifdef DEBUGME +// printf("ORC at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx - 16, yy + 32, params, DIRECTION_DOWN, "ENEMY ORC"); +// break; +// +// case ATTR_RAT: +// RemapSlot(CHARA_RAT_BMP, RAT_SLOT); +// +// if (!aSpawnObjects) { +// break; +// } +//#ifdef DEBUGME +// printf("RAT at %.2f,%.2f %d,%d,%d\n", xx, yy, row, col, eCount); +//#endif +// GProcess::Spawn(this, op, ip, xx - 16, yy + 32, params, DIRECTION_DOWN, "ENEMY RAT"); +// break; +// +// case ATTR_SLIME: +// RemapSlot(CHARA_SLIME_BMP, SLIME_SLOT); +// +// if (!aSpawnObjects) { +// break; +// } +//#ifdef DEBUGME +// printf("SLIME at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx - 16, yy + 31, params, DIRECTION_DOWN, "ENEMY SLIME"); +// break; +// +// case ATTR_TROLL: +// RemapSlot(CHARA_TROLL_BMP, TROLL_SLOT); +// +// if (!aSpawnObjects) { +// break; +// } +//#ifdef DEBUGME +// printf("TROLL at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx - 16, yy + 32, params, DIRECTION_DOWN, "ENEMY TROLL"); +// break; +// +// case ATTR_TURRET: +// RemapSlot(CRYSTAL_BMP, TURRET_SLOT, IMAGE_64x64); +// RemapSlot(PROJECTILE_CRYSTAL_BMP, PROJECTILE_CRYSTAL_SLOT, IMAGE_32x32); +// if (!aSpawnObjects) { +// break; +// } +//#ifdef DEBUGME +// printf("TURRET at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GProcess::Spawn(this, op, ip, xx - 16, yy + 32, params, DIRECTION_DOWN, "ENEMY TURRET"); +// break; +// +// // mid boss +// // only one mid boss can be available +// case ATTR_MID_BOSS_ENERGY: +//#ifdef DEBUGME +// printf("MID BOSS ENERGY at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// // always explosion (for any enemy) +// RemapSlot(MID_BOSS_DEATH_EXPLOSION_BMP, BOSS_DEATH_SLOT, IMAGE_64x64); +// // Sprite sheet for enemy +// RemapSlot(MID_BOSS_ENERGY_BMP, BOSS_SLOT, IMAGE_128x128); +// // Sprite sheet for enemy projectiles +// RemapSlot(MID_BOSS_ENERGY_PROJECTILE_BMP, BOSS_PROJECTILE_SLOT, IMAGE_32x32); +// +// if (!aSpawnObjects) { +// break; +// } +// GProcess::Spawn(this, op, ip, xx, yy + 64, params, DIRECTION_DOWN, "ENEMY MID BOSS ENERGY"); +// spawnedBoss = op; +// +// break; +// +// case ATTR_MID_BOSS_FIRE: +//#ifdef DEBUGME +// printf("MID BOSS FIRE at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// // always explosion (for any enemy) +// RemapSlot(MID_BOSS_DEATH_EXPLOSION_BMP, BOSS_DEATH_SLOT, IMAGE_64x64); +// // Sprite sheet for enemy +// RemapSlot(MID_BOSS_FIRE_BMP, BOSS_SLOT, IMAGE_128x128); +// // Sprite sheet for enemy projectiles +// RemapSlot(MID_BOSS_FIRE_PROJECTILE_BMP, BOSS_PROJECTILE_SLOT, IMAGE_32x32); +// +// if (!aSpawnObjects) { +// break; +// } +// GProcess::Spawn(this, op, ip, xx, yy + 64, params, DIRECTION_DOWN, "ENEMY MID BOSS FIRE"); +// spawnedBoss = op; +// +// break; +// +// case ATTR_MID_BOSS_EARTH: +//#ifdef DEBUGME +// printf("MID BOSS EARTH at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// // always explosion (for any enemy) +// RemapSlot(MID_BOSS_DEATH_EXPLOSION_BMP, BOSS_DEATH_SLOT, IMAGE_64x64); +// // Sprite sheet for enemy +// RemapSlot(MID_BOSS_EARTH_BROWN_BMP, BOSS_SLOT, IMAGE_128x128); +// // Sprite sheet for enemy projectiles +// RemapSlot(MID_BOSS_EARTH_PROJECTILE_BMP, BOSS_PROJECTILE_SLOT, IMAGE_32x32); +// +// if (!aSpawnObjects) { +// break; +// } +// GProcess::Spawn(this, op, ip, xx - 64, yy + 64, params, DIRECTION_DOWN, "ENEMY MID BOSS EARTH"); +// spawnedBoss = op; +// +// break; +// +// case ATTR_MID_BOSS_WATER: +//#ifdef DEBUGME +// printf("MID BOSS WATER at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// // always explosion (for any enemy) +// RemapSlot(MID_BOSS_DEATH_EXPLOSION_BMP, BOSS_DEATH_SLOT, IMAGE_64x64); +// // Sprite sheet for enemy +// RemapSlot(MID_BOSS_WATER_BMP, BOSS_SLOT, IMAGE_128x128); +// // Sprite sheet for enemy projectiles +// RemapSlot(MID_BOSS_WATER_PROJECTILE_BMP, BOSS_PROJECTILE_SLOT, IMAGE_32x32); +// +// if (!aSpawnObjects) { +// break; +// } +// GProcess::Spawn(this, op, ip, xx, yy + 64, params, DIRECTION_DOWN, "ENEMY MID BOSS WATER"); +// spawnedBoss = op; +// +// break; +// +// case ATTR_WIZARD_WATER: +//#ifdef DEBUGME +// printf("WATER WIZARD at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// // always explosion (for any enemy) +// RemapSlot(MID_BOSS_DEATH_EXPLOSION_BMP, BOSS_DEATH_SLOT, IMAGE_64x64); +// // Sprite sheet for enemy +// RemapSlot(WATER_WIZARD_BMP, BOSS_SLOT, IMAGE_64x64); +// // Sprite sheet for enemy projectiles +// RemapSlot(WATER_PROJECTILE_BMP, WATER_WIZARD_PROJECTILE_SLOT, IMAGE_32x32); +// RemapSlot(WATER_PILLAR_BMP, BOSS_PILLAR_SLOT, IMAGE_32x32); +// +// if (!aSpawnObjects) { +// break; +// } +// GProcess::Spawn(this, op, ip, xx, yy + 64, params, DIRECTION_DOWN, "ENEMY WATER WIZARD"); +// spawnedBoss = op; +// break; +// +// case ATTR_WIZARD_FIRE: +//#ifdef DEBUGME +// printf("FIRE WIZARD at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// // always explosion (for any enemy) +// RemapSlot(MID_BOSS_DEATH_EXPLOSION_BMP, BOSS_DEATH_SLOT, IMAGE_64x64); +// // Sprite sheet for enemy +// RemapSlot(FIRE_WIZARD_BMP, BOSS_SLOT, IMAGE_64x64); +// // Sprite sheet for enemy projectiles +// RemapSlot(FIRE_PROJECTILE_BMP, FIRE_WIZARD_PROJECTILE_SLOT, IMAGE_32x32); +// RemapSlot(FIRE_PILLAR_BMP, BOSS_PILLAR_SLOT, IMAGE_32x32); +// +// if (!aSpawnObjects) { +// break; +// } +// GProcess::Spawn(this, op, ip, xx, yy + 64, params, DIRECTION_DOWN, "ENEMY FIRE WIZARD"); +// spawnedBoss = op; +// +// break; +// +// case ATTR_WIZARD_ENERGY: +//#ifdef DEBUGME +// printf("ENERGY WIZARD at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// // always explosion (for any enemy) +// RemapSlot(MID_BOSS_DEATH_EXPLOSION_BMP, BOSS_DEATH_SLOT, IMAGE_64x64); +// // Sprite sheet for enemy +// RemapSlot(ENERGY_WIZARD_BMP, BOSS_SLOT, IMAGE_64x64); +// // Sprite sheet for enemy projectiles +// RemapSlot(ENERGY_PROJECTILE_BMP, ENERGY_WIZARD_PROJECTILE_SLOT, IMAGE_32x32); +// RemapSlot(ENERGY_PILLAR_BMP, BOSS_PILLAR_SLOT, IMAGE_32x32); +// +// if (!aSpawnObjects) { +// break; +// } +// GProcess::Spawn(this, op, ip, xx, yy + 64, params, DIRECTION_DOWN, "ENEMY ENERGY WIZARD"); +// spawnedBoss = op; +// +// break; +// +// case ATTR_WIZARD_EARTH: +//#ifndef DEBUG_FINALBOSS +//#ifdef DEBUGME +// printf("EARTH WIZARD at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// // always explosion (for any enemy) +// RemapSlot(MID_BOSS_DEATH_EXPLOSION_BMP, BOSS_DEATH_SLOT, IMAGE_64x64); +// // Sprite sheet for enemy +// RemapSlot(EARTH_WIZARD_BMP, BOSS_SLOT, IMAGE_64x64); +// // Sprite sheet for enemy projectiles +// RemapSlot(EARTH_PROJECTILE_BMP, EARTH_WIZARD_PROJECTILE_SLOT, IMAGE_32x32); +// RemapSlot(EARTH_PILLAR_BMP, BOSS_PILLAR_SLOT, IMAGE_32x32); +// +// if (!aSpawnObjects) { +// break; +// } +// GProcess::Spawn(this, op, ip, xx, yy + 64, params, DIRECTION_DOWN, "ENEMY EARTH WIZARD"); +// spawnedBoss = op; +// +// break; +//#endif +// +// case ATTR_FINAL_BOSS: +//#ifdef DEBUGME +// printf("FINAL BOSS at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// // always explosion (for any enemy) +// RemapSlot(MID_BOSS_DEATH_EXPLOSION_BMP, BOSS_DEATH_SLOT, IMAGE_64x64); +// // Sprite sheet for enemy +// RemapSlot(DRAGANOS_BMP, BOSS_SLOT, IMAGE_128x128); +// // Sprite sheets for enemy projectiles +// // Final Boss fires all the Wizard projectiles +// RemapSlot(ENERGY_PROJECTILE_BMP, ENERGY_FINAL_BOSS_PROJECTILE_SLOT, IMAGE_32x32); +// RemapSlot(ENERGY_PILLAR_BMP, ENERGY_FINAL_BOSS_PILLAR_SLOT, IMAGE_32x32); +// +// RemapSlot(EARTH_PROJECTILE_BMP, EARTH_FINAL_BOSS_PROJECTILE_SLOT, IMAGE_32x32); +// RemapSlot(EARTH_PILLAR_BMP, EARTH_FINAL_BOSS_PILLAR_SLOT, IMAGE_32x32); +// +// RemapSlot(WATER_PROJECTILE_BMP, WATER_FINAL_BOSS_PROJECTILE_SLOT, IMAGE_32x32); +// RemapSlot(WATER_PILLAR_BMP, WATER_FINAL_BOSS_PILLAR_SLOT, IMAGE_32x32); +// +// RemapSlot(FIRE_PROJECTILE_BMP, FIRE_FINAL_BOSS_PROJECTILE_SLOT, IMAGE_32x32); +// RemapSlot(FIRE_PILLAR_BMP, FIRE_FINAL_BOSS_PILLAR_SLOT, IMAGE_32x32); +// +// if (!aSpawnObjects) { +// break; +// } +// GProcess::Spawn(this, op, ip, xx, yy + 64, params, DIRECTION_DOWN, "FINAL BOSS"); +// spawnedBoss = op; +// +// break; +// +// // Spawn potions, heart +// case ATTR_SPAWN_SMALL_HEALTH: +//#ifdef DEBUGME +// printf("SMALL HEALTH at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GItemProcess::SpawnItem(this, ip, ITEM_RED_POTION1, xx, yy + 32); +// break; +// +// case ATTR_SPAWN_LARGE_HEALTH: +//#ifdef DEBUGME +// printf("LARGE HEALTH at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GItemProcess::SpawnItem(this, ip, ITEM_RED_POTION2, xx, yy + 32); +// break; +// +// case ATTR_SPAWN_SMALL_MANA: +//#ifdef DEBUGME +// printf("SMALL MANA at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GItemProcess::SpawnItem(this, ip, ITEM_BLUE_POTION1, xx, yy + 32); +// break; +// +// case ATTR_SPAWN_LARGE_MANA: +//#ifdef DEBUGME +// printf("LARGE MANA at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GItemProcess::SpawnItem(this, ip, ITEM_BLUE_POTION2, xx, yy + 32); +// break; +// +// case ATTR_SPAWN_HEART: +//#ifdef DEBUGME +// printf("HEART at %.2f,%.2f %d,%d\n", xx, yy, row, col); +//#endif +// GItemProcess::SpawnItem(this, ip, ITEM_HEART, xx, yy + 32); +// break; +// +// +// default: +// printf("======== > Invalid op code in Object Program: $%0x at col,row %d,%d\n", program[ip].mCode, col, row); +// break; +// } +// } +// if (!startedPlayer) { +// printf("NO PLAYER at %.2f,%.2f\n", 32., 64.); +// GPlayer::mProcess->StartLevel(mGamePlayfield, 32., 64. + 32); +// } +// +// PlayLevelMusic(mNextDungeon, spawnedBoss); +// +// +// mGamePlayfield->StartMosaicIn(); +} + +TBool GGameState::PlayMusicForCurrentLevel() { + return PlayLevelMusic(mDungeon, -1); +} + +TBool GGameState::PlayLevelMusic(TInt16 aNextDungeon, TInt16 aSpawnedBoss) { + + TUint16 song = EMPTYSONG_XM; + printf("aNextDungeon = %i\n", aNextDungeon); + // For levels -- bosses get their own treatment! +// if (aSpawnedBoss == -1) { +// if (aNextDungeon == 0) { +// song = OVERWORLD_XM; +// } +// else if (aNextDungeon == 1) { +// song = DUNGEON_HOME_XM; +// } +// else if (aNextDungeon >= 2 && aNextDungeon <= 4) { +// song = DUNGEON1_XM; +// } +// else if (aNextDungeon >= 13 && aNextDungeon <= 18) { +// song = DUNGEON4_XM; +// } +// else if (aNextDungeon >= 36 && aNextDungeon <= 40) { +// song = DUNGEON9_XM; +// } +// } +// else { +// if (aSpawnedBoss == ATTR_MID_BOSS_WATER || aSpawnedBoss == ATTR_MID_BOSS_ENERGY || aSpawnedBoss == ATTR_MID_BOSS_EARTH || aSpawnedBoss == ATTR_MID_BOSS_FIRE) { +// song = BOSS_1_XM; +// } +// else if (aSpawnedBoss == ATTR_WIZARD_ENERGY || aSpawnedBoss == ATTR_WIZARD_WATER || aSpawnedBoss == ATTR_WIZARD_EARTH || aSpawnedBoss == ATTR_WIZARD_FIRE) { +// song = BOSS_2_XM; +// } else { +// song = BOSS_3_XM; +// } +// } + + + //gSoundPlayer.PlayMusic(song); + + return ETrue; +} +/** + * modify BObjectProgram, like when a door or chest has opened. + * + * aCode is the code to change the program step to, OR ATTR_KEEP to leave the code in the BObjectProgram unchanged. + * aAttr is the attribute to change the program step to, OR ATTR_KEEP + */ +void GGameState::EndProgram(TInt aIp, TUint16 aCode, TUint16 aAttr) { + BObjectProgram *program = mGamePlayfield->mObjectProgram, + *step = &program[aIp]; + + TUint32 code = aCode, + attr = aAttr, + sCode = step->mCode; + + if (aCode == ATTR_KEEP) { + if (aAttr == ATTR_KEEP) { + // keep both? Nothing to do! + return; + } + step->mCode = LOWORD(sCode) | (attr << 16); + } + else if (aAttr == ATTR_KEEP) { + step->mCode = (sCode & 0xffff0000) | (attr << 16); + } + else { + TUint32 new_code = code | (attr << 16); + step->mCode = new_code; + } + printf("EndProgram %p (%08x -> %08x)\n", program, sCode, step->mCode); +} + +/******************************************************************************* + ******************************************************************************* + *******************************************************************************/ + +void GGameState::GameOver() { + mGameOver = new GGameOver(this); + //gSoundPlayer.PlayMusic(GAMEOVER_XM); + //gSoundPlayer.TriggerSfx(SFX_PLAYER_DEATH_WAV); + gControls.Reset(); + GPlayer::mGameOver = ETrue; +} + +/******************************************************************************* + ******************************************************************************* + *******************************************************************************/ + +void GGameState::InitRemapSlots() { + for (TInt i = 2; i < SLOT_MAX; i++) { + if (i == TILESET_SLOT) { + // do not release TILESET + continue; + } + if (mSlotRemapState[i]) { + if (gResourceManager.GetBitmap(i)) { + printf("Releasing slot %d\n", i); + gResourceManager.ReleaseBitmapSlot(i); + } + } + mSlotRemapState[i] = EFalse; + } +} + +// Load aBMP, and remap it to playfield's tilemap palette +void GGameState::RemapSlot(TUint16 aBMP, TUint16 aSlot, TInt16 aImageSize) { + if (aSlot == TILESET_SLOT) { + Panic("Attempt to RemapSlot(TILESET_SLOT)\n"); + } + if (mSlotRemapState[aSlot]) { + return; + } + + gResourceManager.LoadBitmap(aBMP, aSlot, aImageSize); + + BBitmap *screen = mGamePlayfield->GetTilesBitmap(); + BBitmap *bm = gResourceManager.GetBitmap(aSlot); + if (!mSlotRemapState[aSlot]) { + bm->Remap(screen); + mSlotRemapState[aSlot] = ETrue; +#ifdef DEBUGME + printf("Remapped bitmap %d to slot %d, screen colors used %d\n", aBMP, aSlot, screen->CountUsedColors()); +#endif + } + gDisplay.SetPalette(screen->GetPalette(), 0, screen->CountUsedColors()); +} + +TBool GGameState::SaveState() { + printf("\n======= BEGIN %s =======\n", __FUNCTION__); + printf("\n-------- END %s--------\n", __FUNCTION__); + + return ETrue; +} + +TBool GGameState::LoadState(const char *aGameName) { + return ETrue; +} diff --git a/Evade2/old/GameState/GGameState.h b/Evade2/old/GameState/GGameState.h new file mode 100644 index 0000000..3d4cd00 --- /dev/null +++ b/Evade2/old/GameState/GGameState.h @@ -0,0 +1,128 @@ +#ifndef MODITE_GGAMESTATE_H +#define MODITE_GGAMESTATE_H + +#define TILES_WIDE 10 +#define TILES_HIGH 7 + +#define ENABLE_REMAP_SLOTS +//#undef ENABLE_REMAP_SLOTS + +//#include "Game.h" +#include "GResources.h" +#include "GGamePlayfield.h" + +class GAnchorSprite; +class GProcess; +class GGamePlayfield; + +// Message Types +static TUint16 MESSAGE_FLOOR_SWITCH_DOWN = 0; +static TUint16 MESSAGE_FLOOR_SWITCH_UP = MESSAGE_FLOOR_SWITCH_DOWN + 1; + +const TInt16 OVERWORLD_DUNGEON = 0; + +const TInt TARGET_PAN_DURATION = 0.8 * FRAMES_PER_SECOND; + +//#include "GPlayerProcess.h" + +struct TDungeonInfo { + const char *name; + struct { + TInt16 objectsId; + TInt16 map[11]; + } mInfo; +}; +extern TDungeonInfo gDungeonDefs[]; +extern const TInt NUM_DUNGEONS; + +class GGameOver; + +class GGameState : public BGameEngine { +public: + // game engine + GGameState(); + + // game engine loads saved game + EXPLICIT GGameState(const char *aName); + + ~GGameState() OVERRIDE; + + void Init(); + +public: + void GameLoop() OVERRIDE; + + void PreRender() OVERRIDE; + + void PositionCamera() OVERRIDE; + + void PostRender() OVERRIDE; + + void NextLevel(const TInt16 aDungeon, const TInt16 aLevel); + + void LoadLevel(const char *aName, const TInt16 aLevel, TUint16 aTileMapId, TBool aNewLevel = ETrue); + + void SetPlayfieldXYFromPlayer(TFloat aPlayerX, TFloat aPlayerY); + TBool PlayMusicForCurrentLevel(); + TBool SaveState(); + + TBool LoadState(const char *aGameName); + +public: + GProcess *AddProcess(GProcess *p); + + // call this to resume game after death + void TryAgain(TBool aExitDungeon); + + // call this when player is dead + void GameOver(); + + // store code and attr into ObjectProgram at aIp +// void EndProgram(TInt aIp, TUint16 aCode = ATTR_GONE, TUint16 aAttr = 0); + + TUint16 MapWidth(); + + TUint16 MapHeight(); + + TBool IsBossRoom(); + +public: + GGamePlayfield *mGamePlayfield, *mNextGamePlayfield; + +public: + TBool IsGameOver() { return mGameOver != ENull; } + TInt16 Dungeon() { return mDungeon; } + TInt16 IsCurrentLevel(TUint16 aDungeon, TInt16 aLevel) { return mNextDungeon == aDungeon && mLevel == aLevel; } + TInt16 LastOverworldLevel() { return mLastOverworldLevel; } + TBool PlayLevelMusic(TInt16 aNextDungeon, TInt16 aSpawnedBoss); +protected: + TInt mTimer, mCameraTimer; + char mText[128]; + char mName[128]; + TInt16 mNextLevel, mLevel, mNextObjectsId, mLastOverworldLevel; + TUint16 mDungeon, mNextDungeon, mNextTileMapId, mTileMapId; + TUint16 mPlayerToLoad; + GGameOver *mGameOver; +#ifdef ENABLE_REMAP_SLOTS +protected: + // If the value for the slot is ETrue, then the slot + // has already been remapped. We don't want to remap twice or the color range + // ends up in the wrong place. + TBool mSlotRemapState[SLOT_MAX]; +protected: + /** + * Load bmp and remap it to the specified color range, and set the palette colors in gDisplay + * + * @param aBMP + * @param aSlot + * @param aPalette + * @param aColors + */ + void RemapSlot(TUint16 aBMP, TUint16 aSlot, TInt16 aImageSize = IMAGE_64x64); + + void InitRemapSlots(); +#endif + +}; + +#endif //MODITE_GGAMESTATE_H diff --git a/Evade2/src/GameState/GHud.cpp b/Evade2/old/GameState/GHud.cpp similarity index 100% rename from Evade2/src/GameState/GHud.cpp rename to Evade2/old/GameState/GHud.cpp diff --git a/Evade2/src/GameState/GHud.h b/Evade2/old/GameState/GHud.h similarity index 100% rename from Evade2/src/GameState/GHud.h rename to Evade2/old/GameState/GHud.h diff --git a/Evade2/old/GameState/GProcess.cpp b/Evade2/old/GameState/GProcess.cpp new file mode 100644 index 0000000..4544e9e --- /dev/null +++ b/Evade2/old/GameState/GProcess.cpp @@ -0,0 +1,6 @@ +#include "GProcess.h" + +// DEBUG_FINALBOSS causes wizard span to be final boss spawn instead, to debug the final boss +#define DEBUG_FINALBOSS +#undef DEBUG_FINALBOSS + diff --git a/Evade2/src/GameState/GProcess.h b/Evade2/old/GameState/GProcess.h similarity index 100% rename from Evade2/src/GameState/GProcess.h rename to Evade2/old/GameState/GProcess.h diff --git a/Evade2/src/GameState/enemies/GBossProcess.cpp b/Evade2/old/GameState/enemies/GBossProcess.cpp similarity index 100% rename from Evade2/src/GameState/enemies/GBossProcess.cpp rename to Evade2/old/GameState/enemies/GBossProcess.cpp diff --git a/Evade2/src/GameState/enemies/GBossProcess.h b/Evade2/old/GameState/enemies/GBossProcess.h similarity index 100% rename from Evade2/src/GameState/enemies/GBossProcess.h rename to Evade2/old/GameState/enemies/GBossProcess.h diff --git a/Evade2/src/GameState/enemies/GBossSprite.cpp b/Evade2/old/GameState/enemies/GBossSprite.cpp similarity index 99% rename from Evade2/src/GameState/enemies/GBossSprite.cpp rename to Evade2/old/GameState/enemies/GBossSprite.cpp index 90ba6df..30c117f 100644 --- a/Evade2/src/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 "Camera.h" +#include "GCamera.h" static const TFloat z_dist = 256; static const TFloat frames = 32; diff --git a/Evade2/src/GameState/enemies/GBossSprite.h b/Evade2/old/GameState/enemies/GBossSprite.h similarity index 100% rename from Evade2/src/GameState/enemies/GBossSprite.h rename to Evade2/old/GameState/enemies/GBossSprite.h diff --git a/Evade2/src/GameState/enemies/GEnemyProcess.cpp b/Evade2/old/GameState/enemies/GEnemyProcess.cpp similarity index 100% rename from Evade2/src/GameState/enemies/GEnemyProcess.cpp rename to Evade2/old/GameState/enemies/GEnemyProcess.cpp diff --git a/Evade2/src/GameState/enemies/GEnemyProcess.h b/Evade2/old/GameState/enemies/GEnemyProcess.h similarity index 100% rename from Evade2/src/GameState/enemies/GEnemyProcess.h rename to Evade2/old/GameState/enemies/GEnemyProcess.h diff --git a/Evade2/src/GameState/enemies/GEnemySprite.cpp b/Evade2/old/GameState/enemies/GEnemySprite.cpp similarity index 99% rename from Evade2/src/GameState/enemies/GEnemySprite.cpp rename to Evade2/old/GameState/enemies/GEnemySprite.cpp index eb6101c..19c91c1 100644 --- a/Evade2/src/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 "Camera.h" +#include "GCamera.h" const TInt8 *enemy_graphic(TInt16 n) { diff --git a/Evade2/src/GameState/enemies/GEnemySprite.h b/Evade2/old/GameState/enemies/GEnemySprite.h similarity index 100% rename from Evade2/src/GameState/enemies/GEnemySprite.h rename to Evade2/old/GameState/enemies/GEnemySprite.h diff --git a/Evade2/src/GameState/enemies/GGruntProcess.cpp b/Evade2/old/GameState/enemies/GGruntProcess.cpp similarity index 100% rename from Evade2/src/GameState/enemies/GGruntProcess.cpp rename to Evade2/old/GameState/enemies/GGruntProcess.cpp diff --git a/Evade2/src/GameState/enemies/GGruntProcess.h b/Evade2/old/GameState/enemies/GGruntProcess.h similarity index 100% rename from Evade2/src/GameState/enemies/GGruntProcess.h rename to Evade2/old/GameState/enemies/GGruntProcess.h diff --git a/Evade2/src/GameState/object_layer_attributes.h b/Evade2/old/GameState/object_layer_attributes.h similarity index 100% rename from Evade2/src/GameState/object_layer_attributes.h rename to Evade2/old/GameState/object_layer_attributes.h diff --git a/Evade2/src/GameState/player/GGameOver.cpp b/Evade2/old/GameState/player/GGameOver.cpp similarity index 100% rename from Evade2/src/GameState/player/GGameOver.cpp rename to Evade2/old/GameState/player/GGameOver.cpp diff --git a/Evade2/src/GameState/player/GGameOver.h b/Evade2/old/GameState/player/GGameOver.h similarity index 100% rename from Evade2/src/GameState/player/GGameOver.h rename to Evade2/old/GameState/player/GGameOver.h diff --git a/Evade2/src/GameState/player/GPlayerBulletProcess.cpp b/Evade2/old/GameState/player/GPlayerBulletProcess.cpp similarity index 100% rename from Evade2/src/GameState/player/GPlayerBulletProcess.cpp rename to Evade2/old/GameState/player/GPlayerBulletProcess.cpp diff --git a/Evade2/src/GameState/player/GPlayerBulletProcess.h b/Evade2/old/GameState/player/GPlayerBulletProcess.h similarity index 100% rename from Evade2/src/GameState/player/GPlayerBulletProcess.h rename to Evade2/old/GameState/player/GPlayerBulletProcess.h diff --git a/Evade2/src/GameState/player/GPlayerProcess.cpp b/Evade2/old/GameState/player/GPlayerProcess.cpp similarity index 100% rename from Evade2/src/GameState/player/GPlayerProcess.cpp rename to Evade2/old/GameState/player/GPlayerProcess.cpp diff --git a/Evade2/src/GameState/player/GPlayerProcess.h b/Evade2/old/GameState/player/GPlayerProcess.h similarity index 100% rename from Evade2/src/GameState/player/GPlayerProcess.h rename to Evade2/old/GameState/player/GPlayerProcess.h diff --git a/Evade2/src/GameState/player/GPlayerSprite.cpp b/Evade2/old/GameState/player/GPlayerSprite.cpp similarity index 100% rename from Evade2/src/GameState/player/GPlayerSprite.cpp rename to Evade2/old/GameState/player/GPlayerSprite.cpp diff --git a/Evade2/src/GameState/player/GPlayerSprite.h b/Evade2/old/GameState/player/GPlayerSprite.h similarity index 96% rename from Evade2/src/GameState/player/GPlayerSprite.h rename to Evade2/old/GameState/player/GPlayerSprite.h index adb645e..ffb40b4 100644 --- a/Evade2/src/GameState/player/GPlayerSprite.h +++ b/Evade2/old/GameState/player/GPlayerSprite.h @@ -1,6 +1,7 @@ #ifndef MODITE_GPLAYERSPRITE_H #define MODITE_GPLAYERSPRITE_H +#if 0 #include "GAnchorSprite.h" class GPlayerSprite : public GAnchorSprite { @@ -13,5 +14,6 @@ class GPlayerSprite : public GAnchorSprite { public: TFloat mSwordCharge; }; +#endif #endif //MODITE_GPLAYERSPRITE_H diff --git a/Evade2/src/GameState/status/GStartLevelProcess.cpp b/Evade2/old/GameState/status/GStartLevelProcess.cpp similarity index 100% rename from Evade2/src/GameState/status/GStartLevelProcess.cpp rename to Evade2/old/GameState/status/GStartLevelProcess.cpp diff --git a/Evade2/src/GameState/status/GStartLevelProcess.h b/Evade2/old/GameState/status/GStartLevelProcess.h similarity index 100% rename from Evade2/src/GameState/status/GStartLevelProcess.h rename to Evade2/old/GameState/status/GStartLevelProcess.h diff --git a/Evade2/src/GameState/status/GStatProcess.cpp b/Evade2/old/GameState/status/GStatProcess.cpp similarity index 100% rename from Evade2/src/GameState/status/GStatProcess.cpp rename to Evade2/old/GameState/status/GStatProcess.cpp diff --git a/Evade2/src/GameState/status/GStatProcess.h b/Evade2/old/GameState/status/GStatProcess.h similarity index 100% rename from Evade2/src/GameState/status/GStatProcess.h rename to Evade2/old/GameState/status/GStatProcess.h diff --git a/Evade2/src/GameState/status/GStatSprite.cpp b/Evade2/old/GameState/status/GStatSprite.cpp similarity index 100% rename from Evade2/src/GameState/status/GStatSprite.cpp rename to Evade2/old/GameState/status/GStatSprite.cpp diff --git a/Evade2/src/GameState/status/GStatSprite.h b/Evade2/old/GameState/status/GStatSprite.h similarity index 100% rename from Evade2/src/GameState/status/GStatSprite.h rename to Evade2/old/GameState/status/GStatSprite.h diff --git a/Evade2/src/MainMenuState/GMainMenuContainer.cpp b/Evade2/old/MainMenuState/GMainMenuContainer.cpp similarity index 100% rename from Evade2/src/MainMenuState/GMainMenuContainer.cpp rename to Evade2/old/MainMenuState/GMainMenuContainer.cpp diff --git a/Evade2/src/MainMenuState/GMainMenuContainer.h b/Evade2/old/MainMenuState/GMainMenuContainer.h similarity index 100% rename from Evade2/src/MainMenuState/GMainMenuContainer.h rename to Evade2/old/MainMenuState/GMainMenuContainer.h diff --git a/Evade2/src/MainMenuState/GMainMenuPlayfield.cpp b/Evade2/old/MainMenuState/GMainMenuPlayfield.cpp similarity index 100% rename from Evade2/src/MainMenuState/GMainMenuPlayfield.cpp rename to Evade2/old/MainMenuState/GMainMenuPlayfield.cpp diff --git a/Evade2/src/MainMenuState/GMainMenuPlayfield.h b/Evade2/old/MainMenuState/GMainMenuPlayfield.h similarity index 100% rename from Evade2/src/MainMenuState/GMainMenuPlayfield.h rename to Evade2/old/MainMenuState/GMainMenuPlayfield.h diff --git a/Evade2/src/MainMenuState/GMainMenuProcess.cpp b/Evade2/old/MainMenuState/GMainMenuProcess.cpp similarity index 100% rename from Evade2/src/MainMenuState/GMainMenuProcess.cpp rename to Evade2/old/MainMenuState/GMainMenuProcess.cpp diff --git a/Evade2/src/MainMenuState/GMainMenuProcess.h b/Evade2/old/MainMenuState/GMainMenuProcess.h similarity index 100% rename from Evade2/src/MainMenuState/GMainMenuProcess.h rename to Evade2/old/MainMenuState/GMainMenuProcess.h diff --git a/Evade2/src/MainMenuState/GMainMenuState.cpp b/Evade2/old/MainMenuState/GMainMenuState.cpp similarity index 100% rename from Evade2/src/MainMenuState/GMainMenuState.cpp rename to Evade2/old/MainMenuState/GMainMenuState.cpp diff --git a/Evade2/src/MainMenuState/GMainMenuState.h b/Evade2/old/MainMenuState/GMainMenuState.h similarity index 100% rename from Evade2/src/MainMenuState/GMainMenuState.h rename to Evade2/old/MainMenuState/GMainMenuState.h diff --git a/Evade2/src/MainMenuState/GStartWidget.h b/Evade2/old/MainMenuState/GStartWidget.h similarity index 100% rename from Evade2/src/MainMenuState/GStartWidget.h rename to Evade2/old/MainMenuState/GStartWidget.h diff --git a/Evade2/src/MainOptionsState/GExitWidget.h b/Evade2/old/MainOptionsState/GExitWidget.h similarity index 100% rename from Evade2/src/MainOptionsState/GExitWidget.h rename to Evade2/old/MainOptionsState/GExitWidget.h diff --git a/Evade2/src/MainOptionsState/GMainOptionsState.cpp b/Evade2/old/MainOptionsState/GMainOptionsState.cpp similarity index 100% rename from Evade2/src/MainOptionsState/GMainOptionsState.cpp rename to Evade2/old/MainOptionsState/GMainOptionsState.cpp diff --git a/Evade2/src/MainOptionsState/GMainOptionsState.h b/Evade2/old/MainOptionsState/GMainOptionsState.h similarity index 100% rename from Evade2/src/MainOptionsState/GMainOptionsState.h rename to Evade2/old/MainOptionsState/GMainOptionsState.h diff --git a/Evade2/src/MainOptionsState/GMusicWidget.h b/Evade2/old/MainOptionsState/GMusicWidget.h similarity index 100% rename from Evade2/src/MainOptionsState/GMusicWidget.h rename to Evade2/old/MainOptionsState/GMusicWidget.h diff --git a/Evade2/src/MainOptionsState/GResetOptionsState.cpp b/Evade2/old/MainOptionsState/GResetOptionsState.cpp similarity index 100% rename from Evade2/src/MainOptionsState/GResetOptionsState.cpp rename to Evade2/old/MainOptionsState/GResetOptionsState.cpp diff --git a/Evade2/src/MainOptionsState/GResetOptionsState.h b/Evade2/old/MainOptionsState/GResetOptionsState.h similarity index 100% rename from Evade2/src/MainOptionsState/GResetOptionsState.h rename to Evade2/old/MainOptionsState/GResetOptionsState.h diff --git a/Evade2/src/MainOptionsState/GResetWidget.h b/Evade2/old/MainOptionsState/GResetWidget.h similarity index 100% rename from Evade2/src/MainOptionsState/GResetWidget.h rename to Evade2/old/MainOptionsState/GResetWidget.h diff --git a/Evade2/src/MainOptionsState/GSfxWidget.h b/Evade2/old/MainOptionsState/GSfxWidget.h similarity index 100% rename from Evade2/src/MainOptionsState/GSfxWidget.h rename to Evade2/old/MainOptionsState/GSfxWidget.h diff --git a/Evade2/src/MainOptionsState/GSoundSliderWidget.h b/Evade2/old/MainOptionsState/GSoundSliderWidget.h similarity index 100% rename from Evade2/src/MainOptionsState/GSoundSliderWidget.h rename to Evade2/old/MainOptionsState/GSoundSliderWidget.h diff --git a/Evade2/src/ResetState/GCancelResetWidget.cpp b/Evade2/old/ResetState/GCancelResetWidget.cpp similarity index 100% rename from Evade2/src/ResetState/GCancelResetWidget.cpp rename to Evade2/old/ResetState/GCancelResetWidget.cpp diff --git a/Evade2/src/ResetState/GCancelResetWidget.h b/Evade2/old/ResetState/GCancelResetWidget.h similarity index 100% rename from Evade2/src/ResetState/GCancelResetWidget.h rename to Evade2/old/ResetState/GCancelResetWidget.h diff --git a/Evade2/src/ResetState/GResetAllWidget.cpp b/Evade2/old/ResetState/GResetAllWidget.cpp similarity index 100% rename from Evade2/src/ResetState/GResetAllWidget.cpp rename to Evade2/old/ResetState/GResetAllWidget.cpp diff --git a/Evade2/src/ResetState/GResetAllWidget.h b/Evade2/old/ResetState/GResetAllWidget.h similarity index 100% rename from Evade2/src/ResetState/GResetAllWidget.h rename to Evade2/old/ResetState/GResetAllWidget.h diff --git a/Evade2/src/ResetState/GResetOptionsWidget.cpp b/Evade2/old/ResetState/GResetOptionsWidget.cpp similarity index 100% rename from Evade2/src/ResetState/GResetOptionsWidget.cpp rename to Evade2/old/ResetState/GResetOptionsWidget.cpp diff --git a/Evade2/src/ResetState/GResetOptionsWidget.h b/Evade2/old/ResetState/GResetOptionsWidget.h similarity index 100% rename from Evade2/src/ResetState/GResetOptionsWidget.h rename to Evade2/old/ResetState/GResetOptionsWidget.h diff --git a/Evade2/src/SplashState/GSplashPlayfield.cpp b/Evade2/old/SplashState/GSplashPlayfield.cpp similarity index 100% rename from Evade2/src/SplashState/GSplashPlayfield.cpp rename to Evade2/old/SplashState/GSplashPlayfield.cpp diff --git a/Evade2/src/SplashState/GSplashPlayfield.h b/Evade2/old/SplashState/GSplashPlayfield.h similarity index 100% rename from Evade2/src/SplashState/GSplashPlayfield.h rename to Evade2/old/SplashState/GSplashPlayfield.h diff --git a/Evade2/src/SplashState/GSplashProcess.cpp b/Evade2/old/SplashState/GSplashProcess.cpp similarity index 100% rename from Evade2/src/SplashState/GSplashProcess.cpp rename to Evade2/old/SplashState/GSplashProcess.cpp diff --git a/Evade2/src/SplashState/GSplashProcess.h b/Evade2/old/SplashState/GSplashProcess.h similarity index 100% rename from Evade2/src/SplashState/GSplashProcess.h rename to Evade2/old/SplashState/GSplashProcess.h diff --git a/Evade2/src/SplashState/GSplashState.cpp b/Evade2/old/SplashState/GSplashState.cpp similarity index 100% rename from Evade2/src/SplashState/GSplashState.cpp rename to Evade2/old/SplashState/GSplashState.cpp diff --git a/Evade2/src/SplashState/GSplashState.h b/Evade2/old/SplashState/GSplashState.h similarity index 100% rename from Evade2/src/SplashState/GSplashState.h rename to Evade2/old/SplashState/GSplashState.h diff --git a/Evade2/src/SplashState/Splash.cpp b/Evade2/old/SplashState/Splash.cpp similarity index 100% rename from Evade2/src/SplashState/Splash.cpp rename to Evade2/old/SplashState/Splash.cpp diff --git a/Evade2/src/SplashState/Splash.h b/Evade2/old/SplashState/Splash.h similarity index 100% rename from Evade2/src/SplashState/Splash.h rename to Evade2/old/SplashState/Splash.h diff --git a/Evade2/src/VictoryState/GVictoryCreditsProcess.h b/Evade2/old/VictoryState/GVictoryCreditsProcess.h similarity index 100% rename from Evade2/src/VictoryState/GVictoryCreditsProcess.h rename to Evade2/old/VictoryState/GVictoryCreditsProcess.h diff --git a/Evade2/src/VictoryState/GVictoryPlayfield.cpp b/Evade2/old/VictoryState/GVictoryPlayfield.cpp similarity index 100% rename from Evade2/src/VictoryState/GVictoryPlayfield.cpp rename to Evade2/old/VictoryState/GVictoryPlayfield.cpp diff --git a/Evade2/src/VictoryState/GVictoryPlayfield.h b/Evade2/old/VictoryState/GVictoryPlayfield.h similarity index 100% rename from Evade2/src/VictoryState/GVictoryPlayfield.h rename to Evade2/old/VictoryState/GVictoryPlayfield.h diff --git a/Evade2/src/VictoryState/GVictoryState.cpp b/Evade2/old/VictoryState/GVictoryState.cpp similarity index 100% rename from Evade2/src/VictoryState/GVictoryState.cpp rename to Evade2/old/VictoryState/GVictoryState.cpp diff --git a/Evade2/src/VictoryState/GVictoryState.h b/Evade2/old/VictoryState/GVictoryState.h similarity index 100% rename from Evade2/src/VictoryState/GVictoryState.h rename to Evade2/old/VictoryState/GVictoryState.h diff --git a/Evade2/src/common/GButtonWidget.cpp b/Evade2/old/common/GButtonWidget.cpp similarity index 100% rename from Evade2/src/common/GButtonWidget.cpp rename to Evade2/old/common/GButtonWidget.cpp diff --git a/Evade2/src/common/GButtonWidget.h b/Evade2/old/common/GButtonWidget.h similarity index 100% rename from Evade2/src/common/GButtonWidget.h rename to Evade2/old/common/GButtonWidget.h diff --git a/Evade2/src/common/GDialogWidget.cpp b/Evade2/old/common/GDialogWidget.cpp similarity index 100% rename from Evade2/src/common/GDialogWidget.cpp rename to Evade2/old/common/GDialogWidget.cpp diff --git a/Evade2/src/common/GDialogWidget.h b/Evade2/old/common/GDialogWidget.h similarity index 100% rename from Evade2/src/common/GDialogWidget.h rename to Evade2/old/common/GDialogWidget.h diff --git a/Evade2/src/Camera.h b/Evade2/src/Camera.h deleted file mode 100644 index 7e190f6..0000000 --- a/Evade2/src/Camera.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef CAMERA_H -#define CAMERA_H - -#include "Game.h" -#include "GVectorSprite.h" - - -class Camera { -public: - static TFloat mX, mY, mZ; - static TFloat mVX, mVY, mVZ; - -public: - static void Move() { - Camera::mX += Camera::mVX; - Camera::mY += Camera::mVY; - Camera::mZ += Camera::mVZ; - } - - static TBool CollidesWith(GVectorSprite *aVSprite) { - // If enemy bullet collides with player - if (abs(aVSprite->mZ - Camera::mZ) < abs(aVSprite->mVZ) && abs(aVSprite->mX - Camera::mX) < 64 && abs(aVSprite->mY - Camera::mY) < 64) { - return ETrue; - } - return EFalse; - } -}; - - - -#endif diff --git a/Evade2/src/Camera.cpp b/Evade2/src/GCamera.cpp similarity index 83% rename from Evade2/src/Camera.cpp rename to Evade2/src/GCamera.cpp index 9c3deb8..e01328b 100644 --- a/Evade2/src/Camera.cpp +++ b/Evade2/src/GCamera.cpp @@ -1,16 +1,16 @@ -#include "Camera.h" +#include "GCamera.h" // // // -TFloat Camera::mX = 0; -TFloat Camera::mY = 0; -TFloat Camera::mZ = 0; +TFloat GCamera::mX = 0; +TFloat GCamera::mY = 0; +TFloat GCamera::mZ = 0; -TFloat Camera::mVX = 0; -TFloat Camera::mVY = 0; -TFloat Camera::mVZ = CAMERA_VZ; +TFloat GCamera::mVX = 0; +TFloat GCamera::mVY = 0; +TFloat GCamera::mVZ = CAMERA_VZ; // //Camera::Camera() { diff --git a/Evade2/src/GCamera.h b/Evade2/src/GCamera.h new file mode 100644 index 0000000..a9a8565 --- /dev/null +++ b/Evade2/src/GCamera.h @@ -0,0 +1,30 @@ +#ifndef GCAMERA_H +#define GCAMERA_H + +#include "Game.h" +#include + +class GCamera { +public: + static TFloat mX, mY, mZ; + static TFloat mVX, mVY, mVZ; + +public: + static void Move() { + GCamera::mX += GCamera::mVX; + GCamera::mY += GCamera::mVY; + GCamera::mZ += GCamera::mVZ; + } + + static TBool CollidesWith(GVectorSprite *aVSprite) { + // If enemy bullet collides with player + if (abs(aVSprite->mZ - GCamera::mZ) < abs(aVSprite->mVZ) && abs(aVSprite->mX - GCamera::mX) < 64 && abs(aVSprite->mY - GCamera::mY) < 64) { + return ETrue; + } + return EFalse; + } +}; + + + +#endif diff --git a/Evade2/src/GGame.cpp b/Evade2/src/GGame.cpp index edfe308..4f27f0c 100644 --- a/Evade2/src/GGame.cpp +++ b/Evade2/src/GGame.cpp @@ -1,8 +1,10 @@ #include "Game.h" #include "GGame.h" -#include "GPlayer.h" -#include "Camera.h" +//#include "GPlayer.h" +#include "GCamera.h" #include "GResources.h" +#include "./GameState/GGameState.h" + static TUint32 start; BFont *gFont8x8, *gFont16x16; @@ -21,6 +23,9 @@ TBool GGame::mDebug = EFalse; *******************************************************************************/ GGame::GGame() { + printf("Construct GGame\n"); + gGameEngine = new GGameState(); +#if 0 mLocalData = ENull; mLocalDataSize = 0; @@ -74,6 +79,7 @@ GGame::GGame() { mShmoo.Set(0, 0, 0); mStarField = new GStarFieldProcess(); +#endif } GGame::~GGame() { @@ -82,7 +88,7 @@ GGame::~GGame() { #endif delete gGameEngine; delete gViewPort; - delete mGameMenu; +// delete mGameMenu; } /******************************************************************************* @@ -90,15 +96,17 @@ 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; @@ -115,6 +123,9 @@ void GGame::ToggleInGameMenu() { gControls.dKeys = 0; } +#endif + +#if 0 void GGame::ToggleDebugMenu() { if (GPlayer::mGameOver || mGameMenu || mInventory) { return; @@ -130,11 +141,13 @@ void GGame::ToggleDebugMenu() { } gControls.dKeys = 0; } +#endif /******************************************************************************* ******************************************************************************* *******************************************************************************/ +#if 0 void GGame::ToggleInventory() { // if (GPlayer::mGameOver || mGameMenu) { // return; @@ -151,11 +164,13 @@ void GGame::ToggleInventory() { // } // gControls.dKeys = 0; } +#endif /******************************************************************************* ******************************************************************************* *******************************************************************************/ +#if 0 void GGame::SetState(TInt aNewState, TAny *aLocalData, TUint32 aSize) { mNextState = aNewState; if (aLocalData) { @@ -170,12 +185,14 @@ void GGame::SetState(TInt aNewState, TAny *aLocalData, TUint32 aSize) { mLocalDataSize = 0; } } +#endif TInt GGame::GetState() { return mState; } void GGame::StartGame(char *aGameName) { +#if 0 #ifdef DEBUG_MODE printf("START GAME (%s)\n", aGameName); #endif @@ -184,6 +201,7 @@ void GGame::StartGame(char *aGameName) { aGameName, strlen(aGameName)+1 ); +#endif } TBool GGame::IsGameState() { @@ -194,8 +212,9 @@ TBool GGame::IsGameState() { if (!state) { return EFalse; } - GGameState *s = (GGameState *)gGameEngine; - return !s->IsGameOver(); + return ETrue; +// GGameState *s = (GGameState *)gGameEngine; +// return !s->IsGameOver(); } /******************************************************************************* @@ -203,6 +222,21 @@ TBool GGame::IsGameState() { *******************************************************************************/ void GGame::Run() { + printf("run\n"); + 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(); + gGameEngine->GameLoop(); + gDisplay.Update(); + if (gControls.WasPressed(BUTTONQ)) { + done = ETrue; + } + } + +#if 0 #ifdef ENABLE_OPTIONS TBool muted = gOptions->muted; #endif @@ -337,4 +371,5 @@ void GGame::Run() { } #endif } +#endif } diff --git a/Evade2/src/GGame.h b/Evade2/src/GGame.h index 188154a..6031993 100644 --- a/Evade2/src/GGame.h +++ b/Evade2/src/GGame.h @@ -3,7 +3,7 @@ //#include "Game.h" #include -#include "GStarFieldProcess.h" +//#include "GStarFieldProcess.h" class BGameEngine; class BFont; @@ -34,14 +34,14 @@ class GGame : public BApplication { void Run(); public: - void SetState(TInt aNewState, TAny *aLocalData = ENull, TUint32 aSize = 0); +// void SetState(TInt aNewState, TAny *aLocalData = ENull, TUint32 aSize = 0); void StartGame(char *aGameName); TInt GetState(); - void ToggleInGameMenu(); - void ToggleInventory(); - void ToggleDebugMenu(); +// void ToggleInGameMenu(); +// void ToggleInventory(); +// void ToggleDebugMenu(); TBool IsGameState(); BGameEngine *CurrentState(); TUint16 mWave; @@ -51,14 +51,14 @@ class GGame : public BApplication { protected: TInt mState; TInt mNextState; - TAny *mLocalData; // arbitrary local data that is passed to SetState. - TUint32 mLocalDataSize; +// TAny *mLocalData; // arbitrary local data that is passed to SetState. +// TUint32 mLocalDataSize; BGameEngine *mGameMenu; - BGameEngine *mInventory; - BGameEngine *mDebugMenu; +// BGameEngine *mInventory; +// BGameEngine *mDebugMenu; TRGB mShmoo; - GStarFieldProcess *mStarField; +// GStarFieldProcess *mStarField; }; extern GGame *gGame; diff --git a/Evade2/src/GResources.h b/Evade2/src/GResources.h index d9bda30..fbe9007 100644 --- a/Evade2/src/GResources.h +++ b/Evade2/src/GResources.h @@ -7,91 +7,9 @@ // Events const TUint16 EVENT_SPELL_PROCESS_EXIT = 1; -// Sprite priorities -// higher numbers mean deeper into the screen (highest values drawn first) -const TInt CHEST_PRIORITY = 2; -const TInt POT_PRIORITY = 2; -const TInt DOOR_PRIORITY = 2; -const TInt FLOOR_SWITCH_PRIORITY = 2; -const TInt LEVER_PRIORITY = 2; -const TInt SPIKES_PRIORITY = 2; -const TInt STAIRS_PRIORITY = 2; -const TInt ITEM_PRIORITY = 1; -const TInt ENEMY_PRIORITY = 0; -const TInt ENEMY_SPELL_PRIORITY = -1; -const TInt ENEMY_DEATH_PRIORITY = -1; -const TInt PLAYER_PRIORITY = -10; -const TInt PLAYER_HEAL_PRIORITY = -11; -const TInt PLAYER_SPELL_PRIORITY = -11; -const TInt ENEMY_BULLET_PRIORITY = -12; - enum { FONT_8x8_SLOT, FONT_16x16_SLOT, - BKG_SLOT, - PLAYER_SLOT, - PLAYER_HEAL_SLOT, - PLAYER_SPELL_SLOT, - TILESET_SLOT, - ENVIRONMENT_SLOT, - // enemies - PROJECTILE_ARROW_SLOT, - PROJECTILE_CRYSTAL_SLOT, - BAT_SLOT, - GOBLIN_SLOT, - GOBLIN_SNIPER_SLOT, - ORC_SLOT, - RAT_SLOT, - SLIME_SLOT, - SPIDER_SLOT, - TROLL_SLOT, - ENEMY_DEATH_SLOT, - TURRET_SLOT, - - // spells - SPELL_EARTH_SLOT, - SPELL_ELECTRICITY_SLOT, - SPELL_FIRE_SLOT, - SPELL_WATER_SLOT, - - // mid bosses - BOSS_DEATH_SLOT, - BOSS_SLOT, - BOSS_PROJECTILE_SLOT, - BOSS_PILLAR_SLOT, - - // WIZARDS - EARTH_WIZARD_PROJECTILE_SLOT, - WATER_WIZARD_PROJECTILE_SLOT, - FIRE_WIZARD_PROJECTILE_SLOT, - ENERGY_WIZARD_PROJECTILE_SLOT, - - EARTH_WIZARD_PILLAR_SLOT, - WATER_WIZARD_PILLAR_SLOT, - FIRE_WIZARD_PILLAR_SLOT, - ENERGY_WIZARD_PILLAR_SLOT, - - // FINAL BOSS - EARTH_FINAL_BOSS_PROJECTILE_SLOT, - WATER_FINAL_BOSS_PROJECTILE_SLOT, - FIRE_FINAL_BOSS_PROJECTILE_SLOT, - ENERGY_FINAL_BOSS_PROJECTILE_SLOT, - - EARTH_FINAL_BOSS_PILLAR_SLOT, - WATER_FINAL_BOSS_PILLAR_SLOT, - FIRE_FINAL_BOSS_PILLAR_SLOT, - ENERGY_FINAL_BOSS_PILLAR_SLOT, - - // temporary slot - TEMP_SLOT, - - MAIN_MENU_SLOT0, - MAIN_MENU_SLOT1, - MAIN_MENU_SLOT2, - MAIN_MENU_SLOT3, - MAIN_MENU_SLOT4, - MAIN_MENU_SLOT5, - SLOT_MAX, }; @@ -147,6 +65,7 @@ enum { SFX37_SLOT, }; +#if 0 // SPLASH_SPRITES.BMP const TUint16 IMG_DROP1 = 0; const TUint16 IMG_DROP2 = 4; @@ -167,227 +86,18 @@ const TUint16 IMG_SWORD_UP = 28; const TUint16 IMG_DAMAGE_DOWN = 32; const TUint16 IMG_DAMAGE_RIGHT = 36; const TUint16 IMG_DAMAGE_UP = 40; +#endif -// PLAYER_HEAL_EFFECT.BMP -const TUint16 IMG_HEAL = 0; - -// PLAYER_SPELL_EFFECT.BMP -const TUint16 IMG_SPELL = 0; - -// MID BOSS -const TUint16 IMG_MID_BOSS_IDLE = 0; -const TUint16 IMG_MID_BOSS_WALK_DOWN = 0; -const TUint16 IMG_MID_BOSS_WALK_RIGHT = 4; -const TUint16 IMG_MID_BOSS_WALK_LEFT = 4; -const TUint16 IMG_MID_BOSS_WALK_UP = 8; -const TUint16 IMG_MID_BOSS_MOVE = 12; // move and attack - -// MID BOSS PROJECTILE -const TUint16 IMG_FIREBALL = 0; -const TUint16 IMG_FIREBALL_EXPLODE = 5; - -// MID BOSS DEATH -const TUint16 IMG_MID_BOSS_DEATH = 0; - -// WIZARD -const TUint16 IMG_WIZARD_WALK_DOWN = 0; -const TUint16 IMG_WIZARD_WALK_RIGHT = 4; -const TUint16 IMG_WIZARD_WALK_LEFT = 4; -const TUint16 IMG_WIZARD_WALK_UP = 8; -const TUint16 IMG_WIZARD_FIRE_START = 7; -const TUint16 IMG_WIZARD_FIRE = 11; - -// WIZARD PROJECTILE -const TUint16 IMG_WIZARD_PROJECTILE = 0; -const TUint16 IMG_WIZARD_PROJECTILE_EXPLODE = 5; - -// WIZARD PILLAR -const TUint16 IMG_WIZARD_PILLAR = 0; - -// WIZARD DEATH -const TUint16 IMG_WIZARD_DEATH = 0; - -// FINAL BOSS -const TUint16 IMG_FINAL_BOSS_IDLE = 0; -const TUint16 IMG_FINAL_BOSS_WALK_DOWN = 0; -const TUint16 IMG_FINAL_BOSS_WALK_RIGHT = 3; -const TUint16 IMG_FINAL_BOSS_WALK_UP = 6; - -// FINAL BOSS PROJECTILE -const TUint16 IMG_FINAL_BOSS_PROJECTILE = 0; -const TUint16 IMG_FINAL_BOSS_PROJECTILE_EXPLODE = 5; - -// FINAL BOSS PILLAR -const TUint16 IMG_FINAL_BOSS_PILLAR = 0; - -// CHARA_SPIDER_BMP -const TUint16 IMG_SPIDER_IDLE = 0; -const TUint16 IMG_SPIDER_SELECTED = 4; -const TUint16 IMG_SPIDER_WALK_DOWN = 8; -const TUint16 IMG_SPIDER_WALK_RIGHT = 12; -const TUint16 IMG_SPIDER_WALK_UP = 16; -const TUint16 IMG_SPIDER_ATTACK_DOWN = 20; -const TUint16 IMG_SPIDER_ATTACK_RIGHT = 24; -const TUint16 IMG_SPIDER_ATTACK_UP = 28; -const TUint16 IMG_SPIDER_DAMAGE_DOWN = 32; -const TUint16 IMG_SPIDER_DAMAGE_RIGHT = 36; -const TUint16 IMG_SPIDER_DAMAGE_UP = 40; - -// CHARA_BAT_BMP -const TUint16 IMG_BAT_IDLE = 0; -const TUint16 IMG_BAT_SELECTED = 4; -const TUint16 IMG_BAT_WALK_DOWN = 8; -const TUint16 IMG_BAT_WALK_RIGHT = 12; -const TUint16 IMG_BAT_WALK_UP = 16; -const TUint16 IMG_BAT_ATTACK_DOWN = 20; -const TUint16 IMG_BAT_ATTACK_RIGHT = 24; -const TUint16 IMG_BAT_ATTACK_UP = 28; -const TUint16 IMG_BAT_DAMAGE_DOWN = 32; -const TUint16 IMG_BAT_DAMAGE_RIGHT = 36; -const TUint16 IMG_BAT_DAMAGE_UP = 40; - -// CHARA_GOBLIN_BMP -const TUint16 IMG_GOBLIN_IDLE = 0; -const TUint16 IMG_GOBLIN_SELECTED = 4; -const TUint16 IMG_GOBLIN_WALK_DOWN = 8; -const TUint16 IMG_GOBLIN_WALK_RIGHT = 12; -const TUint16 IMG_GOBLIN_WALK_UP = 16; -const TUint16 IMG_GOBLIN_ATTACK_DOWN = 20; -const TUint16 IMG_GOBLIN_ATTACK_RIGHT = 24; -const TUint16 IMG_GOBLIN_ATTACK_UP = 28; -const TUint16 IMG_GOBLIN_DAMAGE_DOWN = 32; -const TUint16 IMG_GOBLIN_DAMAGE_RIGHT = 36; -const TUint16 IMG_GOBLIN_DAMAGE_UP = 40; - -// CHARA_GOBLIN_SNIPER_BMP -const TUint16 IMG_GOBLIN_SNIPER_IDLE = 0; -const TUint16 IMG_GOBLIN_SNIPER_SELECTED = 4; -const TUint16 IMG_GOBLIN_SNIPER_WALK_DOWN = 8; -const TUint16 IMG_GOBLIN_SNIPER_WALK_RIGHT = 12; -const TUint16 IMG_GOBLIN_SNIPER_WALK_UP = 16; -const TUint16 IMG_GOBLIN_SNIPER_ATTACK_DOWN = 20; -const TUint16 IMG_GOBLIN_SNIPER_ATTACK_RIGHT = 24; -const TUint16 IMG_GOBLIN_SNIPER_ATTACK_UP = 28; -const TUint16 IMG_GOBLIN_SNIPER_DAMAGE_DOWN = 32; -const TUint16 IMG_GOBLIN_SNIPER_DAMAGE_RIGHT = 36; -const TUint16 IMG_GOBLIN_SNIPER_DAMAGE_UP = 40; - -// CHARA_ORC_BMP -const TUint16 IMG_ORC_IDLE = 0; -const TUint16 IMG_ORC_SELECTED = 4; -const TUint16 IMG_ORC_WALK_DOWN = 8; -const TUint16 IMG_ORC_WALK_RIGHT = 12; -const TUint16 IMG_ORC_WALK_UP = 16; -const TUint16 IMG_ORC_ATTACK_DOWN = 20; -const TUint16 IMG_ORC_ATTACK_RIGHT = 24; -const TUint16 IMG_ORC_ATTACK_UP = 28; -const TUint16 IMG_ORC_DAMAGE_DOWN = 32; -const TUint16 IMG_ORC_DAMAGE_RIGHT = 36; -const TUint16 IMG_ORC_DAMAGE_UP = 40; - -// CHARA_RAT_BMP -const TUint16 IMG_RAT_IDLE = 0; -const TUint16 IMG_RAT_SELECTED = 4; -const TUint16 IMG_RAT_WALK_DOWN = 8; -const TUint16 IMG_RAT_WALK_RIGHT = 12; -const TUint16 IMG_RAT_WALK_UP = 16; -const TUint16 IMG_RAT_ATTACK_DOWN = 20; -const TUint16 IMG_RAT_ATTACK_RIGHT = 24; -const TUint16 IMG_RAT_ATTACK_UP = 28; -const TUint16 IMG_RAT_DAMAGE_DOWN = 32; -const TUint16 IMG_RAT_DAMAGE_RIGHT = 36; -const TUint16 IMG_RAT_DAMAGE_UP = 40; - -// CHARA_SLIME_BMP -const TUint16 IMG_SLIME_IDLE = 0; -const TUint16 IMG_SLIME_SELECTED = 4; -const TUint16 IMG_SLIME_WALK_DOWN = 8; -const TUint16 IMG_SLIME_WALK_RIGHT = 12; -const TUint16 IMG_SLIME_WALK_UP = 16; -const TUint16 IMG_SLIME_ATTACK_DOWN = 20; -const TUint16 IMG_SLIME_ATTACK_RIGHT = 24; -const TUint16 IMG_SLIME_ATTACK_UP = 28; -const TUint16 IMG_SLIME_DAMAGE_DOWN = 32; -const TUint16 IMG_SLIME_DAMAGE_RIGHT = 36; -const TUint16 IMG_SLIME_DAMAGE_UP = 40; - -// CHARA_TROLL_BMP -const TUint16 IMG_TROLL_IDLE = 0; -const TUint16 IMG_TROLL_SELECTED = 4; -const TUint16 IMG_TROLL_WALK_DOWN = 8; -const TUint16 IMG_TROLL_WALK_RIGHT = 12; -const TUint16 IMG_TROLL_WALK_UP = 16; -const TUint16 IMG_TROLL_ATTACK_DOWN = 20; -const TUint16 IMG_TROLL_ATTACK_RIGHT = 24; -const TUint16 IMG_TROLL_ATTACK_UP = 28; -const TUint16 IMG_TROLL_DAMAGE_DOWN = 32; -const TUint16 IMG_TROLL_DAMAGE_RIGHT = 36; -const TUint16 IMG_TROLL_DAMAGE_UP = 40; - -// ENEMY_DEATH_BMP -const TUint16 IMG_ENEMY_DEATH = 0; - -// GLOBAL_OBJECT_LAYER_BMP -const TUint16 IMG_WOOD_DOOR_H_TOP = 10; // Top -const TUint16 IMG_WOOD_DOOR_H_BOTTOM = 20; // Bottom. This is the code ATTR_WOOD_DOOR_H -const TUint16 IMG_METAL_GATE_H_TOP = 11; // Top -const TUint16 IMG_METAL_GATE_H_BOTTOM = 21; // Bottom. This is the code ATTR_METAL_GATE_H - -const TUint16 IMG_SPIKES = 15; // through 19 -const TUint16 IMG_CHEST = 22; // closed, open is 23 -const TUint16 IMG_POT = 24; // through 28 - -const TUint16 IMG_WOOD_DOOR_V_TOP = 30; // Top. -const TUint16 IMG_WOOD_DOOR_V_BOTTOM = 40; // Bottom. -const TUint16 IMG_METAL_GATE_V_TOP = 31; // Top -const TUint16 IMG_METAL_GATE_V_BOTTOM = 41; // Bottom - -const TUint16 IMG_FLOOR_SWITCH = 32; // grey, 33 is pressed -const TUint16 IMG_FLOOR_SWITCH_WOOD = 34; // brown, 35 is pressed - -const TUint16 IMG_LEVER = 36; // left, center = 36, right = 37 -const TUint16 IMG_STONE_STAIRS_DOWN = 48; -const TUint16 IMG_STONE_STAIRS_UP = 49; // 39 is the upper sprite image for the very top stairs -const TUint16 IMG_WOOD_STAIRS_DOWN = 68; -const TUint16 IMG_WOOD_STAIRS_UP = 69; // 59 is the upper sprite image for the very top stairs -const TUint16 IMG_BLUE_SPELLBOOK = 80; -const TUint16 IMG_RED_SPELLBOOK = 81; -const TUint16 IMG_GREEN_SPELLBOOK = 82; -const TUint16 IMG_YELLOW_SPELLBOOK = 83; -const TUint16 IMG_SILVER_KEY = 85; -const TUint16 IMG_GOLD_KEY = 86; -const TUint16 IMG_BLUE_RING = 90; -const TUint16 IMG_RED_RING = 91; -const TUint16 IMG_GREEN_RING = 92; -const TUint16 IMG_YELLOW_RING = 93; -const TUint16 IMG_BOOTS = 94; -const TUint16 IMG_GLOVES = 95; -const TUint16 IMG_SWORD = 96; -const TUint16 IMG_BLUE_AMULET = 100; -const TUint16 IMG_RED_AMULET = 101; -const TUint16 IMG_GREEN_AMULET = 102; -const TUint16 IMG_YELLOW_AMULET = 103; -const TUint16 IMG_RED_POTION1_LRG = 110;// <-- large image -const TUint16 IMG_RED_POTION2_LRG = 111;// <-- large image -const TUint16 IMG_BLUE_POTION1_LRG = 112; // <-- large image -const TUint16 IMG_BLUE_POTION2_LRG = 113;// <-- large image -const TUint16 IMG_EMPTY_BOTTLE = 114; // EMPTY -const TUint16 IMG_HEART = 84; // EMPTY - -const TUint16 IMG_BLUE_BOTTLE1 = 120; // 25% full -const TUint16 IMG_BLUE_BOTTLE2 = 121; // 50% full -const TUint16 IMG_BLUE_BOTTLE3 = 122; // 75% full -const TUint16 IMG_BLUE_BOTTLE4 = 123; // 100% full -const TUint16 IMG_GREEN_BOTTLE1 = 124; // 25% full -const TUint16 IMG_GREEN_BOTTLE2 = 125; // 50% full -const TUint16 IMG_GREEN_BOTTLE3 = 126; // 75% full -const TUint16 IMG_GREEN_BOTTLE4 = 127; // 100% full //// RESERVED COLORS +const TUint8 COLOR_BLACK = 0; +const TUint8 COLOR_WHITE = 1; +const TUint8 COLOR_TEXT = 2; +const TUint8 COLOR_STAR = 3; +const TUint8 COLOR_ENEMY1 = 4; +const TUint8 COLOR_SHMOO = 255; - -const TUint8 COLOR_BLACK = 200; const TUint8 COLOR_BLUE = 201; const TUint8 COLOR_GREEN = 202; const TUint8 COLOR_CYAN = 203; @@ -408,8 +118,6 @@ const TUint8 COLOR_SPACE = 215; -const float CAMERA_VZ = 8; - const TUint8 SHMOO_COLOR = 216; const TUint8 BULLET_COLOR = 217; @@ -420,51 +128,6 @@ const TUint8 BOMBER_COLOR = 221; const TUint8 SCOUT_COLOR = 222; const TUint8 STAR_COLOR = 223; - - - - -const TUint8 COLOR_WHITE = 240; // for hit/flash animations, etc. -const TUint8 COLOR_SHADOW = 241; -const TUint8 COLOR_SHMOO_RED = 242; -const TUint8 COLOR_SHMOO_GREEN = 243; -const TUint8 COLOR_HUD_BG = 244; -const TUint8 COLOR_METER_OUTLINE = 245; -const TUint8 COLOR_HEALTH = 246; // health bar -const TUint8 COLOR_HEALTH2 = 247; // health bar -const TUint8 COLOR_MAGIC = 248; -const TUint8 COLOR_MAGIC2 = 249; -const TUint8 COLOR_EXPERIENCE = 250; // experience bar -const TUint8 COLOR_EXPERIENCE2 = 251; // experience bar -const TUint8 COLOR_SHMOO = 252; -const TUint8 COLOR_TEXT_SHADOW = 253; -const TUint8 COLOR_TEXT_BG = 254; -const TUint8 COLOR_TEXT = 255; -const TInt16 COLOR_TEXT_TRANSPARENT = -1; - - -const TUint16 OFLAG_TYPE_MASK = 0x07; -// Object is an enemy -const TUint16 OTYPE_ENEMY = 0; -// Object is player's bullet -const TUint16 OTYPE_PLAYER_BULLET = 1; -// Object is enemy bullet -const TUint16 OTYPE_ENEMY_BULLET = 2; -// STRING means lines is a character string to be rendered in 3D -const TUint16 OTYPE_STRING = 3; -const TUint16 OTYPE_ASTEROID = 4; -// MOON means lines is ignored and a circle is rendered, as in a moon or planet -// theta becomes radius -const TUint16 OTYPE_MOON = 5; - -// FLAGS -// if set, the lines will explode -const TUint16 OFLAG_EXPLODE = (1 << 4); -// set when the object has collided (ENEMY vs PLAYER BULLET, etc.) -const TUint16 OFLAG_COLLISION = (1 << 5); -// Process can use the remaining bits, starting with (1< #include +#include -const TUint16 FACTOR = FRAMES_PER_SECOND / 30; +//const TUint16 FACTOR = FRAMES_PER_SECOND / 30; #include "GResources.h" #include "GGame.h" -#include "common/GDialogWidget.h" -#include "common/GButtonWidget.h" +//#include "common/GDialogWidget.h" +//#include "common/GButtonWidget.h" #include "TOptions.h" #include "GSoundPlayer.h" // GGameEngine states -#include "GSplashState.h" -#include "GGameState.h" -#include "GMainMenuState.h" -#include "GMainOptionsState.h" -#include "GResetOptionsState.h" -#include "GGameMenuState.h" -#include "GAttractModeState.h" -#include "GVictoryState.h" -#include "DebugMenuState/GDebugMenuState.h" -#include "GCreditsState.h" +//#include "GSplashState.h" +//#include "GGameState.h" +//#include "GMainMenuState.h" +//#include "GMainOptionsState.h" +//#include "GResetOptionsState.h" +//#include "GGameMenuState.h" +//#include "GAttractModeState.h" +//#include "GVictoryState.h" +//#include "DebugMenuState/GDebugMenuState.h" +//#include "GCreditsState.h" //#include "GInventory.h" extern BViewPort *gViewPort; @@ -91,4 +97,26 @@ struct EnemyConfig { TInt16 mVZ; }; +const TUint16 OFLAG_TYPE_MASK = 0x07; +// Object is an enemy +const TUint16 OTYPE_ENEMY = 0; +// Object is player's bullet +const TUint16 OTYPE_PLAYER_BULLET = 1; +// Object is enemy bullet +const TUint16 OTYPE_ENEMY_BULLET = 2; +// STRING means lines is a character string to be rendered in 3D +const TUint16 OTYPE_STRING = 3; +const TUint16 OTYPE_ASTEROID = 4; +// MOON means lines is ignored and a circle is rendered, as in a moon or planet +// theta becomes radius +const TUint16 OTYPE_MOON = 5; + +// FLAGS +// if set, the lines will explode +const TUint16 OFLAG_EXPLODE = (1 << 4); +// set when the object has collided (ENEMY vs PLAYER BULLET, etc.) +const TUint16 OFLAG_COLLISION = (1 << 5); +// Process can use the remaining bits, starting with (1<mTileset, 0, 128); - for (TInt s = 0; s < 16; s++) { - mGroupDone[s] = mGroupState[s] = EFalse; - } - mMosaicTimer = 0; - - GHud::SetColors(); - - TRGB *source = gDisplay.renderBitmap->GetPalette(); - for (TInt color = 0; color < 255; color++) { - TRGB c = source[color]; - mSavedPalette[color] = c; - gDisplay.SetColor(color, 0,0,0); - } - -} - -GGamePlayfield::~GGamePlayfield() = default; - -void GGamePlayfield::Render() { - BMapPlayfield::Render(); - if (mMosaicTimer) { - TInt mosaicWidth = 1 + (mMosaicIn ? mMosaicTimer : (MOSAIC_DURATION - mMosaicTimer)) * MOSAIC_INTENSITY / MOSAIC_DURATION; - TRect &r = mViewPort->mRect; - TUint8 *pixels = &gDisplay.renderBitmap->mPixels[0]; - - for (TInt y = r.y1; y < SCREEN_HEIGHT; y++) { - for (TInt x = r.x1; x < SCREEN_WIDTH; x++) { - pixels[y * SCREEN_WIDTH + x] = pixels[(y - (y - r.y1) % mosaicWidth) * SCREEN_WIDTH + (x - (x - r.x1) % mosaicWidth)]; - } - } - - - // Normalize mosaic width to the range of 21 and 1. - // Record it as a percentage - TFloat pct = (1 - ((TFloat)mosaicWidth - 1) / 20); - - for (TInt color = 0; color < 255; color++) { - TRGB c = mSavedPalette[color]; - - TUint16 red = (TFloat)c.r * pct; - c.r = (TUint8)((red > 0xFF) ? 0xFF : red); - - TUint16 green = (TFloat)c.g * pct; - c.g = (TUint8)((green > 0xFF) ? 0xFF : green); +// +// Created by Michael Schwartz on 10/29/20. +// - TUint16 blue = (TFloat)c.b * pct; - c.b = (TUint8)((blue > 0xFF) ? 0xFF : blue); - - gDisplay.SetColor(color, c); - } - - mMosaicTimer--; - } -} - -void GGamePlayfield::StartMosaicIn() { - if (!mMosaicTimer) { - GHud::SetColors(); - // Cache colors - TRGB *source = gDisplay.renderBitmap->GetPalette(); - for (TInt color = 0; color < 255; color++) { - TRGB c = source[color]; - mSavedPalette[color] = c; - gDisplay.SetColor(color, 0,0,0); - } +#include "GGamePlayfield.h" +#include "GCamera.h" - mMosaicTimer = MOSAIC_DURATION; - mMosaicIn = ETrue; +GGamePlayfield::GGamePlayfield() : BPlayfield() { + for (TInt i = 0; i < NUM_STARS; i++) { + InitStar(i); } } +GGamePlayfield::~GGamePlayfield() noexcept { -void GGamePlayfield::StartMosaicOut() { - if (!mMosaicTimer) { - TRGB *source = gDisplay.renderBitmap->GetPalette(); - for (TInt color = 0; color < 255; color++) { - TRGB c = source[color]; - mSavedPalette[color] = c; - } - mMosaicTimer = MOSAIC_DURATION; - mMosaicIn = EFalse; - } } -void GGamePlayfield::DumpMap() { - printf("MAP DATA\n"); - for (TInt row = 0; row < mMapHeight; row++) { - for (TInt col = 0; col < mMapWidth; col++) { - printf("%5d ", mMapData[row * mMapWidth + col] & 0xffff); +void GGamePlayfield::Render() { + gDisplay.renderBitmap->Clear(0); + TFloat cz = GCamera::mZ, + sw = TFloat(SCREEN_WIDTH), + sh = TFloat(SCREEN_HEIGHT); + + for (int i = 0; i < NUM_STARS; i++) { + TFloat zz = (mStarZ[i] - cz) * 2; + if (zz < 0) { + InitStar(i); + zz = (mStarZ[i] - cz) * 2; } - printf("\n"); - } -} - -void GGamePlayfield::DumpMapAttributes() { - printf("MAP ATTRIBUTES\n"); - for (TInt row = 0; row < mMapHeight; row++) { - for (TInt col = 0; col < mMapWidth; col++) { - printf("%5d ", (mMapData[row * mMapWidth + col] >> 16) & 0xffff); + TFloat ratioX = sw / (zz + sw); + TFloat ratioY = sh / (zz + sh); + TFloat x = (sw / 2) - (mStarX[i] - GCamera::mX) * ratioX; + TFloat y = (sh / 2) - (mStarY[i] - GCamera::mY) * ratioY; + + if (x < 0) { +// printf("InitStar x %f < 0\n", x); + InitStar(i); + } else if (x > sw) { +// printf("InitStar x %f > %f\n", x, sw); + InitStar(i); + } else if (y < 0) { +// printf("InitStar y %f < 0\n", y); + InitStar(i); + } else if (y > sh) { +// printf("InitStar y %f > %f\n", y, sh); + InitStar(i); } - printf("\n"); +// printf("Plot %f,%f\n", x, y); + gDisplay.renderBitmap->SafeWritePixel(x, y, COLOR_STAR); } } -void GGamePlayfield::Restore() { - gResourceManager.ReleaseBitmapSlot(TILESET_SLOT); - mTileMap = gResourceManager.LoadTileMap(mTileMapId, TILESET_SLOT); -} - -void GGamePlayfield::WriteToStream(BMemoryStream &aStream) { - aStream.Write(&mTileMapId, sizeof(mTileMapId)); - aStream.Write(&mGroupDone[0], sizeof(TBool) * 16); - aStream.Write(&mGroupState[0], sizeof(TBool) * 16); - // object proram - aStream.Write(&mObjectCount, sizeof(mObjectCount)); - aStream.Write(mObjectProgram, sizeof(BObjectProgram) * mObjectCount); - printf("BMapPlayfield: %d Objects\n", mObjectCount); - DumpObjectProgram(); -} +void GGamePlayfield::InitStar(TInt aIndex) { + mStarX[aIndex] = 256 - Random(0, 512) + GCamera::mX; + mStarY[aIndex] = 256 - Random(0, 512) + GCamera::mY; + mStarZ[aIndex] = GCamera::mZ + Random(200, 512); -void GGamePlayfield::ReadFromStream(BMemoryStream &aStream) { - aStream.Read(&mTileMapId, sizeof(mTileMapId)); - aStream.Read(&mGroupDone[0], sizeof(TBool) * 16); - aStream.Read(&mGroupState[0], sizeof(TBool) * 16); - // object proram - aStream.Read(&mObjectCount, sizeof(mObjectCount)); - mObjectProgram = new BObjectProgram[mObjectCount]; - aStream.Read(mObjectProgram, sizeof(BObjectProgram) * mObjectCount); - printf("BMapPlayfield: %d Objects\n", mObjectCount); - DumpObjectProgram(); -} +} \ No newline at end of file diff --git a/Evade2/src/GameState/GGamePlayfield.h b/Evade2/src/GameState/GGamePlayfield.h index 696521a..19c662d 100644 --- a/Evade2/src/GameState/GGamePlayfield.h +++ b/Evade2/src/GameState/GGamePlayfield.h @@ -1,245 +1,29 @@ -#ifndef MODITE_GGAMEPLAYFIELD_H -#define MODITE_GGAMEPLAYFIELD_H - -//#include "Game.h" - -#include - -class GGameState; - -const TFloat GRAVITY = 15.0 / FRAMES_PER_SECOND; // for falling, arrow dropping, etc. - -#include "object_layer_attributes.h" - -// these match the codes set for tiles in Pro Motion: - -//// MAP LAYER -// NOTE: Map layer is only used for tile numbers to render. The codes are ignored. - -//// MAP ATTRIBUTE LAYER -const TUint16 ATTR_ROTATE_90 = 1u << 0u; -const TUint16 ATTR_ROTATE_180 = 1u << 1u; -const TUint16 ATTR_INVERT = 1u << 2u; -const TUint16 ATTR_FULL_FLOOR = 0; -const TUint16 ATTR_LEDGE = 1; -const TUint16 ATTR_THIN_WALL = 2; -const TUint16 ATTR_CORNER_IN = 3; -const TUint16 ATTR_CORNER_OUT = 4; -const TUint16 ATTR_CORNER_DIAGONAL = 5; -const TUint16 ATTR_HORIZONTAL_DOOR_WALL = 6; -const TUint16 ATTR_VERTICAL_DOOR_WALL = 7; - -//const TUint16 ATTR_PROJECTILE_ARROW = 25; // not sure this is going to be used like a GEnemyProcess - -//// OBJECT LAYER VALUES -const TUint16 ATTR_GONE = 0; // thing is no longer in the world -const TUint16 ATTR_STONE_STAIRS_UP = 1; -const TUint16 ATTR_STONE_STAIRS_DOWN = 2; -const TUint16 ATTR_WOOD_STAIRS_UP = 3; -const TUint16 ATTR_WOOD_STAIRS_DOWN = 4; -const TUint16 ATTR_POT = 5; -const TUint16 ATTR_CHEST = 6; -const TUint16 ATTR_SPIKES = 7; -const TUint16 ATTR_WOOD_DOOR_H = 8; // horizontal -const TUint16 ATTR_WOOD_DOOR_V = 9; // vertical -const TUint16 ATTR_METAL_GATE_H = 10; // horizontal -const TUint16 ATTR_METAL_GATE_V = 11; // vertical -const TUint16 ATTR_LEVER = 12; // tri state lever -const TUint16 ATTR_FLOOR_SWITCH = 13; -const TUint16 ATTR_FLOOR_SWITCH_WOOD = 14; -const TUint16 ATTR_PLAYER_IN1 = 100; -const TUint16 ATTR_PLAYER_IN2 = 101; -const TUint16 ATTR_SPIDER = 17; -const TUint16 ATTR_BAT = 18; -const TUint16 ATTR_GOBLIN = 19; -const TUint16 ATTR_GOBLIN_SNIPER = 20; -const TUint16 ATTR_ORC = 21; -const TUint16 ATTR_RAT = 22; -const TUint16 ATTR_SLIME = 23; -const TUint16 ATTR_TROLL = 24; -const TUint16 ATTR_CHEST_OPEN = 25; -const TUint16 ATTR_POT_GONE = 26; -const TUint16 ATTR_DUNGEON_ENTRANCE = 27; -const TUint16 ATTR_DUNGEON_EXIT_FROM_LEVEL_1 = 28; -const TUint16 ATTR_TURRET = 29; -const TUint16 ATTR_SPAWN_SMALL_HEALTH = 30; -const TUint16 ATTR_SPAWN_LARGE_HEALTH = 31; -const TUint16 ATTR_SPAWN_SMALL_MANA = 32; -const TUint16 ATTR_SPAWN_LARGE_MANA = 33; -const TUint16 ATTR_SPAWN_HEART = 34; -// mid bosses -const TUint16 ATTR_MID_BOSS_EARTH = 1001; -const TUint16 ATTR_MID_BOSS_WATER = 1002; -const TUint16 ATTR_MID_BOSS_FIRE = 1003; -const TUint16 ATTR_MID_BOSS_ENERGY = 1004; -const TUint16 ATTR_WIZARD_EARTH = 1005; -const TUint16 ATTR_WIZARD_WATER = 1006; -const TUint16 ATTR_WIZARD_FIRE = 1007; -const TUint16 ATTR_WIZARD_ENERGY = 1008; -const TUint16 ATTR_FINAL_BOSS = 1009; -const TUint16 ATTR_FINAL_BOSS_EARTH = 1005; -const TUint16 ATTR_FINAL_BOSS_WATER = 1006; -const TUint16 ATTR_FINAL_BOSS_FIRE = 1007; -const TUint16 ATTR_FINAL_BOSS_ENERGY = 1008; - - - // -const TUint16 ATTR_KEEP = 32767; // pass this to EndProgram to keep existing OBJECT_LAYER value - -//// OBJECT ATTRIBUTE LAYER VALUES -// Note: these values are unique per thing -// That is, stairs has its own 0-0xffff attributes and crate has its own, and so on. -// Some things, like a key, might be in a crate or simply on the floor, so those have -// to be considered/globally unique. - -// stairs (destinations) -const TUint16 ATTR_OW_LEVEL_ENTRANCE = 99; - -// items (can be inside crates, chests, inventory) -// RED = LEFT, BLUE = MAGIC -// SEE -const TUint16 ATTR_EMPTY = 0; -const TUint16 ATTR_BLUE_SPELLBOOK = 1; -const TUint16 ATTR_RED_SPELLBOOK = 2; -const TUint16 ATTR_GREEN_SPELLBOOK = 3; -const TUint16 ATTR_YELLOW_SPELLBOOK = 4; -const TUint16 ATTR_SILVER_KEY = 5; -const TUint16 ATTR_GOLD_KEY = 6; -const TUint16 ATTR_BLUE_RING = 7; -const TUint16 ATTR_RED_RING = 8; -const TUint16 ATTR_GREEN_RING = 9; -const TUint16 ATTR_YELLOW_RING = 10; -const TUint16 ATTR_BOOTS = 11; -const TUint16 ATTR_GLOVES = 12; -const TUint16 ATTR_SWORD = 13; -const TUint16 ATTR_BLUE_AMULET = 14; -const TUint16 ATTR_RED_AMULET = 15; -const TUint16 ATTR_GREEN_AMULET = 16; -const TUint16 ATTR_YELLOW_AMULET = 17; -const TUint16 ATTR_RED_POTION1 = 18; -const TUint16 ATTR_RED_POTION2 = 19; -const TUint16 ATTR_BLUE_POTION1 = 20; -const TUint16 ATTR_BLUE_POTION2 = 21; -const TUint16 ATTR_HEART = 22; +// Created by Michael Schwartz on 10/29/20. +// -const TUint16 ATTR_EMPTY_BOTTLE = 23; // empty bottle -const TUint16 ATTR_BLUE_BOTTLE1 = 24; // 25% full -const TUint16 ATTR_BLUE_BOTTLE2 = 25; // 50% full -const TUint16 ATTR_BLUE_BOTTLE3 = 26; // 75% full -const TUint16 ATTR_BLUE_BOTTLE4 = 27; // 100% full -const TUint16 ATTR_RED_BOTTLE1 = 28; // 25% full -const TUint16 ATTR_RED_BOTTLE2 = 29; // 50% full -const TUint16 ATTR_RED_BOTTLE3 = 30; // 75% full -const TUint16 ATTR_RED_BOTTLE4 = 31; // 100% full +#ifndef EVADE2_GGAMEPLAYFIELD_H +#define EVADE2_GGAMEPLAYFIELD_H -const TInt MOSAIC_DURATION = 0.5 * FRAMES_PER_SECOND; -const TInt MOSAIC_INTENSITY = 20; +#include -const TInt WALL_THICKNESS = 12; // minimum thickness of walls +const int NUM_STARS = 128; -class GGamePlayfield : public BMapPlayfield { +class GGamePlayfield : public BPlayfield { public: - GGamePlayfield(BViewPort *aViewPort, TUint16 aTileMapId); + GGamePlayfield(); - ~GGamePlayfield() OVERRIDE; + ~GGamePlayfield(); public: void Render() OVERRIDE; - void StartMosaicIn(); - - void StartMosaicOut(); - - TBool MosaicActive() { - return mMosaicTimer > 1; - } - - TBool MosaicDone() { - return mMosaicTimer == 1; - }; - - void Restore(); - - void DumpObjectProgram() { - for (TInt i=0; i> 16); - } - - TUint16 GetAttribute(TInt aRow, TInt aCol) { - return TUint16(GetCell(aRow, aCol) >> 16); - } - - TBool IsFloor(TFloat aWorldX, TFloat aWorldY) { - const TUint16 attr = GetAttribute(aWorldX, aWorldY); - const TInt col = TInt(FLOOR(aWorldX / TILESIZE)), - row = TInt(FLOOR(aWorldY / TILESIZE)); - TInt x = TInt(aWorldX) % TILESIZE, y = TInt(aWorldY) % TILESIZE, tmp; - if (row >= 0 && row <= mMapHeight - 1 && col >= 0 && col <= mMapWidth - 1) { - TBool inverted = attr & ATTR_INVERT; - if (attr & ATTR_ROTATE_90) { - tmp = x; - x = y; - y = TILESIZE - tmp; - } - if (attr & ATTR_ROTATE_180) { - x = TILESIZE - x; - y = TILESIZE - y; - } - switch (attr >> 3u) { - case ATTR_FULL_FLOOR: - default: - return !inverted; - case ATTR_THIN_WALL: - case ATTR_LEDGE: - return inverted ^ (x > WALL_THICKNESS); - case ATTR_CORNER_IN: - return inverted ^ (x > WALL_THICKNESS && y > WALL_THICKNESS); - case ATTR_CORNER_OUT: - return inverted ^ (x > WALL_THICKNESS || y > WALL_THICKNESS); - case ATTR_CORNER_DIAGONAL: - return inverted ^ (x + y < TILESIZE - WALL_THICKNESS); - case ATTR_HORIZONTAL_DOOR_WALL: - return y < 16; - case ATTR_VERTICAL_DOOR_WALL: - return x < 8 || x > 24; - } - } - else { - return (row == -1 && y > -WALL_THICKNESS) || - (row == mMapHeight && y <= WALL_THICKNESS) || - (col == -1 && x > -WALL_THICKNESS) || - (col == mMapWidth && x <= WALL_THICKNESS); - } - } - - TBool IsLedge(TFloat aWorldX, TFloat aWorldY) { - return GetAttribute(aWorldX, aWorldY) >> 3u == ATTR_LEDGE; - } - -public: - TBool mGroupState[16], mGroupDone[16]; - -public: - void WriteToStream(BMemoryStream &aStream); - - void ReadFromStream(BMemoryStream &aStream); +protected: + void InitStar(TInt aIndex); protected: - GGameState *mGameState; - TUint32 mTileMapId; - TInt mMosaicTimer; - TBool mMosaicIn; - TRGB mSavedPalette[256]; + TFloat mStarX[NUM_STARS], mStarY[NUM_STARS], mStarZ[NUM_STARS]; }; -#endif //MODITE_GGAMEPLAYFIELD_H + +#endif //EVADE2_GGAMEPLAYFIELD_H diff --git a/Evade2/src/GameState/GGameState.cpp b/Evade2/src/GameState/GGameState.cpp index b7e3671..8884bc3 100644 --- a/Evade2/src/GameState/GGameState.cpp +++ b/Evade2/src/GameState/GGameState.cpp @@ -1,1122 +1,23 @@ -// Game State -#include "GGameState.h" -#include "GGamePlayfield.h" -#include "GResources.h" -#include "GameState/player/GGameOver.h" -#include "GameState/player/GPlayerProcess.h" -#include "GHud.h" - -#include "GPlayer.h" - -#include - -#define DEBUGME -//#undef DEBUGME - -// DEBUG_FINALBOSS causes wizard spawn to become final boss spawn so we can debug the final boss -#define DEBUG_FINALBOSS -#undef DEBUG_FINALBOSS - -// info about the dungeons -#include "DungeonDefs.h" -const TInt NUM_DUNGEONS = sizeof(gDungeonDefs) / sizeof(TDungeonInfo); - -/******************************************************************************* - ******************************************************************************* - *******************************************************************************/ - -void GGameState::Init() { - strcpy(mText, ""); - strcpy(mName, ""); - mLevel = 0; - mNextDungeon = mDungeon = 0; - mNextLevel = 0; - mTileMapId = 0; - mPlayerToLoad = ATTR_PLAYER_IN1; - - mNextTileMapId = 0; - mNextObjectsId = 0; - - mTimer = FRAMES_PER_SECOND * 1; - mCameraTimer = 0; - mGameOver = ENull; - - mGamePlayfield = mNextGamePlayfield = ENull; - - // Clear BObject programs - GGamePlayfield::ResetCache(); - - - gViewPort->SetRect(TRect(0, 16, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1)); - gViewPort->Offset(0, 16); - gDisplay.SetColor(COLOR_TEXT_BG, 0, 0, 0); - gDisplay.SetColor(COLOR_TEXT, 255, 255, 255); - GPlayer::Init(); -} - -// Constructor -GGameState::GGameState() : BGameEngine(gViewPort) { - Init(); - for (TInt i = 2; i < SLOT_MAX; i++) { - if (gResourceManager.GetBitmap(i)) { - printf("Releasing slot %d\n", i); - gResourceManager.ReleaseBitmapSlot(i); - } - mSlotRemapState[i] = EFalse; - } - NextLevel(OVERWORLD_DUNGEON, 1); -} - -// Constructor -GGameState::GGameState(const char *aName) : BGameEngine(gViewPort) { - Init(); - for (TInt i = 2; i < SLOT_MAX; i++) { - if (gResourceManager.GetBitmap(i)) { - printf("Releasing slot %d\n", i); - gResourceManager.ReleaseBitmapSlot(i); - } - mSlotRemapState[i] = EFalse; - } - LoadState(aName); -} - -GGameState::~GGameState() = default; - -GProcess *GGameState::AddProcess(GProcess *p) { - mProcessList.AddProcess(p); - return p; -} - -void GGameState::TryAgain(TBool aExitDungeon) { - GPlayer::mGameOver = EFalse; - GPlayer::mHitPoints = GPlayer::mMaxHitPoints; - - if (aExitDungeon) { - NextLevel(OVERWORLD_DUNGEON, LastOverworldLevel()); - return; - } - - // Cache previous respawn coords, LoadLevel resets them - TFloat respawnAt[2] = { GPlayerProcess::mRespawnAt[0], GPlayerProcess::mRespawnAt[1] }; - - // Reset the level - LoadLevel(mName, mLevel, mTileMapId); - gDisplay.SetColor(COLOR_WHITE, 255, 255, 255); - - - // Restore respawn coords - GPlayerProcess::mRespawnAt[0] = respawnAt[0]; - GPlayerProcess::mRespawnAt[1] = respawnAt[1]; - - if (respawnAt[0] != '\0') { - GAnchorSprite *s = GPlayer::mProcess->Sprite(); - s->x = respawnAt[0]; - s->y = respawnAt[1]; -#ifdef DEBUG_MODE - printf("RESPAWNED AT %f %f\n", respawnAt[0], respawnAt[1]); -#endif - } -} - -TBool GGameState::IsBossRoom() { - TInt objectCount = mGamePlayfield->mObjectCount; - BObjectProgram *program = mGamePlayfield->mObjectProgram; - for (TInt ip = 0; ip < objectCount; ip++) { - TUint16 op = program[ip].mCode & TUint32(0xffff); - switch (op) { - case ATTR_MID_BOSS_EARTH: - case ATTR_MID_BOSS_ENERGY: - case ATTR_MID_BOSS_FIRE: - case ATTR_MID_BOSS_WATER: - case ATTR_WIZARD_EARTH: - case ATTR_WIZARD_ENERGY: - case ATTR_WIZARD_FIRE: - case ATTR_WIZARD_WATER: - case ATTR_FINAL_BOSS: - return ETrue; - default: - continue; - } - } - - return EFalse; -} - -/******************************************************************************* - ******************************************************************************* - *******************************************************************************/ - -void GGameState::PreRender() { - if (mNextLevel != mLevel || mNextDungeon != mDungeon) { - if (mLevel) { - mGamePlayfield->StartMosaicOut(); - - if (mGamePlayfield->MosaicDone()) { - LoadLevel(mName, mNextLevel, mNextTileMapId); - - } - } - else { - LoadLevel(mName, mNextLevel, mNextTileMapId); - } - } - gDisplay.SetColor(COLOR_WHITE, 255, 255, 255); -} - -/******************************************************************************* - ******************************************************************************* - *******************************************************************************/ - -void GGameState::PositionCamera() { - // position viewport to follow player - TFloat maxx = MapWidth(), - maxy = MapHeight(); - - // half viewport size - const TFloat ww = gViewPort->mRect.Width() / 2.0, - hh = gViewPort->mRect.Height() / 2.0; - TPoint playerCenter = GPlayer::mSprite->Center(); - - // upper left corner of desired viewport position - TFloat xx = playerCenter.x - ww, - yy = playerCenter.y - hh; - - if (mCameraTimer > 0) { - mCameraTimer--; - TFloat cameraInertia = exp(-FACTOR * TFloat(mCameraTimer) / TARGET_PAN_DURATION); - mWorldXX += (xx - mWorldXX) * cameraInertia; - mWorldYY += (yy - mWorldYY) * cameraInertia; - } else { - mWorldXX = xx; - mWorldYY = yy; - } - if (mWorldXX < 0) { - mWorldXX = 0; - } - else if (mWorldXX > maxx) { - mWorldXX = maxx; - } - if (mWorldYY < 0) { - mWorldYY = 0; - } - else if (mWorldYY > maxy) { - mWorldYY = maxy; - } - - gViewPort->mWorldX = TInt(mWorldXX); - gViewPort->mWorldY = TInt(mWorldYY); -} - -static void fuel_gauge(BViewPort *vp, TInt x, TInt y, TInt stat, TInt stat_max, TUint8 color) { -// BBitmap *screen = gDisplay.renderBitmap; -// -// // calculate fill percentage -// TRect r(0, 0, GAUGE_WIDTH, 8); -// -// // offset to display coordinates -// r.Offset(x, y); -// -// // draw frame -// screen->DrawRect(vp, r, COLOR_TEXT); -// -// // calculate percentage -// TFloat pct = stat_max ? (TFloat(stat)) / TFloat(stat_max) : 0.; -// TFloat gw = pct * GAUGE_WIDTH; -// -// // fill area -// TRect fill(0, 0, TInt(gw), 8); -// fill.x1 += 2; -// fill.y1 += 2; -// fill.x2 -= 2; -// fill.y2 -= 2; -// if (fill.x2 < fill.x1) { -// fill.x2 = fill.x1 + 1; -// } -// fill.Offset(x, y); -// screen->FillRect(vp, fill, color); -} - -void GGameState::PostRender() { - GHud::Render(); - - if (mGameOver) { - mGameOver->Run(); - if (mGamePlayfield->MosaicActive()) { - delete mGameOver; - mGameOver = ENull; - } else { - return; - } - } - - if (mGamePlayfield->MosaicActive()) { - gControls.Reset(); - Pause(); - } - else if (mGamePlayfield->MosaicDone()) { - Resume(); - } - -#ifdef DEBUG_MODE - if (mTimer-- < 0) { - mTimer = FRAMES_PER_SECOND * 1; - sprintf(mText, "%s Level %d", mName, mLevel); - } - - if (mText[0]) { - gDisplay.renderBitmap->DrawString(gViewPort, mText, gFont8x8, 4, 4, COLOR_TEXT, COLOR_TEXT_TRANSPARENT); - } -#endif -} - -/******************************************************************************* - ******************************************************************************* - *******************************************************************************/ - -TUint16 GGameState::MapWidth() { - return (mGamePlayfield->MapWidthTiles() - gViewPort->mRect.Width() / 32) * 32; -} - -TUint16 GGameState::MapHeight() { - return (mGamePlayfield->MapHeightTiles() - gViewPort->mRect.Height() / 32) * 32; -} - -void GGameState::GameLoop() { - for (bool &s : mGamePlayfield->mGroupState) { - s = ETrue; - } - - BGameEngine::GameLoop(); - - for (TInt s = 0; s < 16; s++) { - if (mGamePlayfield->mGroupState[s] == ETrue) { - mGamePlayfield->mGroupDone[s] = ETrue; - } - } -} - -/******************************************************************************* - ******************************************************************************* - *******************************************************************************/ - -/** - * This is safe to call from BProcess context. - * - * @param aDungeon ID of dungeon (in gDungeonDefs) - * @param aLevel Level in dungeon - */ -void GGameState::NextLevel(const TInt16 aDungeon, const TInt16 aLevel) { - if (aDungeon == -1) { - // -1 means stay in the same dungeon - mNextDungeon = mDungeon; - - if (mNextDungeon != OVERWORLD_DUNGEON) { - if (aLevel > mLevel) { - // Going up - mPlayerToLoad = ATTR_PLAYER_IN1; - } - else if (aLevel < mLevel) { - // Going Down - mPlayerToLoad = ATTR_PLAYER_IN2; - } - } - } - else { - mNextDungeon = aDungeon; - mPlayerToLoad = ATTR_PLAYER_IN1; - } - - mNextLevel = aLevel; - strcpy(mName, gDungeonDefs[mNextDungeon].name); - mNextTileMapId = gDungeonDefs[mNextDungeon].mInfo.map[aLevel]; - mNextObjectsId = gDungeonDefs[mNextDungeon].mInfo.objectsId; - - if (!mGamePlayfield) { - mPlayfield = mGamePlayfield = new GGamePlayfield(gViewPort, mNextTileMapId); - } - sprintf(mText, "%s Level %d", mName, aLevel); -} - -void GGameState::SetPlayfieldXYFromPlayer(TFloat aPlayerX, TFloat aPlayerY) { - TFloat maxx = MapWidth(), - maxy = MapHeight(); - - // upper left corner of desired viewport position - TFloat xx = gViewPort->mWorldX = aPlayerX, - yy = gViewPort->mWorldY = aPlayerY; - - if (xx < 0) { - gViewPort->mWorldX = 0; - } - else if (xx > maxx) { - gViewPort->mWorldX = maxx; - } - if (yy < 0) { - gViewPort->mWorldY = 0; - } - else if (yy > maxy) { - gViewPort->mWorldY = maxy; - } -} - -/** - * This is NOT safe to call from BProcess context - */ -void GGameState::LoadLevel(const char *aName, const TInt16 aLevel, TUint16 aTileMapId, TBool aSpawnObjects) { -// mNextGamePlayfield = new GGamePlayfield(gViewPort, mNextTileMapId); -// -// strcpy(mName, aName); -// -// const TUint16 overworld_exit = mNextDungeon == OVERWORLD_DUNGEON ? mDungeon : OVERWORLD_DUNGEON; -// const TUint16 exiting_level = mLevel; -// TBool is_same_dungeon = (mDungeon != OVERWORLD_DUNGEON) && (mNextDungeon == mDungeon); -// -// if (mDungeon == OVERWORLD_DUNGEON) { -// mLastOverworldLevel = mLevel; -// } -// -// mLevel = mNextLevel = aLevel; -// mDungeon = mNextDungeon; -// mTileMapId = aTileMapId; -// -// Reset(); // remove sprites and processes -// InitRemapSlots(); -// mPlayfield = mGamePlayfield = mNextGamePlayfield; -// gDisplay.SetPalette(mGamePlayfield->GetTilesBitmap(), 0, 128); -// mNextGamePlayfield = ENull; -// GPlayer::mProcess = ENull; -// -// RemapSlot(mNextObjectsId, ENVIRONMENT_SLOT, IMAGE_32x32); -//// RemapSlot(CHARA_HERO_BMP, PLAYER_SLOT); -//// RemapSlot(CHARA_HERO_HEAL_EFFECT_BMP, PLAYER_HEAL_SLOT, IMAGE_32x32); -//// RemapSlot(CHARA_HERO_SPELL_EFFECT_BMP, PLAYER_SPELL_SLOT, IMAGE_32x32); -//// RemapSlot(SPELL_EARTH_BMP, SPELL_EARTH_SLOT, IMAGE_64x64); -//// RemapSlot(SPELL_ELECTRICITY_BMP, SPELL_ELECTRICITY_SLOT, IMAGE_64x64); -//// RemapSlot(SPELL_FIRE_BMP, SPELL_FIRE_SLOT, IMAGE_64x64); -//// RemapSlot(SPELL_WATER_BMP, SPELL_WATER_SLOT, IMAGE_64x64); -//// RemapSlot(ENEMY_DEATH_BMP, ENEMY_DEATH_SLOT, IMAGE_32x32); -// -// GPlayer::mProcess = new GPlayerProcess(this); -// AddProcess(GPlayer::mProcess); // -//#ifdef DEBUGME -// printf("Level loaded, colors used %d\n", mGamePlayfield->GetTilesBitmap()->CountUsedColors()); -//#endif +// Created by Michael Schwartz on 10/29/20. // -// TInt objectCount = mGamePlayfield->mObjectCount; -// BObjectProgram *program = mGamePlayfield->mObjectProgram; -// TInt eCount = 0; -// -// // Spikes operations -// // Reset spike group counter on level load -// memset(GSpikesProcess::mGroups, 0, sizeof(GSpikesProcess::mGroups)); -// TBool startedPlayer = EFalse; -// TInt spikesMatrix[70][70] = {{0}}; // max level size -// TInt16 spikeGroup = 1; -// -// // Set spikes matrix -// for (TInt ip = 0; ip < objectCount; ip++) { -// if ((program[ip].mCode & TUint32(0xffff)) == ATTR_SPIKES) { -// spikesMatrix[program[ip].mRow][program[ip].mCol] = spikeGroup; -// } -// } -// -// TInt16 spawnedBoss = -1; -// -// for (TInt ip = 0; ip < objectCount; ip++) { -//#ifdef DEBUGME -// printf("%5d: ", ip); -//#endif -// const TUint16 op = program[ip].mCode & TUint32(0xffff), -// params = program[ip].mCode >> TUint32(16), -// row = program[ip].mRow, -// col = program[ip].mCol; -// -// auto xx = TFloat(col * TILESIZE), -// yy = TFloat(row * TILESIZE); -// -// switch (op) { -// -// // -// // ENVIRONMENT -// // -// case ATTR_DUNGEON_EXIT_FROM_LEVEL_1: -//#ifdef DEBUGME -// printf("EXIT TO OVERWORLD at %.2f,%.2f %d,%d %d/%x\n", xx, yy, row, col, params, params); -//#endif -// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_RIGHT, " "); -// break; -// -// case ATTR_STONE_STAIRS_UP: -//#ifdef DEBUGME -// printf("STONE STAIRS UP at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_UP, "STONE"); -// break; -// -// case ATTR_OW_LEVEL_ENTRANCE: -//#ifdef DEBUGME -// printf("OVERWORLD LEVEL TRANSITION at %.2f,%.2f %d,%d %d/%x\n", xx, yy, row, col, params, params); -//#endif -// if (mDungeon == OVERWORLD_DUNGEON) { -// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_DOWN, "DUNGEON"); -// } -// -// break; -// -// case ATTR_STONE_STAIRS_DOWN: -//#ifdef DEBUGME -// printf("STONE STAIRS DOWN at %.2f,%.2f %d,%d %d/%x\n", xx, yy, row, col, params, params); -//#endif -// if (mDungeon == OVERWORLD_DUNGEON) { -// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_DOWN, "DUNGEON"); -// } -// else { -// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_DOWN, "STONE"); -// } -// break; -// -// case ATTR_WOOD_STAIRS_UP: -//#ifdef DEBUGME -// printf("WOOD STAIRS UP at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_UP, "WOOD"); -// break; -// -// case ATTR_WOOD_STAIRS_DOWN: -//#ifdef DEBUGME -// printf("WOOD STAIRS DOWN at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_DOWN, "WOOD"); -// break; -// -// case ATTR_POT: -//#ifdef DEBUGME -// printf("POT at %.2f,%.2f %d, %d\n", xx, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_DOWN, "POT"); -// break; -// -// case ATTR_POT_GONE: -//#ifdef DEBUGME -// printf("POT GONE at %.2f,%.2f %d, %d\n", xx, yy, row, col); -//#endif -// if (params) { -// GItemProcess::SpawnItem(this, ip, params, xx, yy + 32); -// } -// break; -// -// case ATTR_CHEST: -//#ifdef DEBUGME -// printf("CHEST CLOSED at %.2f,%.2f %d, %d\n", xx, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_DOWN, "CHEST"); -// break; -// -// case ATTR_CHEST_OPEN: -//#ifdef DEBUGME -// printf("CHEST OPEN at %.2f,%.2f %d,%d ATTR: %d\n", xx, yy, row, col, params); -//#endif -// GProcess::Spawn(this, op, ip, xx, yy, params, DIRECTION_DOWN, "CHEST"); -// break; -// -// case ATTR_SPIKES: -//#ifdef DEBUGME -// printf("SPIKES at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// // Check the surrounding tiles to the left and top for spikes -// // if there aren't any increment group counter and set all spike tiles to it -// if ( -// spikesMatrix[row-1][col] == 0 && -// spikesMatrix[row][col-1] == 0 && -// spikesMatrix[row-1][col-1] == 0 && -// spikesMatrix[row-1][col+1] == 0) -// { -// // Check adjecent node that wasn't processed yet, but could've been set -// if (spikesMatrix[row+1][col-1] == 0) { -// if (++spikeGroup > MAX_SPIKE_GROUPS) { -// Panic("Reached spike group limit!\n"); -// } -// } -// spikesMatrix[row][col] = spikeGroup; -// } -// -// if (spikesMatrix[row+1][col] > 0) spikesMatrix[row+1][col] = spikesMatrix[row][col]; -// if (spikesMatrix[row][col + 1] > 0) spikesMatrix[row][col+1] = spikesMatrix[row][col]; -// if (spikesMatrix[row+1][col + 1] > 0) spikesMatrix[row+1][col+1] = spikesMatrix[row][col]; -// if (spikesMatrix[row+1][col - 1] > 0) spikesMatrix[row+1][col-1] = spikesMatrix[row][col]; -// -// GProcess::Spawn(this, op, ip, xx, yy, spikesMatrix[row][col], DIRECTION_DOWN, "SPIKES"); -// break; -// -// case ATTR_METAL_GATE_H: -//#ifdef DEBUGME -// printf("METAL DOOR H at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx, yy + 30, params, DIRECTION_DOWN, "METAL DOOR HORIZONTAL"); -// break; -// -// case ATTR_METAL_GATE_V: -//#ifdef DEBUGME -// printf("METAL DOOR V at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx, yy + 30, params, DIRECTION_DOWN, "METAL DOOR VERTICAL"); -// break; -// -// case ATTR_WOOD_DOOR_H: -//#ifdef DEBUGME -// printf("WOOD DOOR H at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx, yy + 30, params, DIRECTION_DOWN, "WOOD DOOR HORIZONTAL"); -// break; -// -// case ATTR_WOOD_DOOR_V: -//#ifdef DEBUGME -// printf("WOOD DOOR V at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx, yy + 30, params, DIRECTION_DOWN, "WOOD DOOR VERTICAL"); -// break; -// -// case ATTR_LEVER: -//#ifdef DEBUGME -// printf("LEVER at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx, yy + 30, params, DIRECTION_DOWN, "LEVER"); -// break; -// -// case ATTR_FLOOR_SWITCH: -//#ifdef DEBUGME -// printf("FLOOR_SWITCH at %.2f,%.2f %d,%d params: %x\n", xx, yy, row, col, params); -//#endif -// GProcess::Spawn(this, op, ip, xx, yy + 32, params, DIRECTION_DOWN, "STONE FLOOR SWITCH"); -// break; -// -// case ATTR_FLOOR_SWITCH_WOOD: -//#ifdef DEBUGME -// printf("FLOOR_SWITCH at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx, yy + 32, params, DIRECTION_DOWN, "WOOD FLOOR SWITCH"); -// break; -// -// // -// // PLAYER -// // -// // This case is used for the player 1 entrance for dungeon levels AND overworld entrance auto-detection. -// case ATTR_PLAYER_IN1: -// if (!aSpawnObjects || mPlayerToLoad != ATTR_PLAYER_IN1) { -// break; -// } -//#ifdef DEBUGME -// printf("PLAYER IN1 at %.2f,%.2f\n", xx, yy); -//#endif -// if (mDungeon == OVERWORLD_DUNGEON) { -// GPlayer::mProcess->StartLevel(mGamePlayfield, xx - 16, yy + 32, overworld_exit, exiting_level); -// SetPlayfieldXYFromPlayer(xx - 16, yy + 32); -// } -// else { -// GPlayer::mProcess->StartLevel(mGamePlayfield, xx - 16, yy + 28, overworld_exit, exiting_level); -// SetPlayfieldXYFromPlayer(xx - 16, yy + 28); -// } -// startedPlayer = ETrue; -// break; -// -// // This case is used for the player 2 entrance for levels within dungeons only! -// case ATTR_PLAYER_IN2: -// if (mPlayerToLoad != ATTR_PLAYER_IN2) { -// break; -// } -//#ifdef DEBUGME -// printf("PLAYER IN2 at %.2f,%.2f\n", xx, yy); -//#endif -// GPlayer::mProcess->StartLevel(mGamePlayfield, xx - 16, yy + 32, overworld_exit, exiting_level); -// SetPlayfieldXYFromPlayer(xx - 16, yy - 32); -// -// startedPlayer = ETrue; -// break; -// -// // -// // ENEMIES -// // -// case ATTR_SPIDER: -// RemapSlot(CHARA_SPIDER_BMP, SPIDER_SLOT); -// -// if (!aSpawnObjects) { -// break; -// } -//#ifdef DEBUGME -// printf("SPIDER at %.2f,%.2f %d,%d\n", xx - 32, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx - 16, yy + 32, params, DIRECTION_DOWN, "ENEMY SPIDER"); -// break; -// -// case ATTR_BAT: -// RemapSlot(CHARA_BAT_BMP, BAT_SLOT); -// -//#ifdef DEBUGME -// printf("BAT at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx - 16, yy + 32, params, DIRECTION_DOWN, "ENEMY BAT"); -// break; -// -// case ATTR_GOBLIN: -// RemapSlot(CHARA_GOBLIN_BMP, GOBLIN_SLOT); -// if (!aSpawnObjects) { -// break; -// } -//#ifdef DEBUGME -// printf("GOBLIN at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx - 16, yy + 32, params, DIRECTION_DOWN, "ENEMY GOBLIN"); -// break; -// -// case ATTR_GOBLIN_SNIPER: -// RemapSlot(CHARA_GOBLIN_SNIPER_BMP, GOBLIN_SNIPER_SLOT); -// RemapSlot(PROJECTILE_ARROW_BMP, PROJECTILE_ARROW_SLOT, IMAGE_32x32); -// if (!aSpawnObjects) { -// break; -// } -//#ifdef DEBUGME -// printf("GOBLIN_SNIPER at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx - 16, yy + 32, params, DIRECTION_DOWN, "ENEMY GOBLIN SNIPER"); -// break; -// -// case ATTR_ORC: -// RemapSlot(CHARA_ORC_BMP, ORC_SLOT); -// if (!aSpawnObjects) { -// break; -// } -//#ifdef DEBUGME -// printf("ORC at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx - 16, yy + 32, params, DIRECTION_DOWN, "ENEMY ORC"); -// break; -// -// case ATTR_RAT: -// RemapSlot(CHARA_RAT_BMP, RAT_SLOT); -// -// if (!aSpawnObjects) { -// break; -// } -//#ifdef DEBUGME -// printf("RAT at %.2f,%.2f %d,%d,%d\n", xx, yy, row, col, eCount); -//#endif -// GProcess::Spawn(this, op, ip, xx - 16, yy + 32, params, DIRECTION_DOWN, "ENEMY RAT"); -// break; -// -// case ATTR_SLIME: -// RemapSlot(CHARA_SLIME_BMP, SLIME_SLOT); -// -// if (!aSpawnObjects) { -// break; -// } -//#ifdef DEBUGME -// printf("SLIME at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx - 16, yy + 31, params, DIRECTION_DOWN, "ENEMY SLIME"); -// break; -// -// case ATTR_TROLL: -// RemapSlot(CHARA_TROLL_BMP, TROLL_SLOT); -// -// if (!aSpawnObjects) { -// break; -// } -//#ifdef DEBUGME -// printf("TROLL at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx - 16, yy + 32, params, DIRECTION_DOWN, "ENEMY TROLL"); -// break; -// -// case ATTR_TURRET: -// RemapSlot(CRYSTAL_BMP, TURRET_SLOT, IMAGE_64x64); -// RemapSlot(PROJECTILE_CRYSTAL_BMP, PROJECTILE_CRYSTAL_SLOT, IMAGE_32x32); -// if (!aSpawnObjects) { -// break; -// } -//#ifdef DEBUGME -// printf("TURRET at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GProcess::Spawn(this, op, ip, xx - 16, yy + 32, params, DIRECTION_DOWN, "ENEMY TURRET"); -// break; -// -// // mid boss -// // only one mid boss can be available -// case ATTR_MID_BOSS_ENERGY: -//#ifdef DEBUGME -// printf("MID BOSS ENERGY at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// // always explosion (for any enemy) -// RemapSlot(MID_BOSS_DEATH_EXPLOSION_BMP, BOSS_DEATH_SLOT, IMAGE_64x64); -// // Sprite sheet for enemy -// RemapSlot(MID_BOSS_ENERGY_BMP, BOSS_SLOT, IMAGE_128x128); -// // Sprite sheet for enemy projectiles -// RemapSlot(MID_BOSS_ENERGY_PROJECTILE_BMP, BOSS_PROJECTILE_SLOT, IMAGE_32x32); -// -// if (!aSpawnObjects) { -// break; -// } -// GProcess::Spawn(this, op, ip, xx, yy + 64, params, DIRECTION_DOWN, "ENEMY MID BOSS ENERGY"); -// spawnedBoss = op; -// -// break; -// -// case ATTR_MID_BOSS_FIRE: -//#ifdef DEBUGME -// printf("MID BOSS FIRE at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// // always explosion (for any enemy) -// RemapSlot(MID_BOSS_DEATH_EXPLOSION_BMP, BOSS_DEATH_SLOT, IMAGE_64x64); -// // Sprite sheet for enemy -// RemapSlot(MID_BOSS_FIRE_BMP, BOSS_SLOT, IMAGE_128x128); -// // Sprite sheet for enemy projectiles -// RemapSlot(MID_BOSS_FIRE_PROJECTILE_BMP, BOSS_PROJECTILE_SLOT, IMAGE_32x32); -// -// if (!aSpawnObjects) { -// break; -// } -// GProcess::Spawn(this, op, ip, xx, yy + 64, params, DIRECTION_DOWN, "ENEMY MID BOSS FIRE"); -// spawnedBoss = op; -// -// break; -// -// case ATTR_MID_BOSS_EARTH: -//#ifdef DEBUGME -// printf("MID BOSS EARTH at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// // always explosion (for any enemy) -// RemapSlot(MID_BOSS_DEATH_EXPLOSION_BMP, BOSS_DEATH_SLOT, IMAGE_64x64); -// // Sprite sheet for enemy -// RemapSlot(MID_BOSS_EARTH_BROWN_BMP, BOSS_SLOT, IMAGE_128x128); -// // Sprite sheet for enemy projectiles -// RemapSlot(MID_BOSS_EARTH_PROJECTILE_BMP, BOSS_PROJECTILE_SLOT, IMAGE_32x32); -// -// if (!aSpawnObjects) { -// break; -// } -// GProcess::Spawn(this, op, ip, xx - 64, yy + 64, params, DIRECTION_DOWN, "ENEMY MID BOSS EARTH"); -// spawnedBoss = op; -// -// break; -// -// case ATTR_MID_BOSS_WATER: -//#ifdef DEBUGME -// printf("MID BOSS WATER at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// // always explosion (for any enemy) -// RemapSlot(MID_BOSS_DEATH_EXPLOSION_BMP, BOSS_DEATH_SLOT, IMAGE_64x64); -// // Sprite sheet for enemy -// RemapSlot(MID_BOSS_WATER_BMP, BOSS_SLOT, IMAGE_128x128); -// // Sprite sheet for enemy projectiles -// RemapSlot(MID_BOSS_WATER_PROJECTILE_BMP, BOSS_PROJECTILE_SLOT, IMAGE_32x32); -// -// if (!aSpawnObjects) { -// break; -// } -// GProcess::Spawn(this, op, ip, xx, yy + 64, params, DIRECTION_DOWN, "ENEMY MID BOSS WATER"); -// spawnedBoss = op; -// -// break; -// -// case ATTR_WIZARD_WATER: -//#ifdef DEBUGME -// printf("WATER WIZARD at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// // always explosion (for any enemy) -// RemapSlot(MID_BOSS_DEATH_EXPLOSION_BMP, BOSS_DEATH_SLOT, IMAGE_64x64); -// // Sprite sheet for enemy -// RemapSlot(WATER_WIZARD_BMP, BOSS_SLOT, IMAGE_64x64); -// // Sprite sheet for enemy projectiles -// RemapSlot(WATER_PROJECTILE_BMP, WATER_WIZARD_PROJECTILE_SLOT, IMAGE_32x32); -// RemapSlot(WATER_PILLAR_BMP, BOSS_PILLAR_SLOT, IMAGE_32x32); -// -// if (!aSpawnObjects) { -// break; -// } -// GProcess::Spawn(this, op, ip, xx, yy + 64, params, DIRECTION_DOWN, "ENEMY WATER WIZARD"); -// spawnedBoss = op; -// break; -// -// case ATTR_WIZARD_FIRE: -//#ifdef DEBUGME -// printf("FIRE WIZARD at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// // always explosion (for any enemy) -// RemapSlot(MID_BOSS_DEATH_EXPLOSION_BMP, BOSS_DEATH_SLOT, IMAGE_64x64); -// // Sprite sheet for enemy -// RemapSlot(FIRE_WIZARD_BMP, BOSS_SLOT, IMAGE_64x64); -// // Sprite sheet for enemy projectiles -// RemapSlot(FIRE_PROJECTILE_BMP, FIRE_WIZARD_PROJECTILE_SLOT, IMAGE_32x32); -// RemapSlot(FIRE_PILLAR_BMP, BOSS_PILLAR_SLOT, IMAGE_32x32); -// -// if (!aSpawnObjects) { -// break; -// } -// GProcess::Spawn(this, op, ip, xx, yy + 64, params, DIRECTION_DOWN, "ENEMY FIRE WIZARD"); -// spawnedBoss = op; -// -// break; -// -// case ATTR_WIZARD_ENERGY: -//#ifdef DEBUGME -// printf("ENERGY WIZARD at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// // always explosion (for any enemy) -// RemapSlot(MID_BOSS_DEATH_EXPLOSION_BMP, BOSS_DEATH_SLOT, IMAGE_64x64); -// // Sprite sheet for enemy -// RemapSlot(ENERGY_WIZARD_BMP, BOSS_SLOT, IMAGE_64x64); -// // Sprite sheet for enemy projectiles -// RemapSlot(ENERGY_PROJECTILE_BMP, ENERGY_WIZARD_PROJECTILE_SLOT, IMAGE_32x32); -// RemapSlot(ENERGY_PILLAR_BMP, BOSS_PILLAR_SLOT, IMAGE_32x32); -// -// if (!aSpawnObjects) { -// break; -// } -// GProcess::Spawn(this, op, ip, xx, yy + 64, params, DIRECTION_DOWN, "ENEMY ENERGY WIZARD"); -// spawnedBoss = op; -// -// break; -// -// case ATTR_WIZARD_EARTH: -//#ifndef DEBUG_FINALBOSS -//#ifdef DEBUGME -// printf("EARTH WIZARD at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// // always explosion (for any enemy) -// RemapSlot(MID_BOSS_DEATH_EXPLOSION_BMP, BOSS_DEATH_SLOT, IMAGE_64x64); -// // Sprite sheet for enemy -// RemapSlot(EARTH_WIZARD_BMP, BOSS_SLOT, IMAGE_64x64); -// // Sprite sheet for enemy projectiles -// RemapSlot(EARTH_PROJECTILE_BMP, EARTH_WIZARD_PROJECTILE_SLOT, IMAGE_32x32); -// RemapSlot(EARTH_PILLAR_BMP, BOSS_PILLAR_SLOT, IMAGE_32x32); -// -// if (!aSpawnObjects) { -// break; -// } -// GProcess::Spawn(this, op, ip, xx, yy + 64, params, DIRECTION_DOWN, "ENEMY EARTH WIZARD"); -// spawnedBoss = op; -// -// break; -//#endif -// -// case ATTR_FINAL_BOSS: -//#ifdef DEBUGME -// printf("FINAL BOSS at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// // always explosion (for any enemy) -// RemapSlot(MID_BOSS_DEATH_EXPLOSION_BMP, BOSS_DEATH_SLOT, IMAGE_64x64); -// // Sprite sheet for enemy -// RemapSlot(DRAGANOS_BMP, BOSS_SLOT, IMAGE_128x128); -// // Sprite sheets for enemy projectiles -// // Final Boss fires all the Wizard projectiles -// RemapSlot(ENERGY_PROJECTILE_BMP, ENERGY_FINAL_BOSS_PROJECTILE_SLOT, IMAGE_32x32); -// RemapSlot(ENERGY_PILLAR_BMP, ENERGY_FINAL_BOSS_PILLAR_SLOT, IMAGE_32x32); -// -// RemapSlot(EARTH_PROJECTILE_BMP, EARTH_FINAL_BOSS_PROJECTILE_SLOT, IMAGE_32x32); -// RemapSlot(EARTH_PILLAR_BMP, EARTH_FINAL_BOSS_PILLAR_SLOT, IMAGE_32x32); -// -// RemapSlot(WATER_PROJECTILE_BMP, WATER_FINAL_BOSS_PROJECTILE_SLOT, IMAGE_32x32); -// RemapSlot(WATER_PILLAR_BMP, WATER_FINAL_BOSS_PILLAR_SLOT, IMAGE_32x32); -// -// RemapSlot(FIRE_PROJECTILE_BMP, FIRE_FINAL_BOSS_PROJECTILE_SLOT, IMAGE_32x32); -// RemapSlot(FIRE_PILLAR_BMP, FIRE_FINAL_BOSS_PILLAR_SLOT, IMAGE_32x32); -// -// if (!aSpawnObjects) { -// break; -// } -// GProcess::Spawn(this, op, ip, xx, yy + 64, params, DIRECTION_DOWN, "FINAL BOSS"); -// spawnedBoss = op; -// -// break; -// -// // Spawn potions, heart -// case ATTR_SPAWN_SMALL_HEALTH: -//#ifdef DEBUGME -// printf("SMALL HEALTH at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GItemProcess::SpawnItem(this, ip, ITEM_RED_POTION1, xx, yy + 32); -// break; -// -// case ATTR_SPAWN_LARGE_HEALTH: -//#ifdef DEBUGME -// printf("LARGE HEALTH at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GItemProcess::SpawnItem(this, ip, ITEM_RED_POTION2, xx, yy + 32); -// break; -// -// case ATTR_SPAWN_SMALL_MANA: -//#ifdef DEBUGME -// printf("SMALL MANA at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GItemProcess::SpawnItem(this, ip, ITEM_BLUE_POTION1, xx, yy + 32); -// break; -// -// case ATTR_SPAWN_LARGE_MANA: -//#ifdef DEBUGME -// printf("LARGE MANA at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GItemProcess::SpawnItem(this, ip, ITEM_BLUE_POTION2, xx, yy + 32); -// break; -// -// case ATTR_SPAWN_HEART: -//#ifdef DEBUGME -// printf("HEART at %.2f,%.2f %d,%d\n", xx, yy, row, col); -//#endif -// GItemProcess::SpawnItem(this, ip, ITEM_HEART, xx, yy + 32); -// break; -// -// -// default: -// printf("======== > Invalid op code in Object Program: $%0x at col,row %d,%d\n", program[ip].mCode, col, row); -// break; -// } -// } -// if (!startedPlayer) { -// printf("NO PLAYER at %.2f,%.2f\n", 32., 64.); -// GPlayer::mProcess->StartLevel(mGamePlayfield, 32., 64. + 32); -// } -// -// PlayLevelMusic(mNextDungeon, spawnedBoss); -// -// -// mGamePlayfield->StartMosaicIn(); -} -TBool GGameState::PlayMusicForCurrentLevel() { - return PlayLevelMusic(mDungeon, -1); -} - -TBool GGameState::PlayLevelMusic(TInt16 aNextDungeon, TInt16 aSpawnedBoss) { - - TUint16 song = EMPTYSONG_XM; - printf("aNextDungeon = %i\n", aNextDungeon); - // For levels -- bosses get their own treatment! -// if (aSpawnedBoss == -1) { -// if (aNextDungeon == 0) { -// song = OVERWORLD_XM; -// } -// else if (aNextDungeon == 1) { -// song = DUNGEON_HOME_XM; -// } -// else if (aNextDungeon >= 2 && aNextDungeon <= 4) { -// song = DUNGEON1_XM; -// } -// else if (aNextDungeon >= 13 && aNextDungeon <= 18) { -// song = DUNGEON4_XM; -// } -// else if (aNextDungeon >= 36 && aNextDungeon <= 40) { -// song = DUNGEON9_XM; -// } -// } -// else { -// if (aSpawnedBoss == ATTR_MID_BOSS_WATER || aSpawnedBoss == ATTR_MID_BOSS_ENERGY || aSpawnedBoss == ATTR_MID_BOSS_EARTH || aSpawnedBoss == ATTR_MID_BOSS_FIRE) { -// song = BOSS_1_XM; -// } -// else if (aSpawnedBoss == ATTR_WIZARD_ENERGY || aSpawnedBoss == ATTR_WIZARD_WATER || aSpawnedBoss == ATTR_WIZARD_EARTH || aSpawnedBoss == ATTR_WIZARD_FIRE) { -// song = BOSS_2_XM; -// } else { -// song = BOSS_3_XM; -// } -// } - - - //gSoundPlayer.PlayMusic(song); - - return ETrue; -} -/** - * modify BObjectProgram, like when a door or chest has opened. - * - * aCode is the code to change the program step to, OR ATTR_KEEP to leave the code in the BObjectProgram unchanged. - * aAttr is the attribute to change the program step to, OR ATTR_KEEP - */ -void GGameState::EndProgram(TInt aIp, TUint16 aCode, TUint16 aAttr) { - BObjectProgram *program = mGamePlayfield->mObjectProgram, - *step = &program[aIp]; - - TUint32 code = aCode, - attr = aAttr, - sCode = step->mCode; - - if (aCode == ATTR_KEEP) { - if (aAttr == ATTR_KEEP) { - // keep both? Nothing to do! - return; - } - step->mCode = LOWORD(sCode) | (attr << 16); - } - else if (aAttr == ATTR_KEEP) { - step->mCode = (sCode & 0xffff0000) | (attr << 16); - } - else { - TUint32 new_code = code | (attr << 16); - step->mCode = new_code; - } - printf("EndProgram %p (%08x -> %08x)\n", program, sCode, step->mCode); -} - -/******************************************************************************* - ******************************************************************************* - *******************************************************************************/ - -void GGameState::GameOver() { - mGameOver = new GGameOver(this); - //gSoundPlayer.PlayMusic(GAMEOVER_XM); - //gSoundPlayer.TriggerSfx(SFX_PLAYER_DEATH_WAV); - gControls.Reset(); - GPlayer::mGameOver = ETrue; -} - -/******************************************************************************* - ******************************************************************************* - *******************************************************************************/ +#include "GGameState.h" +#include "GGamePlayfield.h" -void GGameState::InitRemapSlots() { - for (TInt i = 2; i < SLOT_MAX; i++) { - if (i == TILESET_SLOT) { - // do not release TILESET - continue; - } - if (mSlotRemapState[i]) { - if (gResourceManager.GetBitmap(i)) { - printf("Releasing slot %d\n", i); - gResourceManager.ReleaseBitmapSlot(i); - } - } - mSlotRemapState[i] = EFalse; +GGameState::GGameState() : BGameEngine(gViewPort) { + mPlayfield = new GGamePlayfield(); + // set colors + 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(COLOR_STAR, 255,255,255); } -// Load aBMP, and remap it to playfield's tilemap palette -void GGameState::RemapSlot(TUint16 aBMP, TUint16 aSlot, TInt16 aImageSize) { - if (aSlot == TILESET_SLOT) { - Panic("Attempt to RemapSlot(TILESET_SLOT)\n"); - } - if (mSlotRemapState[aSlot]) { - return; - } - - gResourceManager.LoadBitmap(aBMP, aSlot, aImageSize); - - BBitmap *screen = mGamePlayfield->GetTilesBitmap(); - BBitmap *bm = gResourceManager.GetBitmap(aSlot); - if (!mSlotRemapState[aSlot]) { - bm->Remap(screen); - mSlotRemapState[aSlot] = ETrue; -#ifdef DEBUGME - printf("Remapped bitmap %d to slot %d, screen colors used %d\n", aBMP, aSlot, screen->CountUsedColors()); -#endif - } - gDisplay.SetPalette(screen->GetPalette(), 0, screen->CountUsedColors()); +GGameState::~GGameState() { +// delete mPlayfield; } -TBool GGameState::SaveState() { - printf("\n======= BEGIN %s =======\n", __FUNCTION__); - printf("\n-------- END %s--------\n", __FUNCTION__); - return ETrue; -} - -TBool GGameState::LoadState(const char *aGameName) { - return ETrue; -} diff --git a/Evade2/src/GameState/GGameState.h b/Evade2/src/GameState/GGameState.h index e55958f..73b10bb 100644 --- a/Evade2/src/GameState/GGameState.h +++ b/Evade2/src/GameState/GGameState.h @@ -1,128 +1,19 @@ -#ifndef MODITE_GGAMESTATE_H -#define MODITE_GGAMESTATE_H +// +// Created by Michael Schwartz on 10/29/20. +// -#define TILES_WIDE 10 -#define TILES_HIGH 7 +#ifndef EVADE2_GGAMESTATE_H +#define EVADE2_GGAMESTATE_H -#define ENABLE_REMAP_SLOTS -//#undef ENABLE_REMAP_SLOTS - -//#include "Game.h" -#include "GResources.h" -#include "GGamePlayfield.h" - -class GAnchorSprite; -class GProcess; -class GGamePlayfield; - -// Message Types -static TUint16 MESSAGE_FLOOR_SWITCH_DOWN = 0; -static TUint16 MESSAGE_FLOOR_SWITCH_UP = MESSAGE_FLOOR_SWITCH_DOWN + 1; - -const TInt16 OVERWORLD_DUNGEON = 0; - -const TInt TARGET_PAN_DURATION = 0.8 * FRAMES_PER_SECOND; - -//#include "GPlayerProcess.h" - -struct TDungeonInfo { - const char *name; - struct { - TInt16 objectsId; - TInt16 map[11]; - } mInfo; -}; -extern TDungeonInfo gDungeonDefs[]; -extern const TInt NUM_DUNGEONS; - -class GGameOver; +#include class GGameState : public BGameEngine { public: - // game engine GGameState(); - - // game engine loads saved game - EXPLICIT GGameState(const char *aName); - - ~GGameState() OVERRIDE; - - void Init(); - + ~GGameState(); public: - void GameLoop() OVERRIDE; - - void PreRender() OVERRIDE; - - void PositionCamera() OVERRIDE; - - void PostRender() OVERRIDE; - - void NextLevel(const TInt16 aDungeon, const TInt16 aLevel); - - void LoadLevel(const char *aName, const TInt16 aLevel, TUint16 aTileMapId, TBool aNewLevel = ETrue); - - void SetPlayfieldXYFromPlayer(TFloat aPlayerX, TFloat aPlayerY); - TBool PlayMusicForCurrentLevel(); - TBool SaveState(); - - TBool LoadState(const char *aGameName); - -public: - GProcess *AddProcess(GProcess *p); - - // call this to resume game after death - void TryAgain(TBool aExitDungeon); - - // call this when player is dead - void GameOver(); - - // store code and attr into ObjectProgram at aIp - void EndProgram(TInt aIp, TUint16 aCode = ATTR_GONE, TUint16 aAttr = 0); - - TUint16 MapWidth(); - - TUint16 MapHeight(); - - TBool IsBossRoom(); - -public: - GGamePlayfield *mGamePlayfield, *mNextGamePlayfield; - -public: - TBool IsGameOver() { return mGameOver != ENull; } - TInt16 Dungeon() { return mDungeon; } - TInt16 IsCurrentLevel(TUint16 aDungeon, TInt16 aLevel) { return mNextDungeon == aDungeon && mLevel == aLevel; } - TInt16 LastOverworldLevel() { return mLastOverworldLevel; } - TBool PlayLevelMusic(TInt16 aNextDungeon, TInt16 aSpawnedBoss); -protected: - TInt mTimer, mCameraTimer; - char mText[128]; - char mName[128]; - TInt16 mNextLevel, mLevel, mNextObjectsId, mLastOverworldLevel; - TUint16 mDungeon, mNextDungeon, mNextTileMapId, mTileMapId; - TUint16 mPlayerToLoad; - GGameOver *mGameOver; -#ifdef ENABLE_REMAP_SLOTS -protected: - // If the value for the slot is ETrue, then the slot - // has already been remapped. We don't want to remap twice or the color range - // ends up in the wrong place. - TBool mSlotRemapState[SLOT_MAX]; -protected: - /** - * Load bmp and remap it to the specified color range, and set the palette colors in gDisplay - * - * @param aBMP - * @param aSlot - * @param aPalette - * @param aColors - */ - void RemapSlot(TUint16 aBMP, TUint16 aSlot, TInt16 aImageSize = IMAGE_64x64); - - void InitRemapSlots(); -#endif - +// void GameLoop() OVERRIDE; }; -#endif //MODITE_GGAMESTATE_H + +#endif //EVADE2_GGAMESTATE_H diff --git a/Evade2/src/GameState/GProcess.cpp b/Evade2/src/GameState/GProcess.cpp deleted file mode 100644 index aa921d9..0000000 --- a/Evade2/src/GameState/GProcess.cpp +++ /dev/null @@ -1,128 +0,0 @@ -#include "GProcess.h" - - - -// DEBUG_FINALBOSS causes wizard span to be final boss spawn instead, to debug the final boss -#define DEBUG_FINALBOSS -#undef DEBUG_FINALBOSS - -void GProcess::WriteToStream(BMemoryStream &aStream) { -// aStream.Write(&mAttribute, sizeof(mAttribute)); -// WriteCustomToStream(aStream); // write additional data, if any -// mSprite->WriteToStream(aStream); -} - -void GProcess::ReadFromStream(BMemoryStream &aStream) { - // we assume mAttribute was already read in -// ReadCustomFromStream(aStream); -// mSprite->ReadFromStream(aStream); -} - -GProcess *GProcess::Spawn(GGameState *aGameState, TInt16 mAttribute, TInt aIp, TFloat aX, TFloat aY, TUint16 aParams) { - TInt ip = aIp; - TFloat xx = aX, - yy = aY; - TUint16 params = aParams; - - switch (mAttribute) { - case ATTR_GONE: - default: - return ENull; -// -// case ATTR_DUNGEON_EXIT_FROM_LEVEL_1: -// return aGameState->AddProcess(new GOverworldLevelTransitionProcess(aGameState, ip, DIRECTION_RIGHT, params, xx, yy, " ")); -// -// case ATTR_STONE_STAIRS_UP: -// return aGameState->AddProcess(new GStairsProcess(aGameState, ip, DIRECTION_UP, aParams, xx, yy, "STONE")); -// -// case ATTR_OW_LEVEL_ENTRANCE: -// return aGameState->AddProcess(new GOverworldLevelTransitionProcess(aGameState, ip, DIRECTION_DOWN, params, xx, yy, "OVERWORLD")); -// -// case ATTR_STONE_STAIRS_DOWN: -// if (!strcasecmp(aName, "DUNGEON")) { -// return aGameState->AddProcess(new GStairsProcess(aGameState, ip, DIRECTION_DOWN, params, xx, yy, "DUNGEON")); -// } -// else { -// return aGameState->AddProcess(new GStairsProcess(aGameState, ip, DIRECTION_DOWN, params, xx, yy, "STONE")); -// } -// -// case ATTR_WOOD_STAIRS_UP: -// return aGameState->AddProcess(new GStairsProcess(aGameState, ip, DIRECTION_UP, aParams, xx, yy, "WOOD")); -// -// case ATTR_WOOD_STAIRS_DOWN: -// return aGameState->AddProcess(new GStairsProcess(aGameState, ip, DIRECTION_DOWN, aParams, xx, yy, "WOOD")); -// -// case ATTR_POT: -// return aGameState->AddProcess(new GPotProcess(aGameState, ip, params, xx, yy)); -// -// case ATTR_POT_GONE: -// break; -// -// case ATTR_CHEST: -// return aGameState->AddProcess(new GChestProcess(aGameState, ip, params, xx, yy, EFalse)); -// case ATTR_CHEST_OPEN: -// return aGameState->AddProcess(new GChestProcess(aGameState, ip, params, xx, yy, ETrue)); -// case ATTR_SPIKES: -// return aGameState->AddProcess(new GSpikesProcess(aGameState, ip, xx, yy, params)); -// case ATTR_WOOD_DOOR_H: -// return aGameState->AddProcess(new GDoorProcess(aGameState, ip, params, xx, yy, ETrue, ETrue)); -// case ATTR_WOOD_DOOR_V: -// return aGameState->AddProcess(new GDoorProcess(aGameState, ip, params, xx, yy, ETrue, EFalse)); -// case ATTR_METAL_GATE_H: -// return aGameState->AddProcess(new GDoorProcess(aGameState, ip, params, xx, yy, EFalse, ETrue)); -// case ATTR_METAL_GATE_V: -// return aGameState->AddProcess(new GDoorProcess(aGameState, ip, params, xx, yy, EFalse, EFalse)); -// case ATTR_LEVER: -// return aGameState->AddProcess(new GLeverProcess(aGameState, ip, params, xx, yy)); -// case ATTR_FLOOR_SWITCH: -// return aGameState->AddProcess(new GFloorSwitchProcess(aGameState, ip, params, xx, yy, EFalse)); -// case ATTR_FLOOR_SWITCH_WOOD: -// return aGameState->AddProcess(new GFloorSwitchProcess(aGameState, ip, params, xx, yy, ETrue)); -// case ATTR_PLAYER_IN1: -// // ignore -// break; -// case ATTR_SPIDER: -// return aGameState->AddProcess(new GSpiderProcess(aGameState, ip, xx, yy, params)); -// case ATTR_BAT: -// return aGameState->AddProcess(new GBatProcess(aGameState, ip, xx, yy, params)); -// case ATTR_GOBLIN: -// return aGameState->AddProcess(new GGoblinProcess(aGameState, ip, xx, yy, params)); -// case ATTR_GOBLIN_SNIPER: -// return aGameState->AddProcess(new GGoblinSniperProcess(aGameState, ip, xx, yy, params)); -// case ATTR_TURRET: -// return aGameState->AddProcess(new GTurretProcess(aGameState, ip, xx, yy, params)); -// case ATTR_ORC: -// return aGameState->AddProcess(new GOrcProcess(aGameState, ip, xx, yy, params)); -// case ATTR_RAT: -// return aGameState->AddProcess(new GRatProcess(aGameState, ip, xx, yy, params)); -// case ATTR_SLIME: -// return aGameState->AddProcess(new GSlimeProcess(aGameState, ip, xx, yy, params)); -// case ATTR_TROLL: -// return aGameState->AddProcess(new GTrollProcess(aGameState, ip, xx, yy, params)); -// -// // mid bosses -// case ATTR_MID_BOSS_ENERGY: -// return aGameState->AddProcess(new GMidBossGenericProcess(aGameState, xx, yy, BOSS_SLOT, ip, ATTR_MID_BOSS_ENERGY, params, MID_BOSS_ENERGY_BMP_SPRITES)); -// case ATTR_MID_BOSS_FIRE: -// return aGameState->AddProcess(new GMidBossGenericProcess(aGameState, xx, yy, BOSS_SLOT, ip, ATTR_MID_BOSS_FIRE, params, MID_BOSS_FIRE_BMP_SPRITES)); -// case ATTR_MID_BOSS_EARTH: -// return aGameState->AddProcess(new GMidBossGenericProcess(aGameState, xx, yy, BOSS_SLOT, ip, ATTR_MID_BOSS_EARTH, params, MID_BOSS_EARTH_BROWN_BMP_SPRITES)); -// case ATTR_MID_BOSS_WATER: -// return aGameState->AddProcess(new GMidBossGenericProcess(aGameState, xx, yy, BOSS_SLOT, ip, ATTR_MID_BOSS_WATER, params, MID_BOSS_WATER_BMP_SPRITES)); -// -// // wizards -// case ATTR_WIZARD_ENERGY: -// return aGameState->AddProcess(new GWizardProcess(aGameState, xx, yy, BOSS_SLOT, ip, ATTR_WIZARD_ENERGY, params, ENERGY_WIZARD_BMP_SPRITES)); -// case ATTR_WIZARD_FIRE: -// return aGameState->AddProcess(new GWizardProcess(aGameState, xx, yy, BOSS_SLOT, ip, ATTR_WIZARD_FIRE, params, FIRE_WIZARD_BMP_SPRITES)); -// case ATTR_WIZARD_WATER: -// return aGameState->AddProcess(new GWizardProcess(aGameState, xx, yy, BOSS_SLOT, ip, ATTR_WIZARD_WATER, params, WATER_WIZARD_BMP_SPRITES)); -// case ATTR_WIZARD_EARTH: -//#ifndef DEBUG_FINALBOSS -// return aGameState->AddProcess(new GWizardProcess(aGameState, xx, yy, BOSS_SLOT, ip, ATTR_WIZARD_EARTH, params, EARTH_WIZARD_BMP_SPRITES)); -//#endif -// case ATTR_FINAL_BOSS: -// return aGameState->AddProcess(new GFinalBossProcess(aGameState, xx, yy, ip, params)); - } - return ENull; -} diff --git a/Evade2/src/GameState/player/GPlayer.cpp b/Evade2/src/GameState/player/GPlayer.cpp deleted file mode 100644 index 83e439e..0000000 --- a/Evade2/src/GameState/player/GPlayer.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "Game.h" -#include "GPlayer.h" - -TInt16 GPlayer::mHitPoints; -TInt16 GPlayer::mMaxHitPoints; -TBool GPlayer::mInvulnerable; - -TBool GPlayer::mGameOver; - -GPlayerProcess *GPlayer::mProcess; -GPlayerSprite *GPlayer::mSprite; -GGameState *GPlayer::mGameState; -GBossProcess *GPlayer::mActiveBoss; - -void GPlayer::WriteToStream(BMemoryStream &stream) { -} - -void GPlayer::ReadFromStream(BMemoryStream &stream) { -} - -void GPlayer::Dump() { - printf("GPlayer\n"); -} - -TUint16 GPlayer::GetSpellSlot() { - return 0; -} diff --git a/Evade2/src/GameState/player/GPlayer.h b/Evade2/src/GameState/player/GPlayer.h deleted file mode 100644 index 2e66a74..0000000 --- a/Evade2/src/GameState/player/GPlayer.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * GPlayer - * - * Contains player info like experience, strength, gold, inventory, etc. - */ -#ifndef MODITE_GPLAYER_H -#define MODITE_GPLAYER_H - -class GPlayerProcess; -class GBossProcess; - -#include -#include -#include "GGame.h" -#include "GGameState.h" -#include "GPlayerSprite.h" -#include "GAnchorSprite.h" -#include "GResources.h" -#include "GStatProcess.h" -#include "GSoundPlayer.h" - -const TInt DEFAULT_PLAYER_HITPOINTS = 200; - - -struct GPlayer { - static void Init() { - printf("Init GPlayer\n"); - mMaxHitPoints = DEFAULT_PLAYER_HITPOINTS; - mHitPoints = mMaxHitPoints; - mInvulnerable = EFalse; - - // - mGameOver = EFalse; - mActiveBoss = ENull; - } - - - - static void WriteToStream(BMemoryStream &stream); - static void ReadFromStream(BMemoryStream &stream); - static TUint16 GetSpellSlot(); - - static TInt16 mHitPoints, mMaxHitPoints; - static TBool mInvulnerable; - static GPlayerProcess *mProcess; - static GPlayerSprite *mSprite; - static GGameState *mGameState; - static TBool mGameOver; - static GBossProcess *mActiveBoss; - - static void Dump(); -}; - -#endif //MODITE_GPLAYER_H diff --git a/Evade2/src/GameState/GVectorSprite.cpp b/Evade2/src/common/GVectorSprite.cpp similarity index 74% rename from Evade2/src/GameState/GVectorSprite.cpp rename to Evade2/src/common/GVectorSprite.cpp index f4b023e..4246350 100644 --- a/Evade2/src/GameState/GVectorSprite.cpp +++ b/Evade2/src/common/GVectorSprite.cpp @@ -1,5 +1,5 @@ #include "GVectorSprite.h" -#include "Camera.h" +#include "GCamera.h" TBool GVectorSprite::ExplodeVectorGraphic(const TInt8 *graphic, TFloat x, TFloat y, @@ -7,7 +7,7 @@ TBool GVectorSprite::ExplodeVectorGraphic(const TInt8 *graphic, TFloat x, TFloat graphic += 2; TBool drawn = false; - TInt8 numRows = pgm_read_byte(graphic++); + TInt8 numRows = *graphic++; TFloat rad = TFloat(theta) * PI / 180, sint = sin(rad), cost = cos(rad); @@ -23,9 +23,6 @@ TBool GVectorSprite::ExplodeVectorGraphic(const TInt8 *graphic, TFloat x, TFloat x1 = seg.x1; y1 = seg.y1; -// printf("Row %i : [%i][%i] [%i][%i]\n", i, (TInt16)x0, (TInt16)y0, (TInt16)x1, (TInt16)y1); -// scaleFactor = 1; - if (scaleFactor) { x0 /= scaleFactor; y0 /= scaleFactor; @@ -68,18 +65,18 @@ TBool GVectorSprite::ExplodeVectorGraphic(const TInt8 *graphic, TFloat x, TFloat } TBool GVectorSprite::Render(BViewPort *aViewPort) { - if (!mLines || mZ <= Camera::mZ) { + if (!mLines || mZ <= GCamera::mZ) { // nothing to draw return EFalse; } - TFloat zz = (mZ - Camera::mZ) * 2; + TFloat zz = (mZ - GCamera::mZ) * 2; TFloat ratio = 128 / (zz + 128); bool isEnemy = Type() == OTYPE_ENEMY; // printf("is enemy = %i\n", isEnemy); - TFloat cx = (Camera::mX - mX) * ratio + SCREEN_WIDTH / 2; - TFloat cy = (Camera::mY - mY) * ratio + SCREEN_HEIGHT / 2; + TFloat cx = (GCamera::mX - mX) * ratio + SCREEN_WIDTH / 2; + TFloat cy = (GCamera::mY - mY) * ratio + SCREEN_HEIGHT / 2; // uint8_t color = isEnemy ? 5 : 255; @@ -91,17 +88,17 @@ TBool GVectorSprite::Render(BViewPort *aViewPort) { if ((!drawn) && isEnemy) { // draw radar blip - TFloat dx = Camera::mX - mX, - dy = Camera::mY - mY, + TFloat dx = GCamera::mX - mX, + dy = GCamera::mY - mY, angle = atan2(dy, dx); - printf("TODO: Fill Circle for enemy radar\n"); -// Gfx::FillCircle( -// (int16_t)(SCREEN_WIDTH / 2 + cos(angle) * 75), -// (int16_t)(SCREEN_HEIGHT / 2 + sin(angle) * 75), -// 3, -// EBULLET_COLOR -// ); +// printf("TODO: Fill Circle for enemy radar\n"); + aViewPort->FillCircle(gDisplay.renderBitmap, + (int16_t)(SCREEN_WIDTH / 2 + cos(angle) * 75), + (int16_t)(SCREEN_HEIGHT / 2 + sin(angle) * 75), + 3, + EBULLET_COLOR + ); } } @@ -111,5 +108,5 @@ TBool GVectorSprite::Render(BViewPort *aViewPort) { TBool GVectorSprite::BehindCamera() { - return mZ <= Camera::mZ; + return mZ <= GCamera::mZ; } \ No newline at end of file diff --git a/Evade2/src/GameState/GVectorSprite.h b/Evade2/src/common/GVectorSprite.h similarity index 97% rename from Evade2/src/GameState/GVectorSprite.h rename to Evade2/src/common/GVectorSprite.h index cadd0c8..94546fa 100644 --- a/Evade2/src/GameState/GVectorSprite.h +++ b/Evade2/src/common/GVectorSprite.h @@ -3,6 +3,7 @@ #include "BSprite.h" #include "GResources.h" +#include "Game.h" struct vec_segment_u8 { TInt8 x0; @@ -40,7 +41,7 @@ class GVectorSprite : public BSprite { TBool Render(BViewPort *aViewPort) OVERRIDE; - void Animate() OVERRIDE { + void Move() OVERRIDE { mX += mVX; mY += mVY; mZ += mVZ; diff --git a/Evade2/src/main.cpp b/Evade2/src/main.cpp deleted file mode 100644 index 7984956..0000000 --- a/Evade2/src/main.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "Game.h" - -BViewPort *gViewPort; -BGameEngine *gGameEngine; -TOptions *gOptions; -GGame *gGame; - -// app_main -extern "C" void app_main() { - gGame = new GGame(); - gGame->Run(); - delete gGame; -} - -#ifndef __XTENSA - -int main() { - app_main(); - return 0; -} - -#endif -