Just breaking stuff
This commit is contained in:
35
archive/dawnplatformergame/components/PlayerController.cpp
Normal file
35
archive/dawnplatformergame/components/PlayerController.cpp
Normal 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);
|
||||
}
|
Reference in New Issue
Block a user