A 2D tile-based sandbox game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Game.cc 579B

12345678910111213141516171819202122232425262728293031323334
  1. #include "Game.h"
  2. namespace Swan {
  3. void Game::registerTile(std::string &name, Tile &tile) {
  4. Tile::TileID id = registered_tiles_.size();
  5. registered_tiles_.push_back(tile);
  6. tile_id_map_[name] = id;
  7. }
  8. Tile::TileID Game::getTileID(std::string &name) {
  9. return tile_id_map_[name];
  10. }
  11. void Game::draw(Win &win) {
  12. for (WorldPlane *plane: planes_)
  13. plane->draw(win);
  14. player_->draw(win);
  15. }
  16. void Game::update(float dt) {
  17. for (WorldPlane *plane: planes_)
  18. plane->update(dt);
  19. player_->update(dt);
  20. }
  21. void Game::tick() {
  22. for (WorldPlane *plane: planes_)
  23. plane->tick();
  24. }
  25. }