feat: clarity and fixes pass
This commit is contained in:
		
							parent
							
								
									dc008f72b2
								
							
						
					
					
						commit
						d8bba34542
					
				|  | @ -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 <typename TLogicType> | ||||
| 	static Spawner make_factory(CharacterData const &stats); | ||||
| 	static Spawner make_spawner(CharacterData const &stats); | ||||
| }; | ||||
| 
 | ||||
| template <typename TLogicType> | ||||
|  | @ -64,7 +64,7 @@ Character Character::create(CharacterData const &stats, Tile tile) { | |||
| } | ||||
| 
 | ||||
| template <typename TLogicType> | ||||
| Character::Spawner Character::make_factory(CharacterData const &stats) { | ||||
| Character::Spawner Character::make_spawner(CharacterData const &stats) { | ||||
| 	return std::bind(&Character::create<TLogicType>, stats, std::placeholders::_1); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -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)
 | ||||
|  |  | |||
							
								
								
									
										12
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								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<PlayerCharacterLogic>(player_data)) | ||||
| 		.with_player(Character::make_spawner<PlayerCharacterLogic>(player_data)) | ||||
| 		// enemies and boss all use the same "AI" with different data
 | ||||
| 		.with_enemy(Character::make_factory<CritteLogic>(critte_data), 2) | ||||
| 		.with_enemy(Character::make_factory<CritteLogic>(critte_data), 3) | ||||
| 		.with_enemy(Character::make_factory<CritteLogic>(critte_data), 10) | ||||
| 		.with_boss(Character::make_factory<CritteLogic>(boss_data))}; | ||||
| 		.with_enemy(Character::make_spawner<CritteLogic>(critte_data), 2) | ||||
| 		.with_enemy(Character::make_spawner<CritteLogic>(critte_data), 3) | ||||
| 		.with_enemy(Character::make_spawner<CritteLogic>(critte_data), 10) | ||||
| 		.with_boss(Character::make_spawner<CritteLogic>(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; | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Sara
						Sara