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 497B

12345678910111213141516171819202122232425262728293031
  1. #include "Game.h"
  2. #include <dlfcn.h>
  3. namespace Swan {
  4. void Game::loadMod(const std::string &path) {
  5. registered_mods_.push_back(Mod());
  6. Mod &mod = registered_mods_.back();
  7. void *dl = dlopen(path.c_str(), RTLD_LAZY);
  8. void (*mod_init)(Mod &) = (void (*)(Mod &))dlsym(dl, "mod_init");
  9. mod_init(mod);
  10. }
  11. void Game::draw(Win &win) {
  12. if (world_)
  13. world_->draw(win);
  14. }
  15. void Game::update(float dt) {
  16. if (world_)
  17. world_->update(dt);
  18. }
  19. void Game::tick() {
  20. if (world_)
  21. world_->tick();
  22. }
  23. }