diff --git a/src/core/character.h b/src/core/character.h index ddfca85..7b5f233 100644 --- a/src/core/character.h +++ b/src/core/character.h @@ -55,7 +55,7 @@ public: // binds Character::create into a std::function, // making a Factory Pattern object to pass to WorldGenerator as a spawner template - static Spawner make_factory(CharacterData const &stats); + static Spawner make_spawner(CharacterData const &stats); }; template @@ -64,7 +64,7 @@ Character Character::create(CharacterData const &stats, Tile tile) { } template -Character::Spawner Character::make_factory(CharacterData const &stats) { +Character::Spawner Character::make_spawner(CharacterData const &stats) { return std::bind(&Character::create, stats, std::placeholders::_1); } diff --git a/src/core/world.h b/src/core/world.h index ae40af4..efcb5aa 100644 --- a/src/core/world.h +++ b/src/core/world.h @@ -39,9 +39,9 @@ public: Character *get_boss(); // returns the boss character instance Chunk get_chunk(Tile tile); // returns the chunk at the given world-space tile TileData query_tile(Tile tile); // returns data related to the given world-space tile - void on_input(bool pressed); // registered with the 'direction_pressed' key event handler private: void act(); + void on_input(bool pressed); // registered with the 'direction_pressed' key event handler private: int chunk_size{1}; // size of chunks unsigned shear{0}; // number of chunks before the next row (width of the map in chunks) diff --git a/src/main.cpp b/src/main.cpp index 7532849..b0f780d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -37,6 +37,7 @@ CharacterData const critte_data{ int main(int argc, char *argv[]) { + SDL_Init(SDL_INIT_EVERYTHING); // Game state, simple way of managing which menu/screen the player is currently on GameState game_state{GameState::MainMenu}; // World generator, can be used to generate new rooms when the player restarts the game @@ -47,12 +48,12 @@ int main(int argc, char *argv[]) { .with_room_size(5, 8) .with_connecting_chance(5) // setup character spawners/character factories - .with_player(Character::make_factory(player_data)) + .with_player(Character::make_spawner(player_data)) // enemies and boss all use the same "AI" with different data - .with_enemy(Character::make_factory(critte_data), 2) - .with_enemy(Character::make_factory(critte_data), 3) - .with_enemy(Character::make_factory(critte_data), 10) - .with_boss(Character::make_factory(boss_data))}; + .with_enemy(Character::make_spawner(critte_data), 2) + .with_enemy(Character::make_spawner(critte_data), 3) + .with_enemy(Character::make_spawner(critte_data), 10) + .with_boss(Character::make_spawner(boss_data))}; // renderdata, passed to Render but kept here so that RAII will call the destructor when main pops off the stack RenderData data{RenderDataSetup() // create window and renderer, allowing for texture creation @@ -143,5 +144,6 @@ int main(int argc, char *argv[]) { } } } + SDL_Quit(); return 0; }