Skip to content

Commit b1ad032

Browse files
committed
Removed a lot of stuff and cleaned up some of the code
1 parent b21230e commit b1ad032

47 files changed

Lines changed: 247 additions & 2178 deletions

Some content is hidden

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

.github/workflows/build.yml

Lines changed: 1 addition & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -10,59 +10,31 @@ jobs:
1010
- {
1111
name: "SDL3 - Linux (x64)",
1212
os: "ubuntu-latest",
13-
cFlags: "",
1413
impl: "SDL3",
1514
output: "BlockBreakC-SDL3-Linux-x64",
1615
upload: "BlockBreakC"
1716
}
1817
- {
1918
name: "FreeGLUT (GLUT) - Linux (x64)",
2019
os: "ubuntu-latest",
21-
cFlags: "",
2220
impl: "GLUT",
2321
output: "BlockBreakC-FreeGLUT-Linux-x64",
2422
upload: "BlockBreakC"
2523
}
26-
- {
27-
name: "GLFW3 - Linux (x64)",
28-
os: "ubuntu-latest",
29-
cFlags: "",
30-
impl: "GLFW3",
31-
output: "BlockBreakC-GLFW3-Linux-x64",
32-
upload: "BlockBreakC"
33-
}
3424
- {
3525
name: "SDL3 + GL - Linux (x64)",
3626
os: "ubuntu-latest",
37-
cFlags: "",
3827
impl: "SDL3GL",
3928
output: "BlockBreakC-SDL3GL-Linux-x64",
4029
upload: "BlockBreakC"
4130
}
42-
- {
43-
name: "raylib - Linux (x64)",
44-
os: "ubuntu-latest",
45-
cFlags: "",
46-
impl: "raylib",
47-
output: "BlockBreakC-raylib-Linux-x64",
48-
upload: "BlockBreakC",
49-
raylibVersion: "5.5"
50-
}
51-
- {
52-
name: "Xlib - Linux (x64)",
53-
os: "ubuntu-latest",
54-
cFlags: "",
55-
impl: "Xlib",
56-
output: "BlockBreakC-Xlib-Linux-x64",
57-
upload: "BlockBreakC"
58-
}
5931
steps:
6032
- uses: actions/checkout@v4
6133

6234
- name: Update Package Lists
6335
run: sudo apt-get update
6436

65-
# SDL3
37+
# SDL3 (+ GL)
6638
- uses: libsdl-org/setup-sdl@main
6739
if: ${{matrix.build-targets.impl == 'SDL3' || matrix.build-targets.impl == 'SDL3GL'}}
6840
id: sdl
@@ -75,89 +47,12 @@ jobs:
7547
if: matrix.build-targets.impl == 'GLUT'
7648
run: sudo apt-get install freeglut3-dev
7749

78-
# GLFW3
79-
- name: GLFW3 - Install Dependencies
80-
if: matrix.build-targets.impl == 'GLFW3'
81-
run: sudo apt-get install libwayland-dev libxkbcommon-dev xorg-dev
82-
83-
- name: GLFW3 - Clone
84-
if: matrix.build-targets.impl == 'GLFW3'
85-
run: >
86-
git clone
87-
--depth 1
88-
https://github.com/glfw/glfw.git
89-
90-
- name: GLFW3 - Configure CMake
91-
if: matrix.build-targets.impl == 'GLFW3'
92-
run: >
93-
cmake -S glfw
94-
-B build/GLFW3
95-
-DCMAKE_C_COMPILER=gcc
96-
-DCMAKE_BUILD_TYPE=Release
97-
-DBUILD_SHARED_LIBS=ON
98-
-DGLFW_BUILD_EXAMPLES=OFF
99-
-DGLFW_BUILD_TESTS=OFF
100-
-DGLFW_BUILD_DOCS=OFF
101-
-DCMAKE_C_FLAGS=${{matrix.build-targets.cFlags}}
102-
-G "Unix Makefiles"
103-
104-
- name: GLFW3 - Build
105-
if: matrix.build-targets.impl == 'GLFW3'
106-
run: cmake --build build/GLFW3
107-
108-
- name: GLFW3 - Install
109-
if: matrix.build-targets.impl == 'GLFW3'
110-
run: sudo cmake --install build/GLFW3
111-
112-
# raylib
113-
- name: raylib - Install Dependencies
114-
if: matrix.build-targets.impl == 'raylib'
115-
run: >
116-
sudo apt-get install libasound2-dev libx11-dev libxrandr-dev libxi-dev
117-
libgl1-mesa-dev libglu1-mesa-dev libxcursor-dev libxinerama-dev libwayland-dev
118-
libxkbcommon-dev
119-
120-
- name: raylib - Clone
121-
if: matrix.build-targets.impl == 'raylib'
122-
run: >
123-
git clone
124-
--branch ${{matrix.build-targets.raylibVersion}}
125-
--depth 1
126-
https://github.com/raysan5/raylib.git
127-
128-
- name: raylib - Configure CMake
129-
if: matrix.build-targets.impl == 'raylib'
130-
run: >
131-
cmake -S raylib
132-
-B build/raylib
133-
-DCMAKE_C_COMPILER=gcc
134-
-DCMAKE_BUILD_TYPE=Release
135-
-DBUILD_SHARED_LIBS=ON
136-
-DBUILD_EXAMPLES=OFF
137-
-DCMAKE_C_FLAGS=${{matrix.build-targets.cFlags}}
138-
-G "Unix Makefiles"
139-
140-
- name: raylib - Build
141-
if: matrix.build-targets.impl == 'raylib'
142-
run: cmake --build build/raylib
143-
144-
- name: raylib - Install
145-
if: matrix.build-targets.impl == 'raylib'
146-
run: sudo cmake --install build/raylib
147-
148-
# Xlib
149-
- name: Xlib - Install
150-
if: matrix.build-targets.impl == 'Xlib'
151-
run: sudo apt-get install xorg-dev
152-
15350
- name: Configure CMake
15451
run: >
15552
cmake -S .
15653
-DCMAKE_C_COMPILER=gcc
15754
-DCMAKE_BUILD_TYPE=Release
158-
-DBUILD_SHARED_LIBS=OFF
15955
-DIMPL=${{matrix.build-targets.impl}}
160-
-DCMAKE_C_FLAGS=${{matrix.build-targets.cFlags}}
16156
-G "Unix Makefiles"
16257
16358
- name: Build

CMakeLists.txt

Lines changed: 79 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,53 @@ cmake_minimum_required(VERSION 3.12)
22

33
set(CMAKE_C_STANDARD 99)
44
set(CMAKE_C_STANDARD_REQUIRED TRUE)
5-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
6-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
75

8-
project(BlockBreakC LANGUAGES C VERSION 1.2)
6+
project(BlockBreakC LANGUAGES C VERSION 1.3)
97

10-
set(IMPL "GLFW3" CACHE STRING "The implementation to build with")
8+
set(IMPL "SDL3" CACHE STRING "The implementation to build with")
119
set(HSSIMPL "libc" CACHE STRING "The high score saving implementation to build with")
12-
set(SIMPL "Dummy" CACHE STRING "The screenshot implementation to build with")
1310
option(BUILD_SHARED_LIBS "Build the libraries as shared libraries" OFF)
14-
option(BUILD_ONLY_IMPL "Build only the implementation library" OFF)
15-
option(BUILD_AS_LIBRARY "Build the game as a library" OFF)
1611
option(BUILD_FOR_I586 "Build ${PROJECT_NAME} for i586 (Intel Pentium) or higher" OFF)
17-
option(ENABLE_SCREENSHOT "Enables taking screenshots" OFF)
18-
option(USE_BLOCKSIZELIST "Uses the block size list instead of doing the block size calculations at runtime" OFF)
1912
# Windows Compiler Options
2013
option(BUILD_USING_MSVCRT20 "Build ${PROJECT_NAME} using msvcrt20 (Windows Compiler Only)" OFF)
21-
option(BUILD_WITH_RES "Build with the resource file (Windows Compiler Only)" ON)
2214

23-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MD")
24-
25-
include(TestBigEndian)
26-
TEST_BIG_ENDIAN(BIG_ENDIAN)
27-
if (BIG_ENDIAN)
28-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBIG_ENDIAN")
29-
endif()
30-
31-
if(
32-
NOT IMPL STREQUAL "DJGPP"
33-
AND
34-
NOT ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "mips"
35-
)
36-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
37-
endif()
38-
39-
if(IMPL STREQUAL "DJGPP")
40-
set(CMAKE_C_COMPILER "i586-pc-msdosdjgpp-gcc")
41-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DRENDER_WIDTH=320 -DRENDER_HEIGHT=200 -DFONT_WIDTH=8 -DFONT_HEIGHT=8 -DPLAYER_HEIGHT=7 -DPLAYER_SPEED=4 -DFILENAME83")
42-
elseif(IMPL STREQUAL "Xlib")
43-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFONT_HEIGHT=10")
15+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFONT_WIDTH=8 -DFONT_HEIGHT=8")
16+
17+
# Impl
18+
if(IMPL STREQUAL "SDL3")
19+
find_package(SDL3 REQUIRED)
20+
set(IMPL_FILE "sdl3.c")
21+
elseif(IMPL STREQUAL "GLUT")
22+
find_package(OpenGL REQUIRED)
23+
find_package(GLUT REQUIRED)
24+
include_directories(
25+
${OPENGL_INCLUDE_DIRS}
26+
${GLUT_INCLUDE_DIR}
27+
)
28+
set(IMPL_FILE "glut.c")
29+
elseif(IMPL STREQUAL "SDL3GL")
30+
find_package(SDL3 REQUIRED)
31+
find_package(OpenGL REQUIRED)
32+
include_directories(${OPENGL_INCLUDE_DIRS})
33+
set(IMPL_FILE "sdl3GL.c")
4434
elseif(IMPL STREQUAL "citro2d")
4535
if (NINTENDO_3DS)
46-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DRENDER_WIDTH=400 -DRENDER_HEIGHT=240 -DFONT_WIDTH=8 -DFONT_HEIGHT=8 -DPLAYER_SPEED=5")
36+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DRENDER_WIDTH=400 -DRENDER_HEIGHT=240 -DPLAYER_SPEED=5")
4737
else()
48-
message(FATAL_ERROR "To build the citro2d implementation you must be using the devkitPro 3DS toolchain: -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/cmake/3DS.cmake")
38+
message(FATAL_ERROR "To build the citro2d implementation you must be using the devkitPro 3DS/2DS toolchain: -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/cmake/3DS.cmake")
4939
endif()
40+
set(IMPL_FILE "citro2d.c")
5041
else()
51-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFONT_WIDTH=8 -DFONT_HEIGHT=8")
42+
message(FATAL_ERROR "Invalid implementation, the possible values are \"SDL3\", \"GLUT\", \"SDL3GL\" or \"citro2d\"")
5243
endif()
5344

54-
if(ENABLE_SCREENSHOT)
55-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_SCREENSHOT")
56-
endif()
57-
58-
if(USE_BLOCKSIZELIST)
59-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_BLOCKSIZELIST")
45+
# HSSImpl
46+
if(HSSIMPL STREQUAL "libc")
47+
set(HSSIMPL_FILE "libc.c")
48+
elseif(HSSIMPL STREQUAL "Dummy")
49+
set(HSSIMPL_FILE "dummy.c")
50+
else()
51+
message(FATAL_ERROR "Invalid high score implementation, the possible values are \"libc\" or \"Dummy\"")
6052
endif()
6153

6254
set(CMAKE_C_FLAGS_DEBUG "-g -Wall")
@@ -74,68 +66,66 @@ endif()
7466

7567
if(WIN32)
7668
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-subsystem,windows")
77-
if(BUILD_WITH_RES)
78-
set(RESOURCE_FILES "src/res/resource.rc")
79-
endif()
69+
set(RESOURCE_FILES "src/res/resource.rc")
8070
if(BUILD_USING_MSVCRT20)
8171
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcrtdll=msvcrt20")
8272
endif()
8373
elseif(NOT WIN32 AND BUILD_USING_MSVCRT20)
8474
message(FATAL_ERROR "To build using msvcrt20 you must be using a Windows C compiler")
8575
endif()
8676

87-
include_directories(
88-
"src"
89-
"src/impl"
90-
"src/impl/highScore"
91-
"src/impl/screenshot"
92-
"src/shared"
93-
)
94-
95-
add_subdirectory(src/impl)
96-
if(ENABLE_SCREENSHOT)
97-
add_subdirectory(src/impl/screenshot)
98-
endif()
99-
100-
file(GLOB SHARED_SOURCE_FILES "src/shared/*.c")
77+
include_directories("src")
10178

102-
add_library(Shared ${SHARED_SOURCE_FILES})
79+
file(GLOB SOURCE_FILES "src/*.c")
10380

104-
if(ENABLE_SCREENSHOT)
105-
target_link_libraries(Shared SImpl)
106-
endif()
107-
108-
if(NOT BUILD_ONLY_IMPL)
109-
add_subdirectory(src/impl/highScore)
110-
111-
file(GLOB SOURCE_FILES "src/*.c")
81+
add_executable(
82+
${PROJECT_NAME}
83+
"src/impl/${IMPL_FILE}"
84+
"src/hssImpl/${HSSIMPL_FILE}"
85+
${RESOURCE_FILES}
86+
${SOURCE_FILES}
87+
)
88+
if(IMPL STREQUAL "SDL3")
89+
target_link_libraries(${PROJECT_NAME} SDL3::SDL3)
90+
elseif(IMPL STREQUAL "GLUT")
91+
target_link_libraries(
92+
${PROJECT_NAME}
93+
${OPENGL_LIBRARY}
94+
)
11295

113-
if(BUILD_AS_LIBRARY)
114-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBLOCKBREAKC_MAIN_NAME=blockBreakC_main")
115-
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES})
96+
if (BUILD_USING_MSVCRT20)
97+
target_link_libraries(${PROJECT_NAME} libglut.a)
11698
else()
117-
add_executable(${PROJECT_NAME} ${RESOURCE_FILES} ${SOURCE_FILES})
118-
if(IMPL STREQUAL "DJGPP")
119-
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".exe")
120-
elseif(IMPL STREQUAL "citro2d")
121-
ctr_generate_smdh(${PROJECT_NAME}.smdh
122-
NAME "${PROJECT_NAME}"
123-
DESCRIPTION "A simple game originally made in JavaScript + jQuery"
124-
VERSION "v${PROJECT_VERSION}pre"
125-
AUTHOR "StevenSYS"
126-
ICON "src/res/icon.png"
127-
)
128-
ctr_create_3dsx(${PROJECT_NAME} SMDH ${PROJECT_NAME}.smdh)
129-
endif()
99+
target_link_libraries(${PROJECT_NAME} ${GLUT_glut_LIBRARY})
100+
endif()
101+
102+
if (APPLE)
103+
target_link_libraries(${PROJECT_NAME} "-framework OpenGL")
130104
endif()
105+
elseif(IMPL STREQUAL "SDL3GL")
131106
target_link_libraries(
132107
${PROJECT_NAME}
133-
Impl
134-
HSSImpl
135-
Shared
108+
SDL3::SDL3
109+
${OPENGL_LIBRARY}
136110
)
137-
if(ENABLE_SCREENSHOT)
138-
target_link_libraries(${PROJECT_NAME} SImpl)
111+
112+
if (APPLE)
113+
target_link_libraries(${PROJECT_NAME} "-framework OpenGL")
139114
endif()
140-
set_property(TARGET ${PROJECT_NAME} PROPERTY BUILD_RPATH ".")
141-
endif()
115+
elseif(IMPL STREQUAL "citro2d")
116+
ctr_generate_smdh(${PROJECT_NAME}.smdh
117+
NAME "${PROJECT_NAME}"
118+
DESCRIPTION "A simple game originally made in JavaScript + jQuery"
119+
VERSION "v${PROJECT_VERSION}pre"
120+
AUTHOR "StevenSYS"
121+
ICON "src/res/icon.png"
122+
)
123+
ctr_create_3dsx(${PROJECT_NAME} SMDH ${PROJECT_NAME}.smdh)
124+
target_link_libraries(
125+
${PROJECT_NAME}
126+
citro2d
127+
citro3d
128+
ctru
129+
)
130+
endif()
131+
set_property(TARGET ${PROJECT_NAME} PROPERTY BUILD_RPATH ".")

0 commit comments

Comments
 (0)