diff --git a/assets/games/platformergame/locale/en.csv b/assets/games/platformergame/locale/en.csv
new file mode 100644
index 00000000..d6e3958c
--- /dev/null
+++ b/assets/games/platformergame/locale/en.csv
@@ -0,0 +1,4 @@
+undefined,UNDEFINED
+hello.world,Hello World!
+scene.1.1,Hello Scene 1_1!
+character.penny.name,Penny
\ No newline at end of file
diff --git a/assets/games/platformergame/tileset/s4m_ur4i_minivania_lava.aseprite b/assets/games/platformergame/tileset/s4m_ur4i_minivania_lava.aseprite
new file mode 100644
index 00000000..5d2d3638
Binary files /dev/null and b/assets/games/platformergame/tileset/s4m_ur4i_minivania_lava.aseprite differ
diff --git a/assets/games/platformergame/tileset/s4m_ur4i_minivania_lava.png b/assets/games/platformergame/tileset/s4m_ur4i_minivania_lava.png
new file mode 100644
index 00000000..0b67be58
Binary files /dev/null and b/assets/games/platformergame/tileset/s4m_ur4i_minivania_lava.png differ
diff --git a/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap.aseprite b/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap.aseprite
new file mode 100644
index 00000000..f925eae0
Binary files /dev/null and b/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap.aseprite differ
diff --git a/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap.png b/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap.png
new file mode 100644
index 00000000..46ba1897
Binary files /dev/null and b/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap.png differ
diff --git a/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap.tsx b/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap.tsx
new file mode 100644
index 00000000..a08cc3a7
--- /dev/null
+++ b/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap.tsx
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap_aqua.aseprite b/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap_aqua.aseprite
new file mode 100644
index 00000000..ee7fcb21
Binary files /dev/null and b/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap_aqua.aseprite differ
diff --git a/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap_aqua.png b/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap_aqua.png
new file mode 100644
index 00000000..fdf8d581
Binary files /dev/null and b/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap_aqua.png differ
diff --git a/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap_aqua.tsx b/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap_aqua.tsx
new file mode 100644
index 00000000..b3e7a260
--- /dev/null
+++ b/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap_aqua.tsx
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap_lava.tsx b/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap_lava.tsx
new file mode 100644
index 00000000..9bf0f43f
--- /dev/null
+++ b/assets/games/platformergame/tileset/s4m_ur4i_minivania_tilemap_lava.tsx
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/assets/games/platformergame/tileset/tiled-example.tmx b/assets/games/platformergame/tileset/tiled-example.tmx
new file mode 100644
index 00000000..b324d6ce
--- /dev/null
+++ b/assets/games/platformergame/tileset/tiled-example.tmx
@@ -0,0 +1,618 @@
+
+
diff --git a/cmake/targets/CMakeLists.txt b/cmake/targets/CMakeLists.txt
index 3210e1a8..06dcd4bd 100644
--- a/cmake/targets/CMakeLists.txt
+++ b/cmake/targets/CMakeLists.txt
@@ -6,9 +6,9 @@
# Check for build target, or default
if(NOT DEFINED DAWN_BUILD_TARGET)
if(WIN32)
- set(DAWN_BUILD_TARGET "target-pokergame-win32-glfw")
+ set(DAWN_BUILD_TARGET "target-platformergame-win32-glfw")
elseif(UNIX AND NOT APPLE)
- set(DAWN_BUILD_TARGET "target-pokergame-linux64-glfw")
+ set(DAWN_BUILD_TARGET "target-platformergame-linux64-glfw")
endif()
endif()
diff --git a/cmake/targets/target-barrygame-linux64-glfw/CMakeLists.txt b/cmake/targets/target-barrygame-linux64-glfw/CMakeLists.txt
deleted file mode 100644
index b3b54649..00000000
--- a/cmake/targets/target-barrygame-linux64-glfw/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright (c) 2022 Dominic Masters
-#
-# This software is released under the MIT License.
-# https://opensource.org/licenses/MIT
-
-set(DAWN_BUILDING dawnbarrygame CACHE INTERNAL ${DAWN_CACHE_TARGET})
-set(DAWN_TARGET_LINUX64 true CACHE INTERNAL ${DAWN_CACHE_TARGET})
-set(DAWN_TARGET_GLFW true CACHE INTERNAL ${DAWN_CACHE_TARGET})
\ No newline at end of file
diff --git a/cmake/targets/target-barrygame-win32-glfw/CMakeLists.txt b/cmake/targets/target-platformergame-win32-glfw/CMakeLists.txt
similarity index 77%
rename from cmake/targets/target-barrygame-win32-glfw/CMakeLists.txt
rename to cmake/targets/target-platformergame-win32-glfw/CMakeLists.txt
index 7eb0b8e4..e4d36e1e 100644
--- a/cmake/targets/target-barrygame-win32-glfw/CMakeLists.txt
+++ b/cmake/targets/target-platformergame-win32-glfw/CMakeLists.txt
@@ -3,6 +3,6 @@
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
-set(DAWN_BUILDING dawnbarrygame CACHE INTERNAL ${DAWN_CACHE_TARGET})
+set(DAWN_BUILDING dawnplatformergame CACHE INTERNAL ${DAWN_CACHE_TARGET})
set(DAWN_TARGET_WIN32 true CACHE INTERNAL ${DAWN_CACHE_TARGET})
set(DAWN_TARGET_GLFW true CACHE INTERNAL ${DAWN_CACHE_TARGET})
\ No newline at end of file
diff --git a/src/dawn/CMakeLists.txt b/src/dawn/CMakeLists.txt
index 0ecdd3a0..a8b8d945 100644
--- a/src/dawn/CMakeLists.txt
+++ b/src/dawn/CMakeLists.txt
@@ -28,4 +28,7 @@ add_subdirectory(save)
add_subdirectory(scene)
add_subdirectory(time)
add_subdirectory(ui)
-add_subdirectory(visualnovel)
\ No newline at end of file
+
+if(DAWN_VISUAL_NOVEL)
+ add_subdirectory(visualnovel)
+endif()
\ No newline at end of file
diff --git a/src/dawn/input/_InputManager.hpp b/src/dawn/input/_InputManager.hpp
index ee76e637..19d53b66 100644
--- a/src/dawn/input/_InputManager.hpp
+++ b/src/dawn/input/_InputManager.hpp
@@ -96,6 +96,19 @@ namespace Dawn {
}
}
+ float_t getAxis(inputbind_t negative, inputbind_t positive) {
+ return -getValue(negative) + getValue(positive);
+ }
+
+ glm::vec2 getAxis2D(
+ inputbind_t negativeX,
+ inputbind_t positiveX,
+ inputbind_t negativeY,
+ inputbind_t positiveY
+ ) {
+ return glm::vec2(getAxis(negativeX, positiveX), getAxis(negativeY, positiveY));
+ }
+
/**
* Returns true if the given bind is currently being pressed (a non-zero
* value).
diff --git a/src/dawn/poker/CMakeLists.txt b/src/dawn/poker/CMakeLists.txt
index eeb1c912..3b9c9f84 100644
--- a/src/dawn/poker/CMakeLists.txt
+++ b/src/dawn/poker/CMakeLists.txt
@@ -15,4 +15,6 @@ target_sources(${DAWN_TARGET_NAME}
)
# Subdirs
-add_subdirectory(visualnovel)
\ No newline at end of file
+if(DAWN_VISUAL_NOVEL)
+ add_subdirectory(visualnovel)
+endif()
\ No newline at end of file
diff --git a/src/dawn/prefab/Prefab.hpp b/src/dawn/prefab/Prefab.hpp
index 4192448f..f4553270 100644
--- a/src/dawn/prefab/Prefab.hpp
+++ b/src/dawn/prefab/Prefab.hpp
@@ -6,6 +6,7 @@
#pragma once
#include "asset/AssetManager.hpp"
#include "scene/Scene.hpp"
+#include "util/array.hpp"
namespace Dawn {
template
diff --git a/src/dawn/prefab/SceneItemPrefab.hpp b/src/dawn/prefab/SceneItemPrefab.hpp
index 6fc5ba6f..92652497 100644
--- a/src/dawn/prefab/SceneItemPrefab.hpp
+++ b/src/dawn/prefab/SceneItemPrefab.hpp
@@ -11,7 +11,7 @@ namespace Dawn {
template
class SceneItemPrefab :
public SceneItem,
- public Prefab
+ public Prefab
{
public:
/**
diff --git a/src/dawn/scene/components/Components.hpp b/src/dawn/scene/components/Components.hpp
index 1a873f4e..7cf54cd1 100644
--- a/src/dawn/scene/components/Components.hpp
+++ b/src/dawn/scene/components/Components.hpp
@@ -9,6 +9,7 @@
#include "scene/components/display/MeshHost.hpp"
#include "scene/components/display/MeshRenderer.hpp"
#include "scene/components/display/Material.hpp"
+#include "scene/components/display/PixelPerfectCamera.hpp"
#include "scene/components/display/TiledSprite.hpp"
#include "scene/components/example/ExampleSpin.hpp"
diff --git a/src/dawn/scene/components/display/CMakeLists.txt b/src/dawn/scene/components/display/CMakeLists.txt
index 9384ce7c..85974ecd 100644
--- a/src/dawn/scene/components/display/CMakeLists.txt
+++ b/src/dawn/scene/components/display/CMakeLists.txt
@@ -11,5 +11,6 @@ target_sources(${DAWN_TARGET_NAME}
Material.cpp
MeshHost.cpp
MeshRenderer.cpp
+ PixelPerfectCamera.cpp
TiledSprite.cpp
)
\ No newline at end of file
diff --git a/src/dawn/scene/components/display/PixelPerfectCamera.cpp b/src/dawn/scene/components/display/PixelPerfectCamera.cpp
new file mode 100644
index 00000000..734a54be
--- /dev/null
+++ b/src/dawn/scene/components/display/PixelPerfectCamera.cpp
@@ -0,0 +1,64 @@
+// Copyright (c) 2023 Dominic Masters
+//
+// This software is released under the MIT License.
+// https://opensource.org/licenses/MIT
+
+#include "PixelPerfectCamera.hpp"
+#include "game/DawnGame.hpp"
+
+using namespace Dawn;
+
+PixelPerfectCamera::PixelPerfectCamera(SceneItem *i) : SceneItemComponent(i) {
+
+}
+
+std::vector PixelPerfectCamera::getDependencies() {
+ return std::vector{
+ (this->camera = this->item->getComponent())
+ };
+}
+
+void PixelPerfectCamera::onRenderTargetResized(
+ RenderTarget *t, float_t w, float_t h
+) {
+ this->updateDimensions();
+}
+
+void PixelPerfectCamera::updateDimensions() {
+ float_t w, h;
+ assertNotNull(this->camera);
+
+ auto target = this->camera->getRenderTarget();
+ switch(this->camera->type) {
+ case CAMERA_TYPE_ORTHONOGRAPHIC:
+ w = target->getWidth() / 2.0f / this->scale;
+ h = target->getHeight() / 2.0f / this->scale;
+ camera->orthoLeft = -w;
+ camera->orthoRight = w;
+ camera->orthoTop = h;
+ camera->orthoBottom = -h;
+ camera->updateProjection();
+ break;
+
+ case CAMERA_TYPE_PERSPECTIVE:
+ assertDeprecated();
+ break;
+
+ default:
+ assertUnreachable();
+ }
+}
+
+void PixelPerfectCamera::onStart() {
+ assertNotNull(this->camera);
+ this->updateDimensions();
+ camera->getRenderTarget()->eventRenderTargetResized
+ .addListener(this, &PixelPerfectCamera::onRenderTargetResized)
+ ;
+}
+
+PixelPerfectCamera::~PixelPerfectCamera() {
+ camera->getRenderTarget()->eventRenderTargetResized
+ .removeListener(this, &PixelPerfectCamera::onRenderTargetResized)
+ ;
+}
\ No newline at end of file
diff --git a/src/dawn/scene/components/display/PixelPerfectCamera.hpp b/src/dawn/scene/components/display/PixelPerfectCamera.hpp
new file mode 100644
index 00000000..f8258970
--- /dev/null
+++ b/src/dawn/scene/components/display/PixelPerfectCamera.hpp
@@ -0,0 +1,36 @@
+// Copyright (c) 2023 Dominic Masters
+//
+// This software is released under the MIT License.
+// https://opensource.org/licenses/MIT
+
+#pragma once
+#include "Camera.hpp"
+
+namespace Dawn {
+ class PixelPerfectCamera : public SceneItemComponent {
+ protected:
+ Camera *camera = nullptr;
+ /** Event for when the render target is resized. */
+ void onRenderTargetResized(RenderTarget *target, float_t w, float_t h);
+
+ /**
+ * Updates the underlying camera's projection information.
+ */
+ void updateDimensions();
+
+ public:
+ float_t scale = 4.0f;
+
+ /**
+ * Create a new PixelPerfectCamera Component.
+ *
+ * @param item Item that this component belongs to.
+ */
+ PixelPerfectCamera(SceneItem *item);
+
+ std::vector getDependencies() override;
+ void onStart() override;
+
+ ~PixelPerfectCamera();
+ };
+}
\ No newline at end of file
diff --git a/src/dawn/visualnovel/scene/SimpleVNScene.cpp b/src/dawn/visualnovel/scene/SimpleVNScene.cpp
index 81fe0e90..12c6e890 100644
--- a/src/dawn/visualnovel/scene/SimpleVNScene.cpp
+++ b/src/dawn/visualnovel/scene/SimpleVNScene.cpp
@@ -4,6 +4,7 @@
// https://opensource.org/licenses/MIT
#include "SimpleVNScene.hpp"
+#include "prefabs/ui/VisualNovelTextboxPrefab.hpp"
using namespace Dawn;
diff --git a/src/dawn/visualnovel/scene/SimpleVNScene.hpp b/src/dawn/visualnovel/scene/SimpleVNScene.hpp
index f6838744..9d69344a 100644
--- a/src/dawn/visualnovel/scene/SimpleVNScene.hpp
+++ b/src/dawn/visualnovel/scene/SimpleVNScene.hpp
@@ -13,7 +13,6 @@
#include "visualnovel/events/VisualNovelPauseEvent.hpp"
#include "visualnovel/events/VisualNovelFadeEvent.hpp"
#include "visualnovel/events/VisualNovelChangeSimpleBackgroundEvent.hpp"
-#include "prefabs/ui/VisualNovelTextboxPrefab.hpp"
namespace Dawn {
class SimpleVNScene : public Scene {
diff --git a/src/dawnbarrygame/input/InputBinds.hpp b/src/dawnbarrygame/input/InputBinds.hpp
deleted file mode 100644
index 9e400ad8..00000000
--- a/src/dawnbarrygame/input/InputBinds.hpp
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright (c) 2022 Dominic Masters
-//
-// This software is released under the MIT License.
-// https://opensource.org/licenses/MIT
-
-#pragma once
-#include "input/InputManager.hpp"
-
-#define INPUT_BIND_ACCEPT ((inputbind_t)1)
\ No newline at end of file
diff --git a/src/dawnbarrygame/prefabs/UIBorderPrefab.hpp b/src/dawnbarrygame/prefabs/UIBorderPrefab.hpp
deleted file mode 100644
index fb3512f9..00000000
--- a/src/dawnbarrygame/prefabs/UIBorderPrefab.hpp
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2022 Dominic Masters
-//
-// This software is released under the MIT License.
-// https://opensource.org/licenses/MIT
-
-#pragma once
-#include "scene/Prefab.hpp"
-#include "ui/UIBorder.hpp"
-#include "asset/assets/TextureAsset.hpp"
-#include "game/DawnGame.hpp"
-
-#define UI_BORDER_TEXTURE_ASSET "texture_test"
-
-namespace Dawn {
- class UIBorderPrefab : public UIPrefab {
- protected:
- static std::vector getAssets(AssetManager *man) override {
- return std::vector{
- man->get(UI_BORDER_TEXTURE_ASSET)
- };
- }
-
- static SceneItem * uiCreate(UICanvas *canvas) override {
- auto border = canvas->addElement();
- UIPrefab::uiApply(border);
- return border;
- }
-
- public:
- void uiApply(UIBorder *border) {
- border->texture = &border
- ->getGame()
- ->assetManager.get(UI_BORDER_TEXTURE_ASSET)->texture
- ;
- border->setBorderSize(glm::vec2(16, 16));
- }
- }
-}
\ No newline at end of file
diff --git a/src/dawnbarrygame/prefabs/VisualNovelTextboxPrefab.hpp b/src/dawnbarrygame/prefabs/VisualNovelTextboxPrefab.hpp
deleted file mode 100644
index c6627822..00000000
--- a/src/dawnbarrygame/prefabs/VisualNovelTextboxPrefab.hpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2022 Dominic Masters
-//
-// This software is released under the MIT License.
-// https://opensource.org/licenses/MIT
-
-#pragma once
-#include "prefabs/UIBorderPrefab.hpp"
-#include "visualnovel/ui/VisualNovelTextbox.hpp"
-
-namespace Dawn {
- class VisualNovelTextboxPrefab : public UIPrefab {
- public:
- static std::vector prefabAssets(AssetManager *man) {
- std::vector assets{
- man->get("truetype_ark")
- };
- vectorAppend(&assets, &UIBorderPrefab::getAssets(man));
- return assets;
- }
-
- static void prefabUIApply(VisualNovelTextbox *textbox) override {
- assertNotNull(textbox);
-
- auto assetFont = textbox->getGame()->assetManager.get("truetype_ark");
- UIBorderPrefab::uiApply(&textbox->border);
- textbox->setFont(&assetFont->font);
- textbox->setFontSize(40);
- textbox->setLabelPadding(glm::vec2(10, 8));
- textbox->setTransform(
- UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_END,
- glm::vec4(0, 238, 0, 0),
- 0.0f
- );
- }
- }
-}
\ No newline at end of file
diff --git a/src/dawnbarrygame/scenes/TestScene.hpp b/src/dawnbarrygame/scenes/TestScene.hpp
deleted file mode 100644
index 5f38b01d..00000000
--- a/src/dawnbarrygame/scenes/TestScene.hpp
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2022 Dominic Masters
-//
-// This software is released under the MIT License.
-// https://opensource.org/licenses/MIT
-
-#pragma once
-#include "visualnovel/scene/SimpleVNScene.hpp"
-
-namespace Dawn {
- class TestScene : public SimpleVNScene {
- protected:
- void vnStage() override {
- SimpleVNScene::vnStage();
- }
-
- std::vector getRequiredAssets() override {
- auto assMan = &this->game->assetManager;
- std::vector assets;
- vectorAppend(&assets, &SimpleVNScene::getRequiredAssets());
- return assets;
- }
-
- IVisualNovelEvent * getVNEvent() override {
- return nullptr;
- // auto start = new VisualNovelTextboxEvent(vnManager,nullptr,"scene.1.1");
- // return start;
- }
-
- public:
- TestScene(DawnGame *game) : SimpleVNScene(game) {}
- };
-}
\ No newline at end of file
diff --git a/src/dawnglfw/host/DawnGLFWHost.cpp b/src/dawnglfw/host/DawnGLFWHost.cpp
index e4b20f96..01b7f9a9 100644
--- a/src/dawnglfw/host/DawnGLFWHost.cpp
+++ b/src/dawnglfw/host/DawnGLFWHost.cpp
@@ -60,6 +60,10 @@ int32_t DawnHost::init(DawnGame *game) {
game->inputManager.bind(INPUT_BIND_ACCEPT, GLFW_KEY_ENTER);
game->inputManager.bind(INPUT_BIND_ACCEPT, GLFW_KEY_E);
game->inputManager.bind(INPUT_BIND_ACCEPT, GLFW_KEY_SPACE);
+ game->inputManager.bind(INPUT_BIND_NEGATIVE_X, GLFW_KEY_A);
+ game->inputManager.bind(INPUT_BIND_POSITIVE_X, GLFW_KEY_D);
+ game->inputManager.bind(INPUT_BIND_NEGATIVE_Y, GLFW_KEY_S);
+ game->inputManager.bind(INPUT_BIND_POSITIVE_Y, GLFW_KEY_W);
// Initialize the game
auto result = game->init();
diff --git a/src/dawnbarrygame/CMakeLists.txt b/src/dawnplatformergame/CMakeLists.txt
similarity index 59%
rename from src/dawnbarrygame/CMakeLists.txt
rename to src/dawnplatformergame/CMakeLists.txt
index 730f5321..ff479d63 100644
--- a/src/dawnbarrygame/CMakeLists.txt
+++ b/src/dawnplatformergame/CMakeLists.txt
@@ -4,7 +4,7 @@
# https://opensource.org/licenses/MIT
# Set up the executable
-set(DAWN_TARGET_NAME "BarryGame" CACHE INTERNAL ${DAWN_CACHE_TARGET})
+set(DAWN_TARGET_NAME "PlatformerGame" CACHE INTERNAL ${DAWN_CACHE_TARGET})
# Build Project
add_executable(${DAWN_TARGET_NAME})
@@ -16,22 +16,18 @@ target_include_directories(${DAWN_TARGET_NAME}
)
# Subdirs
+add_subdirectory(components)
add_subdirectory(game)
add_subdirectory(save)
# Assets
-tool_language(language_en games/barrygame/locale/en.csv)
+set(DIR_GAME_ASSETS games/platformergame)
+tool_language(language_en ${DIR_GAME_ASSETS}/locale/en.csv)
tool_texture(texture_test texture_test.png)
-tool_truetype(truetype_ark
- ark-pixel.ttf
- truetype_ark
- 96
- 96
- 10
-)
+tool_tileset(tileset_aqua texture_aqua ${DIR_GAME_ASSETS}/tileset/s4m_ur4i_minivania_tilemap_aqua.png 32 32)
add_dependencies(${DAWN_TARGET_NAME}
language_en
texture_test
- truetype_ark
+ tileset_aqua
)
\ No newline at end of file
diff --git a/src/dawnplatformergame/components/CMakeLists.txt b/src/dawnplatformergame/components/CMakeLists.txt
new file mode 100644
index 00000000..2715dc32
--- /dev/null
+++ b/src/dawnplatformergame/components/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Copyright (c) 2023 Dominic Masters
+#
+# This software is released under the MIT License.
+# https://opensource.org/licenses/MIT
+
+# Sources
+target_sources(${DAWN_TARGET_NAME}
+ PRIVATE
+ PlayerController.cpp
+)
\ No newline at end of file
diff --git a/src/dawnplatformergame/components/PlayerController.cpp b/src/dawnplatformergame/components/PlayerController.cpp
new file mode 100644
index 00000000..58637b2f
--- /dev/null
+++ b/src/dawnplatformergame/components/PlayerController.cpp
@@ -0,0 +1,35 @@
+// Copyright (c) 2023 Dominic Masters
+//
+// This software is released under the MIT License.
+// https://opensource.org/licenses/MIT
+
+#include "PlayerController.hpp"
+#include "game/DawnGame.hpp"
+
+using namespace Dawn;
+
+PlayerController::PlayerController(SceneItem *i) : SceneItemComponent(i) {}
+
+void PlayerController::onSceneUpdate() {
+ auto im = &getGame()->inputManager;
+ auto delta = getGame()->timeManager.delta;
+
+ glm::vec2 iMove = im->getAxis2D(
+ INPUT_BIND_NEGATIVE_X, INPUT_BIND_POSITIVE_X,
+ INPUT_BIND_NEGATIVE_Y, INPUT_BIND_POSITIVE_Y
+ );
+
+ glm::vec2 pos = this->transform->getLocalPosition();
+ this->transform->setLocalPosition(
+ this->transform->getLocalPosition() + glm::vec3(iMove * delta * 20.0f, 0)
+ );
+}
+
+void PlayerController::onStart() {
+ assertNotNull(this->camera);
+ getScene()->eventSceneUnpausedUpdate.addListener(this, &PlayerController::onSceneUpdate);
+}
+
+PlayerController::~PlayerController() {
+ getScene()->eventSceneUnpausedUpdate.removeListener(this, &PlayerController::onSceneUpdate);
+}
\ No newline at end of file
diff --git a/src/dawnplatformergame/components/PlayerController.hpp b/src/dawnplatformergame/components/PlayerController.hpp
new file mode 100644
index 00000000..af101cc6
--- /dev/null
+++ b/src/dawnplatformergame/components/PlayerController.hpp
@@ -0,0 +1,23 @@
+// Copyright (c) 2023 Dominic Masters
+//
+// This software is released under the MIT License.
+// https://opensource.org/licenses/MIT
+
+#pragma once
+#include "scene/components/Components.hpp"
+
+namespace Dawn {
+ class PlayerController : public SceneItemComponent {
+ protected:
+ void onSceneUpdate();
+
+ public:
+ Camera *camera = nullptr;
+
+ PlayerController(SceneItem *item);
+
+ void onStart() override;
+
+ ~PlayerController();
+ };
+}
\ No newline at end of file
diff --git a/src/dawnbarrygame/game/CMakeLists.txt b/src/dawnplatformergame/game/CMakeLists.txt
similarity index 100%
rename from src/dawnbarrygame/game/CMakeLists.txt
rename to src/dawnplatformergame/game/CMakeLists.txt
diff --git a/src/dawnbarrygame/game/DawnGame.cpp b/src/dawnplatformergame/game/DawnGame.cpp
similarity index 93%
rename from src/dawnbarrygame/game/DawnGame.cpp
rename to src/dawnplatformergame/game/DawnGame.cpp
index 3e203ef4..ea220067 100644
--- a/src/dawnbarrygame/game/DawnGame.cpp
+++ b/src/dawnplatformergame/game/DawnGame.cpp
@@ -8,9 +8,6 @@
using namespace Dawn;
-TrueTypeAsset *assetFont;
-TextureAsset *assetTexture;
-
DawnGame::DawnGame(DawnHost *host) :
host(host),
renderManager(this),
diff --git a/src/dawnbarrygame/game/DawnGame.hpp b/src/dawnplatformergame/game/DawnGame.hpp
similarity index 88%
rename from src/dawnbarrygame/game/DawnGame.hpp
rename to src/dawnplatformergame/game/DawnGame.hpp
index 8e57a7dc..7251bdeb 100644
--- a/src/dawnbarrygame/game/DawnGame.hpp
+++ b/src/dawnplatformergame/game/DawnGame.hpp
@@ -6,7 +6,7 @@
#pragma once
#include "game/_DawnGame.hpp"
#include "scene/components/Components.hpp"
-#include "save/BarrySaveManager.hpp"
+#include "save/DawnGameSaveManager.hpp"
namespace Dawn {
class DawnGame : public IDawnGame {
@@ -17,7 +17,7 @@ namespace Dawn {
InputManager inputManager;
TimeManager timeManager;
LocaleManager localeManager;
- BarrySaveManager saveManager;
+ DawnGameSaveManager saveManager;
DawnGame(DawnHost *host);
int32_t init() override;
diff --git a/src/dawnplatformergame/input/InputBinds.hpp b/src/dawnplatformergame/input/InputBinds.hpp
new file mode 100644
index 00000000..70622120
--- /dev/null
+++ b/src/dawnplatformergame/input/InputBinds.hpp
@@ -0,0 +1,14 @@
+// Copyright (c) 2022 Dominic Masters
+//
+// This software is released under the MIT License.
+// https://opensource.org/licenses/MIT
+
+#pragma once
+#include "input/InputManager.hpp"
+
+#define INPUT_BIND(n) ((inputbind_t)n)
+#define INPUT_BIND_ACCEPT INPUT_BIND(1)
+#define INPUT_BIND_NEGATIVE_X INPUT_BIND(2)
+#define INPUT_BIND_POSITIVE_X INPUT_BIND(3)
+#define INPUT_BIND_NEGATIVE_Y INPUT_BIND(4)
+#define INPUT_BIND_POSITIVE_Y INPUT_BIND(5)
\ No newline at end of file
diff --git a/src/dawnplatformergame/prefabs/PlayerPrefab.hpp b/src/dawnplatformergame/prefabs/PlayerPrefab.hpp
new file mode 100644
index 00000000..5ee8689f
--- /dev/null
+++ b/src/dawnplatformergame/prefabs/PlayerPrefab.hpp
@@ -0,0 +1,46 @@
+// Copyright (c) 2023 Dominic Masters
+//
+// This software is released under the MIT License.
+// https://opensource.org/licenses/MIT
+
+#pragma once
+#include "prefab/SceneItemPrefab.hpp"
+#include "scene/components/Components.hpp"
+#include "components/PlayerController.hpp"
+
+namespace Dawn {
+ class PlayerPrefab : public SceneItemPrefab {
+ public:
+ static std::vector prefabAssets(AssetManager *man) {
+ std::vector assets;
+ assets.push_back(man->get("tileset_aqua"));
+ assets.push_back(man->get("texture_aqua"));
+ return assets;
+ }
+
+ //
+ MeshHost *meshHost;
+ TiledSprite *tiledSprite;
+ Material *material;
+ MeshRenderer *meshRenderer;
+ PlayerController *playerController;
+
+ PlayerPrefab(Scene *s, sceneitemid_t i) : SceneItemPrefab(s, i) {}
+
+ void prefabInit(AssetManager *man) override {
+ auto tileset = man->get("tileset_aqua");
+ auto texture = man->get("texture_aqua");
+
+ meshHost = addComponent();
+ tiledSprite = addComponent();
+ material = addComponent();
+ meshRenderer = addComponent();
+ playerController = addComponent();
+
+ tiledSprite->setTilesetAndSize(&tileset->tileset);
+ tiledSprite->setTile(896);
+
+ material->textureValues[material->getShader()->getParameterByName("u_Text")] = &texture->texture;
+ }
+ };
+}
\ No newline at end of file
diff --git a/src/dawnbarrygame/save/CMakeLists.txt b/src/dawnplatformergame/save/CMakeLists.txt
similarity index 86%
rename from src/dawnbarrygame/save/CMakeLists.txt
rename to src/dawnplatformergame/save/CMakeLists.txt
index 5c203b30..0c216047 100644
--- a/src/dawnbarrygame/save/CMakeLists.txt
+++ b/src/dawnplatformergame/save/CMakeLists.txt
@@ -6,5 +6,5 @@
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
- BarrySaveManager.cpp
+ DawnGameSaveManager.cpp
)
\ No newline at end of file
diff --git a/src/dawnbarrygame/save/BarrySaveManager.cpp b/src/dawnplatformergame/save/DawnGameSaveManager.cpp
similarity index 61%
rename from src/dawnbarrygame/save/BarrySaveManager.cpp
rename to src/dawnplatformergame/save/DawnGameSaveManager.cpp
index 420919a2..049a34c9 100644
--- a/src/dawnbarrygame/save/BarrySaveManager.cpp
+++ b/src/dawnplatformergame/save/DawnGameSaveManager.cpp
@@ -3,26 +3,26 @@
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
-#include "BarrySaveManager.hpp"
+#include "DawnGameSaveManager.hpp"
using namespace Dawn;
-BarrySaveManager::BarrySaveManager(DawnGame *game) : SaveManager(game) {
+DawnGameSaveManager::DawnGameSaveManager(DawnGame *game) : SaveManager(game) {
}
-bool_t BarrySaveManager::validateSave(struct SaveFile raw) {
+bool_t DawnGameSaveManager::validateSave(struct SaveFile raw) {
if(!raw.has(POKER_SAVE_KEY_EXAMPLE)) return true;
this->currentSave.copy(raw, POKER_SAVE_KEY_EXAMPLE);
return false;
}
-void BarrySaveManager::setExample(int32_t val) {
+void DawnGameSaveManager::setExample(int32_t val) {
savedata_t value;
value.i32 = val;
this->currentSave.set(POKER_SAVE_KEY_EXAMPLE, value);
}
-int32_t BarrySaveManager::getExample() {
+int32_t DawnGameSaveManager::getExample() {
return this->currentSave.get(POKER_SAVE_KEY_EXAMPLE).i32;
}
\ No newline at end of file
diff --git a/src/dawnbarrygame/save/BarrySaveManager.hpp b/src/dawnplatformergame/save/DawnGameSaveManager.hpp
similarity index 81%
rename from src/dawnbarrygame/save/BarrySaveManager.hpp
rename to src/dawnplatformergame/save/DawnGameSaveManager.hpp
index 32dc9665..3a339f20 100644
--- a/src/dawnbarrygame/save/BarrySaveManager.hpp
+++ b/src/dawnplatformergame/save/DawnGameSaveManager.hpp
@@ -9,12 +9,12 @@
#define POKER_SAVE_KEY_EXAMPLE "poker.example"
namespace Dawn {
- class BarrySaveManager : public SaveManager {
+ class DawnGameSaveManager : public SaveManager {
protected:
virtual bool_t validateSave(struct SaveFile raw) override;
public:
- BarrySaveManager(DawnGame *game);
+ DawnGameSaveManager(DawnGame *game);
void setExample(int32_t value);
int32_t getExample();
diff --git a/src/dawnplatformergame/scenes/TestScene.hpp b/src/dawnplatformergame/scenes/TestScene.hpp
new file mode 100644
index 00000000..7d0fdb91
--- /dev/null
+++ b/src/dawnplatformergame/scenes/TestScene.hpp
@@ -0,0 +1,33 @@
+// Copyright (c) 2022 Dominic Masters
+//
+// This software is released under the MIT License.
+// https://opensource.org/licenses/MIT
+
+#pragma once
+#include "scene/Scene.hpp"
+#include "prefabs/PlayerPrefab.hpp"
+
+namespace Dawn {
+ class TestScene : public Scene {
+ protected:
+ void stage() override {
+ auto camera = Camera::create(this);
+ camera->type = CAMERA_TYPE_ORTHONOGRAPHIC;
+ camera->item->addComponent();
+ camera->transform->lookAt(glm::vec3(0, 0, 10), glm::vec3(0, 0, 0));
+
+ auto player = PlayerPrefab::create(this);
+ player->playerController->camera = camera;
+ }
+
+ std::vector getRequiredAssets() override {
+ auto assMan = &this->game->assetManager;
+ std::vector assets;
+ vectorAppend(&assets, PlayerPrefab::getRequiredAssets(assMan));
+ return assets;
+ }
+
+ public:
+ TestScene(DawnGame *game) : Scene(game) {}
+ };
+}
\ No newline at end of file
diff --git a/src/dawnpokergame/CMakeLists.txt b/src/dawnpokergame/CMakeLists.txt
index ca536f96..3d7b922a 100644
--- a/src/dawnpokergame/CMakeLists.txt
+++ b/src/dawnpokergame/CMakeLists.txt
@@ -6,6 +6,9 @@
# Set up the executable
set(DAWN_TARGET_NAME "PokerGame" CACHE INTERNAL ${DAWN_CACHE_TARGET})
+# Add Common Engine Parts
+set(DAWN_VISUAL_NOVEL true CACHE INTERNAL ${DAWN_CACHE_TARGET})
+
# Build Project
add_executable(${DAWN_TARGET_NAME})