Simplified DawnGAme a lot
This commit is contained in:
17
src/dawnrose/CMakeLists.txt
Normal file
17
src/dawnrose/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright (c) 2023 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Build Project
|
||||
add_executable(${DAWN_TARGET_NAME})
|
||||
|
||||
# Includes
|
||||
target_include_directories(${DAWN_TARGET_NAME}
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
# Subdirs
|
||||
add_subdirectory(game)
|
||||
add_subdirectory(save)
|
10
src/dawnrose/game/CMakeLists.txt
Normal file
10
src/dawnrose/game/CMakeLists.txt
Normal file
@ -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
|
||||
RoseGame.cpp
|
||||
)
|
13
src/dawnrose/game/RoseGame.cpp
Normal file
13
src/dawnrose/game/RoseGame.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "game/DawnGame.hpp"
|
||||
#include "scenes/HelloWorldScene.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
Scene * Dawn::dawnGameGetInitialScene(DawnGame *game) {
|
||||
return new HelloWorldScene(game);
|
||||
}
|
19
src/dawnrose/input/InputBinds.hpp
Normal file
19
src/dawnrose/input/InputBinds.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright (c) 2023 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)
|
||||
#define INPUT_BIND_MOUSE_X INPUT_BIND(6)
|
||||
#define INPUT_BIND_MOUSE_Y INPUT_BIND(7)
|
||||
#define INPUT_BIND_MOUSE_CLICK INPUT_BIND(8)
|
||||
#define INPUT_BIND_CANCEL INPUT_BIND(9)
|
10
src/dawnrose/save/CMakeLists.txt
Normal file
10
src/dawnrose/save/CMakeLists.txt
Normal file
@ -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
|
||||
RoseSave.cpp
|
||||
)
|
12
src/dawnrose/save/RoseSave.cpp
Normal file
12
src/dawnrose/save/RoseSave.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "save/SaveManager.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
bool_t Dawn::saveValidateFile(struct SaveFile raw) {
|
||||
return false;
|
||||
}
|
65
src/dawnrose/scenes/HelloWorldScene.hpp
Normal file
65
src/dawnrose/scenes/HelloWorldScene.hpp
Normal file
@ -0,0 +1,65 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "scene/Scene.hpp"
|
||||
#include "prefabs/SimpleSpinningCubePrefab.hpp"
|
||||
#include "scene/components/ui/UILabel.hpp"
|
||||
#include "scene/components/ui/UIImage.hpp"
|
||||
#include "display/font/BitmapFont.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class HelloWorldScene : public Scene {
|
||||
protected:
|
||||
Camera *camera;
|
||||
SimpleSpinningCubePrefab *cube;
|
||||
UICanvas *canvas;
|
||||
UILabel *label;
|
||||
UIImage *image;
|
||||
BitmapFont font;
|
||||
|
||||
void stage() override {
|
||||
camera = Camera::create(this);
|
||||
camera->transform->lookAt(glm::vec3(0, 0, 8), glm::vec3(0, 0, 0));
|
||||
|
||||
cube = SimpleSpinningCubePrefab::create(this);
|
||||
|
||||
canvas = UICanvas::create(this);
|
||||
|
||||
auto imageItem = this->createSceneItem();
|
||||
image = imageItem->addComponent<UIImage>();
|
||||
image->color = COLOR_BLACK;
|
||||
imageItem->transform.setParent(canvas->transform);
|
||||
|
||||
auto labelItem = this->createSceneItem();
|
||||
label = labelItem->addComponent<UILabel>();
|
||||
labelItem->transform.setParent(canvas->transform);
|
||||
|
||||
auto assMan = &this->game->assetManager;
|
||||
auto texture = assMan->get<TextureAsset>("testbitmap_texture");
|
||||
auto tileset = assMan->get<TilesetAsset>("testbitmap_tileset");
|
||||
this->font.texture = &texture->texture;
|
||||
this->font.tileset = &tileset->tileset;
|
||||
|
||||
label->text = "Hello World, how are you today? I hope you are doing well. I really like the fact I can ramble in my text for once.";
|
||||
label->font = &font;
|
||||
label->maxWidth = 220;
|
||||
|
||||
image->alignment = glm::vec4(0, 0, label->getContentWidth(), label->getContentHeight());
|
||||
}
|
||||
|
||||
std::vector<Asset*> getRequiredAssets() override {
|
||||
auto assMan = &this->game->assetManager;
|
||||
std::vector<Asset*> assets;
|
||||
vectorAppend(&assets, SimpleSpinningCubePrefab::getRequiredAssets(assMan));
|
||||
assets.push_back(assMan->get<TextureAsset>("testbitmap_texture"));
|
||||
assets.push_back(assMan->get<TilesetAsset>("testbitmap_tileset"));
|
||||
return assets;
|
||||
}
|
||||
|
||||
public:
|
||||
HelloWorldScene(DawnGame *game) : Scene(game) {}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user