From: Nils Forssén Date: Wed, 22 Nov 2023 13:43:27 +0000 (+0100) Subject: pushing stuff X-Git-Url: https://gitweb.forssennils.se/?a=commitdiff_plain;h=c45d18f701c1b56af3ebb780f3c6a04561c48b1f;p=TDDC76_proj.git pushing stuff --- diff --git a/src/Helper.cc b/src/Helper.cc index 0ec4073..9280f94 100644 --- a/src/Helper.cc +++ b/src/Helper.cc @@ -7,10 +7,11 @@ #include -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(pow(-1, forward - 1)) * direction * max_speed; - if (position.y >= stop_bot || position.y <= stop_top ) + position += static_cast(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); } diff --git a/src/Helper.h b/src/Helper.h index 0920156..0eb246b 100644 --- a/src/Helper.h +++ b/src/Helper.h @@ -25,6 +25,7 @@ private: float stop_bot; float stop_top; float max_speed; + sf::Vector2f movement; }; #endif \ No newline at end of file diff --git a/src/Player.cc b/src/Player.cc index 5748cd7..71eddcb 100644 --- a/src/Player.cc +++ b/src/Player.cc @@ -41,8 +41,6 @@ void Player::update(Context& context) // game_state is still managed by context //Game_state* game = static_cast(context.current_state.get()); move(); - - return; } void Player::move(bool forward) diff --git a/src/States.cc b/src/States.cc index bc0f239..7c57cac 100644 --- a/src/States.cc +++ b/src/States.cc @@ -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 index 0000000..9f149b7 --- /dev/null +++ b/suppressions.txt @@ -0,0 +1,70 @@ +{ + + Memcheck:Addr1 + ... + obj:/usr/lib/x86_64-linux-gnu/libsfml-* + ... +} +{ + + Memcheck:Addr2 + ... + obj:/usr/lib/x86_64-linux-gnu/libsfml-* + ... +} +{ + + Memcheck:Addr4 + ... + obj:/usr/lib/x86_64-linux-gnu/libsfml-* + ... +} +{ + + Memcheck:Addr8 + ... + obj:/usr/lib/x86_64-linux-gnu/libsfml-* + ... +} +{ + + Memcheck:Addr1 + ... + obj:/usr/lib/x86_64-linux-gnu/dri/* + ... +} +{ + + Memcheck:Addr2 + ... + obj:/usr/lib/x86_64-linux-gnu/dri/* + ... +} +{ + + Memcheck:Addr4 + ... + obj:/usr/lib/x86_64-linux-gnu/dri/* + ... +} +{ + + Memcheck:Addr8 + ... + obj:/usr/lib/x86_64-linux-gnu/dri/* + ... +} +{ + + Memcheck:Leak + ... + obj:/usr/lib/x86_64-linux-gnu/dri/* + ... +} +{ + + Memcheck:Cond + ... + obj:/usr/lib/x86_64-linux-gnu/dri/* + ... +} \ No newline at end of file