feat: add Pocket Dungeon game prototype
Main / Build (BookPlayer) (push) Has been cancelled
Main / Build (Brainfuck) (push) Has been cancelled
Main / Build (Breakout) (push) Has been cancelled
Main / Build (Calculator) (push) Has been cancelled
Main / Build (Diceware) (push) Has been cancelled
Main / Build (EpubReader) (push) Has been cancelled
Main / Build (GPIO) (push) Has been cancelled
Main / Build (GraphicsDemo) (push) Has been cancelled
Main / Build (HelloWorld) (push) Has been cancelled
Main / Build (M5UnitTest) (push) Has been cancelled
Main / Build (Magic8Ball) (push) Has been cancelled
Main / Build (MediaKeys) (push) Has been cancelled
Main / Build (MystifyDemo) (push) Has been cancelled
Main / Build (SerialConsole) (push) Has been cancelled
Main / Build (Snake) (push) Has been cancelled
Main / Build (TamaTac) (push) Has been cancelled
Main / Build (TodoList) (push) Has been cancelled
Main / Build (TwoEleven) (push) Has been cancelled
Main / Bundle (push) Has been cancelled
Main / Build (BookPlayer) (push) Has been cancelled
Main / Build (Brainfuck) (push) Has been cancelled
Main / Build (Breakout) (push) Has been cancelled
Main / Build (Calculator) (push) Has been cancelled
Main / Build (Diceware) (push) Has been cancelled
Main / Build (EpubReader) (push) Has been cancelled
Main / Build (GPIO) (push) Has been cancelled
Main / Build (GraphicsDemo) (push) Has been cancelled
Main / Build (HelloWorld) (push) Has been cancelled
Main / Build (M5UnitTest) (push) Has been cancelled
Main / Build (Magic8Ball) (push) Has been cancelled
Main / Build (MediaKeys) (push) Has been cancelled
Main / Build (MystifyDemo) (push) Has been cancelled
Main / Build (SerialConsole) (push) Has been cancelled
Main / Build (Snake) (push) Has been cancelled
Main / Build (TamaTac) (push) Has been cancelled
Main / Build (TodoList) (push) Has been cancelled
Main / Build (TwoEleven) (push) Has been cancelled
Main / Bundle (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
#include <GameKitGrid.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace PocketDungeon {
|
||||
|
||||
static constexpr uint8_t DUNGEON_COLS = 9;
|
||||
static constexpr uint8_t DUNGEON_ROWS = 7;
|
||||
static constexpr uint8_t MAX_ENTITIES = 8;
|
||||
|
||||
enum class Tile : uint8_t { Floor, Wall, Stairs, Treasure };
|
||||
enum class EntityType : uint8_t { Player, Slime, Bat };
|
||||
enum class MoveResult : uint8_t { None, Moved, Blocked, Attacked, Treasure, Stairs, Dead };
|
||||
|
||||
struct Entity {
|
||||
EntityType type = EntityType::Slime;
|
||||
GameKit::GridPos pos {};
|
||||
int8_t hp = 1;
|
||||
bool alive = false;
|
||||
};
|
||||
|
||||
struct DungeonState {
|
||||
Tile tiles[DUNGEON_ROWS][DUNGEON_COLS] {};
|
||||
Entity entities[MAX_ENTITIES] {};
|
||||
uint8_t entityCount = 0;
|
||||
GameKit::GridPos playerPos {1, 1};
|
||||
uint16_t floor = 1;
|
||||
uint16_t gold = 0;
|
||||
int8_t hp = 5;
|
||||
bool gameOver = false;
|
||||
};
|
||||
|
||||
class DungeonModel {
|
||||
DungeonState state {};
|
||||
uint32_t seed = 0xC0FFEE;
|
||||
uint16_t bestFloor = 1;
|
||||
uint16_t bestGold = 0;
|
||||
|
||||
uint32_t nextRandom();
|
||||
void addEnemy(EntityType type, GameKit::GridPos pos, int8_t hp);
|
||||
int findEnemyAt(GameKit::GridPos pos) const;
|
||||
bool isWalkable(GameKit::GridPos pos) const;
|
||||
void moveMonsters();
|
||||
|
||||
public:
|
||||
void reset(uint32_t seedValue = 0xC0FFEE);
|
||||
void generateFloor();
|
||||
MoveResult movePlayer(int dx, int dy);
|
||||
|
||||
const DungeonState& getState() const { return state; }
|
||||
uint16_t getBestFloor() const { return bestFloor; }
|
||||
uint16_t getBestGold() const { return bestGold; }
|
||||
void setBests(uint16_t floor, uint16_t gold) { bestFloor = floor; bestGold = gold; }
|
||||
};
|
||||
|
||||
} // namespace PocketDungeon
|
||||
Reference in New Issue
Block a user