Skip to content

Commit

Permalink
Merge pull request jaygarcia#1 from ModusCreateOrg/work
Browse files Browse the repository at this point in the history
starfield works
  • Loading branch information
mschwartz authored Nov 1, 2020
2 parents 94deee5 + ec33dfb commit bb9e048
Show file tree
Hide file tree
Showing 128 changed files with 1,809 additions and 2,280 deletions.
52 changes: 26 additions & 26 deletions Evade2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -376,3 +377,4 @@ void GAnchorSprite::Dump() {
printf("%-16.16s: %d\n", "flags", flags);
printf("\n");
}
#endif
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef MODITE_GANCHORSPRITE_H
#define MODITE_GANCHORSPRITE_H

#if 0
#include <BAnimSprite.h>
#include <BMemoryStream.h>
#include "Game.h"
Expand Down Expand Up @@ -151,4 +152,6 @@ class GAnchorSprite : public BAnimSprite {
char mName[64];
};

#endif

#endif // MODITE_GANCHORSPRITE_H
25 changes: 25 additions & 0 deletions Evade2/old/GameState/GGamePlayfield.cpp
Original file line number Diff line number Diff line change
@@ -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();
}

256 changes: 256 additions & 0 deletions Evade2/old/GameState/GGamePlayfield.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
#ifndef EVADE2_GGAMEPLAYFIELD_H
#define EVADE2_GGAMEPLAYFIELD_H

//#include "Game.h"

#include <CreativeEngine.h>

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<mObjectCount; i++) {
mObjectProgram[i].Dump(i);
}
}

void DumpMap();
void DumpMapAttributes();

public:
TUint16 GetAttribute(TFloat aWorldX, TFloat aWorldY) {
return TUint16(GetCell(aWorldX, aWorldY) >> 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
Loading

0 comments on commit bb9e048

Please sign in to comment.