aboutsummaryrefslogtreecommitdiff
path: root/game/prefab/PlayerScript.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-12-22 16:12:31 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-12-22 16:12:31 +0100
commit7e12ebdf945d40d6f11872cf5852c9bb54d1864f (patch)
treed81f4661e2fd47f487cf0c9627baa1e21dc45b37 /game/prefab/PlayerScript.cpp
parent61148c757a1f742ff09e40e5347e74e638c7371c (diff)
big WIP
Diffstat (limited to 'game/prefab/PlayerScript.cpp')
-rw-r--r--game/prefab/PlayerScript.cpp26
1 files changed, 26 insertions, 0 deletions
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 <crepe/api/Rigidbody.h>
+#include <cassert>
+
+#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 });
+}
+