tumbling{false},
moving_to_bottle{false}
{
- //texture.loadFromFile("assets/6Ling_figur2.png");
texture = txtr;
sprite.setTexture(texture);
position = {params["start_pos"][0], params["start_pos"][1]};
else
{
- Game_state* game = static_cast<Game_state*>(context.current_state.get());
+ Game_state* game =
+ static_cast<Game_state*>(context.current_state.get());
if ((game->bottles).size() != 0)
{
moving_to_bottle = true;
direction = find_closest_bottle(game->bottles) - position;
- float magnitude = sqrt(direction.x*direction.x + direction.y*direction.y);
+ float magnitude = sqrt(direction.x*direction.x +
+ direction.y*direction.y);
direction /= magnitude;
move();
}
{
if (moving_to_bottle)
{
- position += static_cast<float>(pow(-1, forward - 1)) * max_speed * direction;
+ position += static_cast<float>(pow(-1,forward-1))*max_speed*direction;
sprite.setPosition(position);
}
}
-sf::Vector2f Main_enemy::find_closest_bottle(std::vector<std::unique_ptr<Bottle>> & bottles)
+sf::Vector2f Main_enemy::find_closest_bottle(
+ std::vector<std::unique_ptr<Bottle>> & bottles)
{
- //return {0,0};
-
unsigned int closest_bottle_index {0};
float min_dist{100000};
for (uint i {0}; i < bottles.size(); ++i)