Skip to content

Commit 44b389f

Browse files
authored
Merge pull request #1 from kolyaka32/Other-libraries-test
Creating better readable snake
2 parents e6cdcc6 + ecadffb commit 44b389f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2854
-473
lines changed

.gitignore

+56-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,58 @@
11
.vscode/
2-
build/
3-
extra-DLLs/
2+
3+
# Build folder
4+
build/.cmake
5+
build/CMakeFiles
6+
build/cmake_install.cmake
7+
build/CMakeCache.txt
8+
build/compile_commands.json
9+
build/Makefile
10+
build/Testing
11+
12+
# Old include libraries
413
i686-w64-mingw32/
5-
x86_64-w64-mingw32/
14+
x86_64-w64-mingw32/
15+
16+
# New include libraries
17+
lib/
18+
include/
19+
20+
# Prerequisites
21+
*.d
22+
23+
# Compiled Object files
24+
*.slo
25+
*.lo
26+
*.o
27+
*.obj
28+
29+
# Precompiled Headers
30+
*.gch
31+
*.pch
32+
33+
# Compiled Dynamic libraries
34+
*.so
35+
*.dylib
36+
*.dll
37+
38+
# Fortran module files
39+
*.mod
40+
*.smod
41+
42+
# Compiled Static libraries
43+
*.lai
44+
*.la
45+
*.a
46+
*.lib
47+
48+
# Executables
49+
*.exe
50+
*.out
51+
*.app
52+
53+
# Archieves
54+
*.7z
55+
*.zip
56+
57+
# Data files
58+
*.dat

CMakeLists.txt

+54-8
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,72 @@
11
cmake_minimum_required(VERSION 3.10)
22

3-
project(base)
3+
project(base) # Main game project
44

5-
add_executable(base
5+
# Set source files
6+
add_executable( base
7+
# Base includes and defines
8+
src/include.hpp
9+
src/define.hpp
10+
src/structs.hpp
11+
12+
# Function of initialasing all data
13+
src/init.hpp
14+
src/init.cpp
15+
16+
# Functions of loading all in-game data
17+
src/dataLoader.hpp
18+
src/dataLoader.cpp
19+
20+
# Base interface
21+
src/baseHud.hpp
22+
src/baseHud.cpp
23+
24+
# Interface of game pausing
25+
src/pause.hpp
26+
src/pause.cpp
27+
28+
# System of initialasing file loading and unloading
29+
src/initFile.hpp
30+
src/initFile.cpp
31+
32+
# In game classes
33+
src/entity.hpp
34+
src/entity.cpp
35+
36+
# Main function
637
src/main.cpp
38+
39+
# Adding game icone
40+
src/set.rc
741
)
42+
# Setting static dlls
43+
set(CMAKE_CXX_STANDARD_LIBRARIES "-static-libgcc -static-libstdc++ -lwsock32 -lws2_32 -mwindows ${CMAKE_CSS_STANDARD_LIBRARIES}")
44+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive")
845

46+
# Including external libraries
947
set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1048

11-
set(CMAKE_CXX_STANDARD_LIBRARIES "-static-libgcc -static-libstdc++ -lwsock32 -lws2_32 ${CMAKE_CSS_STANDARD_LIBRARIES}")
12-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive")
13-
49+
# Finding place of external libraries
50+
# Including SDL-family
1451
find_package(SDL2 REQUIRED)
1552
find_package(SDL2_image REQUIRED)
1653
find_package(SDL2_ttf REQUIRED)
54+
find_package(SDL2_mixer REQUIRED)
55+
# Including libzip
56+
set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/lib/cmake")
57+
find_package(libzip REQUIRED)
1758

18-
19-
target_include_directories(base
59+
# Including external included directories
60+
target_include_directories( base
2061
PUBLIC ${SDL2_INCLUDE_DIRS}
21-
PUBLIC ${SDL2IMAGE_INCLUDE_DIRS}
62+
PUBLIC ${SDL2_image_INCLUDE_DIRS}
2263
PUBLIC ${SDL2_ttf_config_path}
64+
PUBLIC ${SDL2_mixer_config_path}
65+
PUBLIC &{libzip_INCLUDE_DIRS}
2366
)
2467

68+
# Including linked libraries
2569
target_link_libraries(base PUBLIC ${SDL2_LIBRARIES} SDL2_image::SDL2_image mingw32)
2670
target_link_libraries(base PUBLIC ${SDL2_LIBRARIES} SDL2_ttf::SDL2_ttf mingw32)
71+
target_link_libraries(base PUBLIC ${SDL2_LIBRARIES} SDL2_mixer::SDL2_mixer mingw32)
72+
target_link_libraries(base PUBLIC ${libzip_LIBRARIES} libzip::zip)

build/fnt/Arial.ttf

399 KB
Binary file not shown.

img/Apple.png build/img/Apple.png

File renamed without changes.

build/img/Flag_BEL.png

5.12 KB
Loading

build/img/Flag_RUS.png

220 Bytes
Loading

build/img/Flag_RUS_IMP.png

4.93 KB
Loading

build/img/Flag_USA.png

3.01 KB
Loading

build/img/Game.ico

4.19 KB
Binary file not shown.

build/img/Poloska_pod_polzunom.png

3.71 KB
Loading

build/img/Potato.png

1.74 KB
Loading

build/img/Snake_End.png

1.23 KB
Loading

build/img/Snake_End_fat.png

1.58 KB
Loading

build/img/Snake_Head1.png

1.29 KB
Loading

build/img/Snake_Torso_fat.png

1.6 KB
Loading

build/img/Snake_TurningLeft.png

1.12 KB
Loading

build/img/Snake_TurningLeft_fat.png

1.51 KB
Loading

build/img/Snake_TurningRight.png

1.25 KB
Loading

build/img/Snake_TurningRight_fat.png

1.68 KB
Loading

build/img/Snake_head_turnL.png

1.4 KB
Loading

build/img/Snake_head_turnR.png

1.29 KB
Loading

build/img/Snake_torso.png

951 Bytes
Loading

build/img/esc_butt.png

947 Bytes
Loading

build/img/kletka_svet.png

1.81 KB
Loading

build/img/kletka_tyma.png

1.46 KB
Loading

build/img/none.png

146 Bytes
Loading

build/img/shar_polzun.png

1.41 KB
Loading

build/settings.ini

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
language = english
2+
music = 64
3+
effects = 64
4+
maxScore = 0
5+
FPS = 60
6+
width = 16
7+
height = 20
8+
move time = 200

cmake/sdl2-config-version.cmake

+45-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,54 @@
1+
# based on the files generated by CMake's write_basic_package_version_file
2+
13
# SDL2 CMake version configuration file:
2-
# This file is meant to be placed in a cmake subfolder of SDL2-devel-2.x.y-mingw
4+
# This file is meant to be placed in a cmake subfolder of SDL2-devel-2.x.y-VC
5+
6+
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../include/SDL_version.h")
7+
message(AUTHOR_WARNING "Could not find SDL_version.h. This script is meant to be placed in the root of SDL2-devel-2.x.y-VC")
8+
return()
9+
endif()
310

4-
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
5-
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL2/sdl2-config-version.cmake")
6-
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
7-
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL2/sdl2-config-version.cmake")
11+
file(READ "${CMAKE_CURRENT_LIST_DIR}/../include/SDL_version.h" _sdl_version_h)
12+
string(REGEX MATCH "#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_major_re "${_sdl_version_h}")
13+
set(_sdl_major "${CMAKE_MATCH_1}")
14+
string(REGEX MATCH "#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_version_h}")
15+
set(_sdl_minor "${CMAKE_MATCH_1}")
16+
string(REGEX MATCH "#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)" _sdl_patch_re "${_sdl_version_h}")
17+
set(_sdl_patch "${CMAKE_MATCH_1}")
18+
if(_sdl_major_re AND _sdl_minor_re AND _sdl_patch_re)
19+
set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_patch}")
820
else()
9-
set(PACKAGE_VERSION_UNSUITABLE TRUE)
21+
message(AUTHOR_WARNING "Could not extract version from SDL_version.h.")
1022
return()
1123
endif()
1224

13-
if(NOT EXISTS "${sdl2_config_path}")
14-
message(WARNING "${sdl2_config_path} does not exist: MinGW development package is corrupted")
25+
if(PACKAGE_FIND_VERSION_RANGE)
26+
# Package version must be in the requested version range
27+
if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN)
28+
OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX)
29+
OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX)))
30+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
31+
else()
32+
set(PACKAGE_VERSION_COMPATIBLE TRUE)
33+
endif()
34+
else()
35+
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
36+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
37+
else()
38+
set(PACKAGE_VERSION_COMPATIBLE TRUE)
39+
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
40+
set(PACKAGE_VERSION_EXACT TRUE)
41+
endif()
42+
endif()
43+
endif()
44+
45+
# if the using project doesn't have CMAKE_SIZEOF_VOID_P set, fail.
46+
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "")
1547
set(PACKAGE_VERSION_UNSUITABLE TRUE)
16-
return()
1748
endif()
1849

19-
include("${sdl2_config_path}")
50+
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
51+
if(NOT (CMAKE_SIZEOF_VOID_P STREQUAL "8" OR CMAKE_SIZEOF_VOID_P STREQUAL "4"))
52+
set(PACKAGE_VERSION "${PACKAGE_VERSION} (32+64bit)")
53+
set(PACKAGE_VERSION_UNSUITABLE TRUE)
54+
endif()

cmake/sdl2-config.cmake

+108-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,117 @@
11
# SDL2 CMake configuration file:
2-
# This file is meant to be placed in a cmake subfolder of SDL2-devel-2.x.y-mingw
2+
# This file is meant to be placed in a cmake subfolder of SDL2-devel-2.x.y-VC
33

4-
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
5-
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL2/sdl2-config.cmake")
6-
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
7-
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL2/sdl2-config.cmake")
4+
cmake_minimum_required(VERSION 3.0...3.5)
5+
6+
include(FeatureSummary)
7+
set_package_properties(SDL2 PROPERTIES
8+
URL "https://www.libsdl.org/"
9+
DESCRIPTION "low level access to audio, keyboard, mouse, joystick, and graphics hardware"
10+
)
11+
12+
# Copied from `configure_package_config_file`
13+
macro(set_and_check _var _file)
14+
set(${_var} "${_file}")
15+
if(NOT EXISTS "${_file}")
16+
message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
17+
endif()
18+
endmacro()
19+
20+
# Copied from `configure_package_config_file`
21+
macro(check_required_components _NAME)
22+
foreach(comp ${${_NAME}_FIND_COMPONENTS})
23+
if(NOT ${_NAME}_${comp}_FOUND)
24+
if(${_NAME}_FIND_REQUIRED_${comp})
25+
set(${_NAME}_FOUND FALSE)
26+
endif()
27+
endif()
28+
endforeach()
29+
endmacro()
30+
31+
set(SDL2_FOUND TRUE)
32+
33+
if(CMAKE_SIZEOF_VOID_P STREQUAL "4")
34+
set(_sdl_arch_subdir "x86")
35+
elseif(CMAKE_SIZEOF_VOID_P STREQUAL "8")
36+
set(_sdl_arch_subdir "x64")
837
else()
938
set(SDL2_FOUND FALSE)
1039
return()
1140
endif()
1241

13-
if(NOT EXISTS "${sdl2_config_path}")
14-
message(WARNING "${sdl2_config_path} does not exist: MinGW development package is corrupted")
15-
set(SDL2_FOUND FALSE)
16-
return()
42+
# For compatibility with autotools sdl2-config.cmake, provide SDL2_* variables.
43+
44+
set_and_check(SDL2_PREFIX "${CMAKE_CURRENT_LIST_DIR}/..")
45+
set_and_check(SDL2_EXEC_PREFIX "${CMAKE_CURRENT_LIST_DIR}/..")
46+
set_and_check(SDL2_INCLUDE_DIR "${SDL2_PREFIX}/include")
47+
set(SDL2_INCLUDE_DIRS "${SDL2_INCLUDE_DIR}")
48+
set_and_check(SDL2_BINDIR "${SDL2_PREFIX}/lib/${_sdl_arch_subdir}")
49+
set_and_check(SDL2_LIBDIR "${SDL2_PREFIX}/lib/${_sdl_arch_subdir}")
50+
51+
set(SDL2_LIBRARIES SDL2::SDL2main SDL2::SDL2)
52+
set(SDL2MAIN_LIBRARY SDL2::SDL2main)
53+
set(SDL2TEST_LIBRARY SDL2::SDL2test)
54+
55+
56+
# All targets are created, even when some might not be requested though COMPONENTS.
57+
# This is done for compatibility with CMake generated SDL2-target.cmake files.
58+
59+
set(_sdl2_library "${SDL2_LIBDIR}/SDL2.lib")
60+
set(_sdl2_dll_library "${SDL2_BINDIR}/SDL2.dll")
61+
if(EXISTS "${_sdl2_library}" AND EXISTS "${_sdl2_dll_library}")
62+
if(NOT TARGET SDL2::SDL2)
63+
add_library(SDL2::SDL2 SHARED IMPORTED)
64+
set_target_properties(SDL2::SDL2
65+
PROPERTIES
66+
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
67+
IMPORTED_IMPLIB "${_sdl2_library}"
68+
IMPORTED_LOCATION "${_sdl2_dll_library}"
69+
COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED"
70+
INTERFACE_SDL2_SHARED "ON"
71+
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
72+
INTERFACE_SDL_VERSION "SDL2"
73+
)
74+
endif()
75+
set(SDL2_SDL2_FOUND TRUE)
76+
else()
77+
set(SDL2_SDL2_FOUND FALSE)
78+
endif()
79+
unset(_sdl2_library)
80+
unset(_sdl2_dll_library)
81+
82+
set(_sdl2main_library "${SDL2_LIBDIR}/SDL2main.lib")
83+
if(EXISTS "${_sdl2main_library}")
84+
if(NOT TARGET SDL2::SDL2main)
85+
add_library(SDL2::SDL2main STATIC IMPORTED)
86+
set_target_properties(SDL2::SDL2main
87+
PROPERTIES
88+
IMPORTED_LOCATION "${_sdl2main_library}"
89+
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
90+
INTERFACE_SDL_VERSION "SDL2"
91+
)
92+
endif()
93+
set(SDL2_SDL2main_FOUND TRUE)
94+
else()
95+
set(SDL2_SDL2_FOUND FALSE)
96+
endif()
97+
unset(_sdl2main_library)
98+
99+
set(_sdl2test_library "${SDL2_LIBDIR}/SDL2test.lib")
100+
if(EXISTS "${_sdl2test_library}")
101+
if(NOT TARGET SDL2::SDL2test)
102+
add_library(SDL2::SDL2test STATIC IMPORTED)
103+
set_target_properties(SDL2::SDL2test
104+
PROPERTIES
105+
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
106+
IMPORTED_LOCATION "${_sdl2test_library}"
107+
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
108+
INTERFACE_SDL_VERSION "SDL2"
109+
)
110+
endif()
111+
set(SDL2_SDL2test_FOUND TRUE)
112+
else()
113+
set(SDL2_SDL2_FOUND FALSE)
17114
endif()
115+
unset(_sdl2test_library)
18116

19-
include("${sdl2_config_path}")
117+
check_required_components(SDL2)

0 commit comments

Comments
 (0)