Merged helper_collision
authorNils Forssén <nilfo359@student.liu.se>
Tue, 21 Nov 2023 13:29:36 +0000 (14:29 +0100)
committerNils Forssén <nilfo359@student.liu.se>
Tue, 21 Nov 2023 13:29:36 +0000 (14:29 +0100)
1  2 
assets/data.json
src/States.cc
src/States.h

index f123922bba96e3d0352cf5391c2bb0c95b0c6d58,f3899b2bc4e9f4ad49c0e998c7ccc5315e620b8d..5ed7ec8c0a5a01bcd063d2c3f4783213843a947d
      {
          "bottles_per_second" : 2
      },
 +    "map":
 +    {
 +        "points_pos": [100, 100],
 +        "font_size": 24
++    },
+     "main_enemy":
+     {
+         "scale" : [0.35, 0.35]
      }
  }
diff --cc src/States.cc
index 6c20417b9cf93fcf651462744fda6dc47ffdc750,53a6a87e9b68673937a00f3a90ad3ee8b71c638b..bc0f23999c8e4203bcb692e580c1e6dac819caf2
@@@ -14,8 -14,8 +14,9 @@@ Game_state::Game_state() 
      game_map{}, 
      pause_game{false},
      player{},
 -    bottles{},
 -    main_enemy_texture{}, 
 +    bottles{}, 
 +    helper{},
++    main_enemy_texture{},
      time_since_last_bottle{0.0f},
      bottle_texture {},
      data{},
  
      player = std::make_unique<Player>(data["player"]);
      helper = std::make_unique<Helper>(data["helper"]);
 +    game_map = std::make_unique<Map>(data["map"]);
+     enemy = std::make_unique<Main_enemy>(main_enemy_texture, data["main_enemy"]);
  
      bottle_texture.loadFromFile("assets/kir.png");
+     
  }
  
  void Game_state::update(Context &context)
          std::cout << "placed bottle"<< std::endl;
          time_since_last_bottle = 0;
      }
 -    game_map.update(context);
 +    game_map->update(points);
-     enemy.update(context);
+     player->update(context);
+     helper->update(context);
+     enemy->update(context);
  }
  
  void Game_state::render(sf::RenderWindow &window) const
  {
 -    game_map.render(window);
 +    game_map->render(window);
      player->render(window);
-     enemy.render(window);
+     enemy->render(window);
      helper->render(window);
      for (int i{}; i < int(bottles.size()); ++i)
      {
diff --cc src/States.h
index 379c6482a08a3015d66ab9e2a45f57e77cde1d95,5479aa800cd5187893cc821a9d08b375ab434a72..1c8c148505b39d481ce59006ce8c6afd20eaade1
@@@ -42,14 -42,15 +42,16 @@@ protected
  private:
      float time_since_last_bottle;
      
 -    Map game_map;
 +    std::unique_ptr<Map> game_map;
      std::unique_ptr<Player> player;
      std::unique_ptr<Helper> helper;
-     Main_enemy enemy;
+     std::unique_ptr<Main_enemy> enemy;
      bool pause_game;
      sf::Texture bottle_texture;
+     sf::Texture main_enemy_texture;
      json data;
 +    int points;
  
  };