aboutsummaryrefslogtreecommitdiff
path: root/game/preview
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2025-01-10 16:26:05 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2025-01-10 16:26:05 +0100
commita981a42a7378ed51155590215557e52553031272 (patch)
tree7ca1b0cb7f72d6e8d50df09470a177a09ee12e51 /game/preview
parent0f8bf257d86b5532f3d6f559e5368668c255af7c (diff)
missile solution, cannot find @max issue
Diffstat (limited to 'game/preview')
-rw-r--r--game/preview/NpcScript.cpp9
-rw-r--r--game/preview/NpcScript.h5
-rw-r--r--game/preview/NpcSubScene.cpp6
-rw-r--r--game/preview/PrevPlayerSubScene.cpp6
4 files changed, 5 insertions, 21 deletions
diff --git a/game/preview/NpcScript.cpp b/game/preview/NpcScript.cpp
index c4148f2..5a93c2b 100644
--- a/game/preview/NpcScript.cpp
+++ b/game/preview/NpcScript.cpp
@@ -7,16 +7,15 @@
using namespace std;
using namespace crepe;
-void NpcScript::init() {}
void NpcScript::fixed_update(duration_t dt) {
auto & rb = this->get_component<Rigidbody>();
auto & npc = this->get_component<Sprite>();
auto & transform = this->get_component<Transform>();
- if (transform.position.x < -990) {
+ if (transform.position.x < 200) {
rb.data.linear_velocity.x *= -1;
}
- if (transform.position.x > 990) {
+ if (transform.position.x > 700) {
rb.data.linear_velocity.x *= -1;
}
@@ -25,8 +24,4 @@ void NpcScript::fixed_update(duration_t dt) {
} else {
npc.data.flip = {false, false};
}
-
- auto & savemgr = this->get_save_manager();
- savemgr.set("npc_x", transform.position.x);
- savemgr.set("npc_y", transform.position.y);
}
diff --git a/game/preview/NpcScript.h b/game/preview/NpcScript.h
index 8d856fd..d278f83 100644
--- a/game/preview/NpcScript.h
+++ b/game/preview/NpcScript.h
@@ -1,11 +1,8 @@
+#pragma once
#include <crepe/api/Script.h>
class NpcScript : public crepe::Script {
-
-private:
-
public:
- void init();
void fixed_update(crepe::duration_t dt);
};
diff --git a/game/preview/NpcSubScene.cpp b/game/preview/NpcSubScene.cpp
index bd6cfb2..a3781af 100644
--- a/game/preview/NpcSubScene.cpp
+++ b/game/preview/NpcSubScene.cpp
@@ -15,11 +15,7 @@
using namespace crepe;
NpcSubScene::NpcSubScene(Scene & scn) {
- auto & savemgr = scn.get_save_manager();
- ValueBroker npc_x = savemgr.get<float>("npc_x", 500);
- ValueBroker npc_y = savemgr.get<float>("npc_y", 0);
-
- GameObject npc = scn.new_object("npc", "npc_tag", vec2 {npc_x.get(), npc_y.get()}, 0, 1);
+ GameObject npc = scn.new_object("npc", "npc_tag", vec2 {500, 0}, 0, 1);
Asset npc_body {"asset/workers/worker1Body.png"};
Asset npc_head {"asset/workers/worker1Head.png"};
diff --git a/game/preview/PrevPlayerSubScene.cpp b/game/preview/PrevPlayerSubScene.cpp
index b59a0af..4351deb 100644
--- a/game/preview/PrevPlayerSubScene.cpp
+++ b/game/preview/PrevPlayerSubScene.cpp
@@ -16,13 +16,9 @@
using namespace crepe;
PrevPlayerSubScene::PrevPlayerSubScene(Scene & scn) {
- auto & savemgr = scn.get_save_manager();
-
- ValueBroker player_x = savemgr.get<float>("player_x", 500);
- ValueBroker player_y = savemgr.get<float>("player_y", -100);
GameObject player
- = scn.new_object("player", "TAG", vec2 {player_x.get(), player_y.get()}, 0, 1);
+ = scn.new_object("player", "player", vec2 {800 , -100}, 0, 1);
Asset player_body_asset {"asset/barry/defaultBody.png"};
Sprite & player_body_sprite = player.add_component<Sprite>(
player_body_asset,