diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-22 17:26:27 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-22 17:26:27 +0100 |
commit | 0dae96161a99158815a8075b5c405a35b0939936 (patch) | |
tree | 5b9b214c0397694b671e271f6b743c0fd845f51f /game/prefab | |
parent | 7e12ebdf945d40d6f11872cf5852c9bb54d1864f (diff) |
fix Player prefab
Diffstat (limited to 'game/prefab')
-rw-r--r-- | game/prefab/PlayerObject.cpp | 8 | ||||
-rw-r--r-- | game/prefab/PlayerScript.cpp | 15 | ||||
-rw-r--r-- | game/prefab/PlayerScript.h | 10 |
3 files changed, 6 insertions, 27 deletions
diff --git a/game/prefab/PlayerObject.cpp b/game/prefab/PlayerObject.cpp index 736704a..ef7b6cc 100644 --- a/game/prefab/PlayerObject.cpp +++ b/game/prefab/PlayerObject.cpp @@ -1,5 +1,3 @@ -#include <crepe/util/Log.h> - #include "Config.h" #include "PlayerObject.h" #include "PlayerScript.h" @@ -67,10 +65,8 @@ PlayerObject::PlayerObject(crepe::GameObject && base) .collision_layer = COLL_LAY_PLAYER, })), collider(add_component<BoxCollider>(vec2(50, 50))), - controller(add_component<BehaviorScript>().set_script<PlayerScript>(this)) { + controller(add_component<BehaviorScript>().set_script<PlayerScript>(*this)) { sprite.jetpack.active = false; - // controller.active = false; - - Log::logf(Log::DEBUG, "PlayerObject: ref {}", (void*) &(this->body.game_object_id)); + controller.active = false; } diff --git a/game/prefab/PlayerScript.cpp b/game/prefab/PlayerScript.cpp index e4a4951..67aadb6 100644 --- a/game/prefab/PlayerScript.cpp +++ b/game/prefab/PlayerScript.cpp @@ -6,21 +6,10 @@ 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; -} +PlayerScript::PlayerScript(const PlayerObject & player) : player(player) { } void PlayerScript::fixed_update(crepe::duration_t dt) { if (this->get_key_state(Keycode::SPACE)) - player->body.add_force_linear({ 0, -10 }); + player.body.add_force_linear({ 0, -10 }); } diff --git a/game/prefab/PlayerScript.h b/game/prefab/PlayerScript.h index bd4a00a..131c73f 100644 --- a/game/prefab/PlayerScript.h +++ b/game/prefab/PlayerScript.h @@ -6,18 +6,12 @@ class PlayerScript : public crepe::Script { public: - PlayerScript(PlayerObject * player); - - PlayerScript(const PlayerScript &) = delete; - PlayerScript(PlayerScript &&) = delete; - PlayerScript & operator=(const PlayerScript &) = delete; - PlayerScript & operator=(PlayerScript &&) = delete; + PlayerScript(const PlayerObject & player); protected: void fixed_update(crepe::duration_t dt); - void init(); protected: - PlayerObject * player = nullptr; + PlayerObject player; }; |