Merge branch 'dev' of https://github.com/Jonny999999/snake-pp into dev
This commit is contained in:
		
						commit
						04d45c7988
					
				| @ -28,7 +28,6 @@ endif() | ||||
| 
 | ||||
| # --- Locate SDL2 --- | ||||
| # Uses SDL2_DIR on Windows, on Linux it's found automatically | ||||
| # Locate SDL2 | ||||
| find_package(SDL2 REQUIRED) | ||||
| 
 | ||||
| # --- Locate SDL2_ttf --- | ||||
| @ -57,21 +56,67 @@ set(SOURCES | ||||
| ) | ||||
| 
 | ||||
| 
 | ||||
| #--- executable --- | ||||
| add_executable(Snake ${SOURCES}) | ||||
| 
 | ||||
| 
 | ||||
| #--- link libraries --- | ||||
| if(WIN32) | ||||
|     # Link libraries statically on Windows to prevent missing basic libraries on other systems. | ||||
|     target_link_options(Snake PRIVATE -static) | ||||
|     target_link_libraries(Snake ${SDL2_LIBRARIES} ${SDL_TTF_LIBRARIES}) | ||||
| else() | ||||
|     target_link_libraries(Snake SDL2::SDL2 SDL2_ttf::SDL2_ttf) | ||||
| endif() | ||||
| 
 | ||||
| 
 | ||||
| # --- Copy assets to output folder --- | ||||
| file(COPY ${CMAKE_SOURCE_DIR}/assets DESTINATION ${CMAKE_BINARY_DIR}) | ||||
| 
 | ||||
| 
 | ||||
| # --- Copy SDL2 DLLs to the output folder on Windows --- | ||||
| if(WIN32) | ||||
|     foreach(DLL ${SDL2_DLLS} ${SDL2_TTF_DLLS}) | ||||
|         add_custom_command(TARGET Snake POST_BUILD COMMAND | ||||
|             ${CMAKE_COMMAND} -E copy_if_different ${DLL} $<TARGET_FILE_DIR:Snake>) | ||||
|     endforeach() | ||||
| endif() | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| ############################################ | ||||
| ######## generate release .zip file ######## | ||||
| ############################################ | ||||
| # Generate a distributable ZIP archive for sharing the game. | ||||
| # Note: currently only intended for windows systems | ||||
| # Usage: | ||||
| #   1. Build the project: cd build && cmake .. && make | ||||
| #   2. Generate ZIP file: cpack | ||||
| #   3. Share the ZIP file for others to run the game effortlessly. | ||||
| if(WIN32) | ||||
| # generator for zip archive TODO add other generator e.g. installer | ||||
| set(CPACK_GENERATOR "ZIP") | ||||
| 
 | ||||
| # Specify to exclude the top-level directory from the archive. | ||||
| set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY ON) | ||||
| 
 | ||||
| # Specify the components to be included in the package | ||||
| install(TARGETS Snake | ||||
|         RUNTIME DESTINATION . | ||||
|         COMPONENT Runtime | ||||
| ) | ||||
| 
 | ||||
| # copy DLL files | ||||
| install(FILES ${SDL2_DLLS} ${SDL2_TTF_DLLS} | ||||
|         DESTINATION . | ||||
|         COMPONENT Runtime | ||||
| ) | ||||
| # copy assets folder | ||||
| install(DIRECTORY ${CMAKE_SOURCE_DIR}/assets | ||||
|         DESTINATION . | ||||
|         COMPONENT Assets | ||||
| ) | ||||
| 
 | ||||
| include(CPack) | ||||
| endif() | ||||
							
								
								
									
										
											BIN
										
									
								
								assets/player_scores.bin
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								assets/player_scores.bin
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -8,7 +8,7 @@ config_t config = { | ||||
|     .cycleDurationMs = 400, | ||||
|     .difficulty = 1, | ||||
|     .snakeDefaultLength = 2, | ||||
|     .leaderboardFilename = "", | ||||
|     .leaderboardFilename = "player_scores.bin", | ||||
|     //.defaultMapName = "default"      //10x10
 | ||||
|     .defaultMapName = "intermediate" //15x15
 | ||||
|     //.defaultMapName = "empty"        //20x10
 | ||||
|  | ||||
							
								
								
									
										24
									
								
								src/game.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								src/game.c
									
									
									
									
									
								
							| @ -23,10 +23,10 @@ gameData_t game = { | ||||
| 
 | ||||
| // list of audio files randomly played when food eaten
 | ||||
| const char *eatSounds[] = { | ||||
|     "../sounds/eat-bite1.wav", | ||||
|     "../sounds/eat-bite2.wav", | ||||
|     "../sounds/eat-crunch1.wav", | ||||
|     "../sounds/eat-crunch2.wav"}; | ||||
|     "assets/sounds/eat-bite1.wav", | ||||
|     "assets/sounds/eat-bite2.wav", | ||||
|     "assets/sounds/eat-crunch1.wav", | ||||
|     "assets/sounds/eat-crunch2.wav"}; | ||||
| #define EAT_SOUNDS_COUNT 4 | ||||
| 
 | ||||
| 
 | ||||
| @ -76,11 +76,11 @@ void handlePortals() | ||||
|             snakeSetHeadPos(p.targetX, p.targetY); | ||||
|             LOGI("game: entered portal i=%d at x=%d, y=%d -> set head to x=%d y=%d\n", i, p.posX, p.posY, p.targetX, p.targetY); | ||||
|             //--- play sound ---
 | ||||
|             //playSoundAsync("../sounds/portal1_short.wav"); //too short
 | ||||
|             //playSoundAsync("../sounds/portal2_oscillate.wav"); //too much bass
 | ||||
|             //playSoundAsync("../sounds/space-gun.wav"); //too loud
 | ||||
|             playSoundAsync("../sounds/portal3_in-out.wav"); | ||||
|             //playSoundAsync("../sounds/portal4_ramp.wav");
 | ||||
|             //playSoundAsync("assets/sounds/portal1_short.wav"); //too short
 | ||||
|             //playSoundAsync("assets/sounds/portal2_oscillate.wav"); //too much bass
 | ||||
|             //playSoundAsync("assets/sounds/space-gun.wav"); //too loud
 | ||||
|             playSoundAsync("assets/sounds/portal3_in-out.wav"); | ||||
|             //playSoundAsync("assets/sounds/portal4_ramp.wav");
 | ||||
|             return; | ||||
|         } | ||||
|     } | ||||
| @ -111,12 +111,12 @@ void runGameCycle() | ||||
|         // TODO consider game.lifesRemaining and reset if still good?
 | ||||
|         //--- play crash sound ---
 | ||||
|         LOGI("game: collided with wall or self! => show leaderboard\n"); | ||||
|         playSound("../sounds/crash_rock-cinematic.wav", false);  | ||||
|         playSound("assets/sounds/crash_rock-cinematic.wav", false);  | ||||
|         DELAY(200); | ||||
|         //--- leaderboard ---
 | ||||
|         //game.gameState = MENU; //TODO add config.collisionEnabled option?
 | ||||
|         savePlayerScore("../build/player_scores.bin"/*(game.snake.length - config.snakeDefaultLength), ttlStorage.userName, config.difficulty, *storedMaps[ttlStorage.userSelectedMap - 1]*/); | ||||
|         readTopScores("../build/player_scores.bin"); | ||||
|         savePlayerScore(config.leaderboardFilename/*(game.snake.length - config.snakeDefaultLength), ttlStorage.userName, config.difficulty, *storedMaps[ttlStorage.userSelectedMap - 1]*/); | ||||
|         readTopScores(config.leaderboardFilename); | ||||
|         game.gameState = MENU; | ||||
|         activeMenu = LEADERBOARD; | ||||
|         return; | ||||
|  | ||||
| @ -126,8 +126,8 @@ void renderStartMenu() | ||||
|     //=========== only first loop ================
 | ||||
|     if(ttlStorage.lastTimeStep == 0) | ||||
|     { | ||||
|         ttlStorage.ptrFont_200 = TTF_OpenFont("../fonts/Quirkus.ttf", ttlStorage.fontSize_200); | ||||
|         ttlStorage.ptrFont_30 = TTF_OpenFont("../fonts/Quirkus.ttf", ttlStorage.fontSize_30); | ||||
|         ttlStorage.ptrFont_200 = TTF_OpenFont("assets/fonts/Quirkus.ttf", ttlStorage.fontSize_200); | ||||
|         ttlStorage.ptrFont_30 = TTF_OpenFont("assets/fonts/Quirkus.ttf", ttlStorage.fontSize_30); | ||||
| 
 | ||||
| 
 | ||||
|         SDL_Color textColor1 = {255, 0, 255}; // rosa Text
 | ||||
| @ -241,7 +241,7 @@ void renderSettings() | ||||
|     //=========== only first loop ================
 | ||||
|     if(ttlStorage.lastTimeStep == 0) | ||||
|     {   | ||||
|         ttlStorage.ptrFont_20 = TTF_OpenFont("../fonts/Prototype.ttf", ttlStorage.fontSize_20); | ||||
|         ttlStorage.ptrFont_20 = TTF_OpenFont("assets/fonts/Prototype.ttf", ttlStorage.fontSize_20); | ||||
|         SDL_StartTextInput();     // start text input
 | ||||
|     } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user