Fixed input
This commit is contained in:
@ -6,4 +6,5 @@
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
Entity.cpp
|
||||
Player.cpp
|
||||
)
|
@ -10,7 +10,7 @@ using namespace Dawn;
|
||||
|
||||
void Entity::onInit() {
|
||||
auto world = this->world.lock();
|
||||
assertNotNull(world, "World is no longer active.");
|
||||
assertNotNull(world, "World is no longer active? ");
|
||||
}
|
||||
|
||||
void Entity::onDispose() {
|
||||
|
23
src/dawnrpg/component/entity/Player.cpp
Normal file
23
src/dawnrpg/component/entity/Player.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (c) 2024 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "Player.hpp"
|
||||
#include "scene/Scene.hpp"
|
||||
#include "input/InputBinds.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
void Player::onInit() {
|
||||
listenerUpdate = getScene()->onUnpausedUpdate.listen([this](float delta) {
|
||||
InputManager &im = getGame()->inputManager;
|
||||
if(im.isDown(InputBind::Up)) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Player::onDispose() {
|
||||
listenerUpdate();
|
||||
}
|
18
src/dawnrpg/component/entity/Player.hpp
Normal file
18
src/dawnrpg/component/entity/Player.hpp
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright (c) 2024 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "scene/SceneComponent.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class Player : public SceneComponent {
|
||||
protected:
|
||||
std::function<void()> listenerUpdate;
|
||||
|
||||
public:
|
||||
void onInit() override;
|
||||
void onDispose() override;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user