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,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "GameKitScene.h"
|
||||
#include "GameKitLoop.h"
|
||||
#include "GameKitGrid.h"
|
||||
#include "GameKitInput.h"
|
||||
#include "GameKitDraw.h"
|
||||
#include "GameKitPrefs.h"
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace GameKit {
|
||||
|
||||
lv_obj_t* makePanel(lv_obj_t* parent, lv_color_t color, uint8_t radius = 8);
|
||||
lv_obj_t* makeCell(lv_obj_t* parent, uint16_t size, lv_color_t color, uint8_t radius = 4);
|
||||
lv_obj_t* makeLabel(lv_obj_t* parent, const char* text, lv_color_t color);
|
||||
void setCell(lv_obj_t* obj, int x, int y, uint16_t cellPx);
|
||||
|
||||
} // namespace GameKit
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace GameKit {
|
||||
|
||||
struct GridPos {
|
||||
int16_t x = 0;
|
||||
int16_t y = 0;
|
||||
};
|
||||
|
||||
inline bool operator==(GridPos a, GridPos b) { return a.x == b.x && a.y == b.y; }
|
||||
inline bool operator!=(GridPos a, GridPos b) { return !(a == b); }
|
||||
|
||||
struct GridSpec {
|
||||
uint8_t cols = 0;
|
||||
uint8_t rows = 0;
|
||||
uint16_t cellPx = 0;
|
||||
uint16_t originX = 0;
|
||||
uint16_t originY = 0;
|
||||
};
|
||||
|
||||
lv_point_t gridToPx(const GridSpec& grid, GridPos pos);
|
||||
bool gridContains(const GridSpec& grid, GridPos pos);
|
||||
|
||||
} // namespace GameKit
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "GameKitScene.h"
|
||||
#include <lvgl.h>
|
||||
|
||||
namespace GameKit {
|
||||
|
||||
InputKind keyToInput(uint32_t key);
|
||||
InputKind gestureToInput(lv_dir_t dir);
|
||||
InputKind pointToQuadrant(lv_obj_t* obj, lv_point_t point);
|
||||
void attachInput(lv_obj_t* target, Scene* scene);
|
||||
|
||||
} // namespace GameKit
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "GameKitScene.h"
|
||||
#include <lvgl.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace GameKit {
|
||||
|
||||
class Loop {
|
||||
lv_timer_t* timer = nullptr;
|
||||
Scene* scene = nullptr;
|
||||
uint32_t periodMs = 0;
|
||||
uint32_t lastTickMs = 0;
|
||||
|
||||
static void onTimer(lv_timer_t* timer);
|
||||
|
||||
public:
|
||||
~Loop();
|
||||
bool start(uint32_t tickMs, Scene* targetScene);
|
||||
void stop();
|
||||
bool isRunning() const { return timer != nullptr; }
|
||||
};
|
||||
|
||||
} // namespace GameKit
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <TactilityCpp/Preferences.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace GameKit {
|
||||
|
||||
class Prefs {
|
||||
Preferences prefs;
|
||||
|
||||
public:
|
||||
explicit Prefs(const char* ns) : prefs(ns) {}
|
||||
int32_t getInt(const char* key, int32_t fallback = 0) const { return prefs.getInt32(key, fallback); }
|
||||
void putInt(const char* key, int32_t value) const { prefs.putInt32(key, value); }
|
||||
};
|
||||
|
||||
} // namespace GameKit
|
||||
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace GameKit {
|
||||
|
||||
struct Tick {
|
||||
uint32_t dtMs = 0;
|
||||
uint32_t nowMs = 0;
|
||||
};
|
||||
|
||||
enum class InputKind : uint8_t {
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right,
|
||||
Confirm,
|
||||
Cancel,
|
||||
Menu,
|
||||
Touch,
|
||||
Swipe,
|
||||
Unknown,
|
||||
};
|
||||
|
||||
struct InputEvent {
|
||||
InputKind kind = InputKind::Unknown;
|
||||
lv_point_t point {0, 0};
|
||||
};
|
||||
|
||||
class Scene {
|
||||
public:
|
||||
virtual ~Scene() = default;
|
||||
virtual void onEnter(lv_obj_t* root) = 0;
|
||||
virtual void onExit() = 0;
|
||||
virtual void onInput(const InputEvent& input) = 0;
|
||||
virtual void onTick(const Tick& tick) = 0;
|
||||
virtual void render() = 0;
|
||||
};
|
||||
|
||||
} // namespace GameKit
|
||||
Reference in New Issue
Block a user