Just breaking stuff

This commit is contained in:
2023-03-14 22:27:46 -07:00
parent 795e69237c
commit 09cb20271b
156 changed files with 4218 additions and 4389 deletions

View 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
PlayerController.cpp
)

View File

@ -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);
}

View File

@ -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();
};
}