pushing stuff
authorNils Forssén <nilfo359@student.liu.se>
Wed, 22 Nov 2023 13:43:27 +0000 (14:43 +0100)
committerNils Forssén <nilfo359@student.liu.se>
Wed, 22 Nov 2023 13:43:27 +0000 (14:43 +0100)
src/Helper.cc
src/Helper.h
src/Player.cc
src/States.cc
suppressions.txt [new file with mode: 0644]

index 0ec40739ba75c9d2a2d0fd49f58f6a62c9bbe81e..9280f9449c781afff8af9bfbca4c6e55a5723da9 100644 (file)
@@ -7,10 +7,11 @@
 
 #include <iostream>
 
-Helper::Helper(json& params) : stop_bot{params["stop_bot"]}, stop_top{params["stop_top"]}, max_speed{params["max_speed"]}
+Helper::Helper(json& params) : stop_bot{params["stop_bot"]}, stop_top{params["stop_top"]}, max_speed{params["max_speed"]}, movement{}
 {
     position = {params["start_pos"][0], params["start_pos"][1]};
     direction = {params["direction"][0], params["direction"][1]};
+    movement = direction;
 
     texture.loadFromFile("assets/ysex.png");
     sprite.setTexture(texture);
@@ -40,10 +41,14 @@ void Helper::update(Context& context)
 
 void Helper::move(bool forward)
 {
-    position += static_cast<float>(pow(-1, forward - 1)) *  direction * max_speed;
-    if (position.y >= stop_bot || position.y <= stop_top )
+    position += static_cast<float>(pow(-1, forward - 1)) * movement * max_speed;
+    if (position.y >= stop_bot)
     {
-        direction *= -1.0f;
+        movement = direction * -1.0f;
+    }
+    else if (position.y <= stop_top)
+    {
+        movement = direction;
     }
     sprite.setPosition(position);
 }
index 092015668be88b3f04f6f3d22d1fe30250240799..0eb246b4bbbcbbd4c3369e2e8823263ff271f084 100644 (file)
@@ -25,6 +25,7 @@ private:
     float stop_bot;
     float stop_top;
     float max_speed;
+    sf::Vector2f movement;
 };
 
 #endif
\ No newline at end of file
index 5748cd7f92f833d922a265b42ba087c64fa9ea26..71eddcbb774e41be822f7b80f438bb178536c336 100644 (file)
@@ -41,8 +41,6 @@ void Player::update(Context& context)
     // game_state is still managed by context
     //Game_state* game = static_cast<Game_state*>(context.current_state.get());
     move();
-
-    return;
 }
 
 void Player::move(bool forward) 
index bc0f23999c8e4203bcb692e580c1e6dac819caf2..7c57caceff91a1e316bb3abb6cfd27f01fa4663a 100644 (file)
@@ -97,8 +97,6 @@ void Game_state::update(Context &context)
         time_since_last_bottle = 0;
     }
     game_map->update(points);
-    player->update(context);
-    helper->update(context);
     enemy->update(context);
 }
 
diff --git a/suppressions.txt b/suppressions.txt
new file mode 100644 (file)
index 0000000..9f149b7
--- /dev/null
@@ -0,0 +1,70 @@
+{
+   <insert_a_suppression_name_here>
+   Memcheck:Addr1
+   ...
+   obj:/usr/lib/x86_64-linux-gnu/libsfml-*
+   ...
+}
+{
+   <insert_a_suppression_name_here>
+   Memcheck:Addr2
+   ...
+   obj:/usr/lib/x86_64-linux-gnu/libsfml-*
+   ...
+}
+{
+   <insert_a_suppression_name_here>
+   Memcheck:Addr4
+   ...
+   obj:/usr/lib/x86_64-linux-gnu/libsfml-*
+   ...
+}
+{
+   <insert_a_suppression_name_here>
+   Memcheck:Addr8
+   ...
+   obj:/usr/lib/x86_64-linux-gnu/libsfml-*
+   ...
+}
+{
+   <insert_a_suppression_name_here>
+   Memcheck:Addr1
+   ...
+   obj:/usr/lib/x86_64-linux-gnu/dri/*
+   ...
+}
+{
+   <insert_a_suppression_name_here>
+   Memcheck:Addr2
+   ...
+   obj:/usr/lib/x86_64-linux-gnu/dri/*
+   ...
+}
+{
+   <insert_a_suppression_name_here>
+   Memcheck:Addr4
+   ...
+   obj:/usr/lib/x86_64-linux-gnu/dri/*
+   ...
+}
+{
+   <insert_a_suppression_name_here>
+   Memcheck:Addr8
+   ...
+   obj:/usr/lib/x86_64-linux-gnu/dri/*
+   ...
+}
+{
+   <insert_a_suppression_name_here>
+   Memcheck:Leak
+   ...
+   obj:/usr/lib/x86_64-linux-gnu/dri/*
+   ...
+}
+{
+   <insert_a_suppression_name_here>
+   Memcheck:Cond
+   ...
+   obj:/usr/lib/x86_64-linux-gnu/dri/*
+   ...
+}
\ No newline at end of file