From 7e12ebdf945d40d6f11872cf5852c9bb54d1864f Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sun, 22 Dec 2024 16:12:31 +0100 Subject: big WIP --- game/prefab/PlayerScript.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 game/prefab/PlayerScript.cpp (limited to 'game/prefab/PlayerScript.cpp') diff --git a/game/prefab/PlayerScript.cpp b/game/prefab/PlayerScript.cpp new file mode 100644 index 0000000..e4a4951 --- /dev/null +++ b/game/prefab/PlayerScript.cpp @@ -0,0 +1,26 @@ +#include +#include + +#include "PlayerScript.h" + +using namespace crepe; +using namespace std; + +PlayerScript::PlayerScript(PlayerObject * player) : player(player) { + logf(Log::DEBUG, "PlayerScript: [C] player {}", (void*) &(*player)); + logf(Log::DEBUG, "PlayerScript: [C] player.body {}", (void*) &(player->body)); + logf(Log::DEBUG, "PlayerScript: [C] player.body.id {}", (void*) &(player->body.game_object_id)); +} + +void PlayerScript::init() { + logf(Log::DEBUG, "PlayerScript: [C] player {}", (void*) &(*player)); + logf(Log::DEBUG, "PlayerScript: [C] player.body {}", (void*) &(player->body)); + logf(Log::DEBUG, "PlayerScript: [C] player.body.id {}", (void*) &(player->body.game_object_id)); + player->controller.active = false; +} + +void PlayerScript::fixed_update(crepe::duration_t dt) { + if (this->get_key_state(Keycode::SPACE)) + player->body.add_force_linear({ 0, -10 }); +} + -- cgit v1.2.3