Skip to content

Commit 8fbb4cb

Browse files
committed
推箱子v1.2.3
从C代码修改为C++代码 优化部分代码 修改部分逻辑 修改部分文件
1 parent b36f747 commit 8fbb4cb

36 files changed

Lines changed: 996 additions & 866 deletions

CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
cmake_minimum_required(VERSION 3.22) #设置CMake的最低版本
22

33
project(PushBox
4-
LANGUAGES C
5-
VERSION 1.1.4
4+
LANGUAGES CXX
5+
VERSION 1.2.3
66
DESCRIPTION "免费,开源,推箱子小游戏.A Free, Open Source, PushBox Game."
77
HOMEPAGE_URL https://github.com/LanYunDev/PushBox
88
) #设置项目名称,语言类型,项目版本号,项目描述,项目主页。
@@ -33,10 +33,11 @@ if (NOT DEFINED BUILD_SHARED_LIBS) #判断是否定义变量BUILD_SHARED_LIBS
3333
set(BUILD_SHARED_LIBS ON) #如果没有,则设置为ON
3434
endif () #结束
3535

36-
set(CMAKE_C_STANDARD 23) #设置C语言标准为C 23
37-
set(CMAKE_C_STANDARD_REQUIRED ON) #编译器必须支持C 23,否则出错
38-
set(CMAKE_C_EXTENSIONS ON) #开启GCC编译器对C语言扩展,只支持GCC编译器,降低对(Windows平台的)MSVC的兼容性
36+
set(CMAKE_CXX_STANDARD 23) #设置C++语言标准为C++23
37+
#set(CMAKE_CXX_STANDARD_REQUIRED ON) #编译器必须支持C++23,否则出错
38+
set(CMAKE_CXX_EXTENSIONS ON) #开启GCC编译器对C语言扩展,只支持GCC编译器,降低对(Windows平台的)MSVC的兼容性
3939

40+
# 在本机查找依赖
4041
find_package(Curses REQUIRED) #查找Curses库
4142

4243
include_directories(${CURSES_INCLUDE_DIR}) #添加Curses库的头文件目录
@@ -46,8 +47,9 @@ file(GLOB SRC_FILES CONFIGURE_DEPENDS
4647
"${PROJECT_SOURCE_DIR}/src/*.c"
4748
"${PROJECT_SOURCE_DIR}/src/*.h"
4849
) #GLOB自动查找当前目录下指定拓展名的文件📃,实现批量添加源文件。添加CONFIGURE_DEPENDS选项,当添加新文件或源文件发生变化时,CMake会自动重新编译项目。
50+
#${SRC_FILES}
4951

50-
add_executable(${CMAKE_PROJECT_NAME} ${SRC_FILES} include/PushBox.h) #可执行文件名为PushBox,源文件为PushBox.c
52+
add_executable(${CMAKE_PROJECT_NAME} src/PushBox.cpp include/PushBox.h) #可执行文件名为PushBox,源文件为PushBox.c
5153

5254
if (CMAKE_SYSTEM_NAME MATCHES "Darwin") #判断是否是Mac平台
5355
target_link_libraries(${CMAKE_PROJECT_NAME} ${CURSES_LIBRARY}) #链接Curses库

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## 前言 Foreword
22

3-
这个是我学校工程实践的作业.作业采用C语言编写,语言标准C23,采用全程采用Clion作为我的IDE进行编写和调试.
3+
这个是我学校工程实践的作业.作业采用C++语言编写,语言标准C++23,采用全程采用Clion作为我的IDE进行编写和调试.
44

55
如果你遇到一些坑,可以参考一下我的CMakeLists.txt文件或者在尝试我博客中寻找解决办法.
66

@@ -70,14 +70,11 @@ chmod +x 启动脚本.sh && ./启动脚本.sh
7070
如果没有Ninja生成器,可以去掉`-G Ninja`参数。
7171

7272
```bash
73-
cd src && gcc PushBox.c -o PushBox -lncurses && ./PushBox
73+
cd src && gcc PushBox.cpp -o PushBox -lncurses && ./PushBox
7474
```
7575

76-
**启动脚本命令:**
77-
78-
```bash
79-
chmod +x 启动脚本.sh && ./启动脚本.sh
80-
```
76+
若需更新,下载最新版覆盖本项目,或更新相关内容,删除build文件夹即可。
77+
对于macOS用户而言,安装`brew`是启动脚本能够正确运行的必要条件之一。
8178

8279
</details>
8380

Release/PushBox_Linu_x64

-22.4 KB
Binary file not shown.

Release/PushBox_Linux_ARM

-136 Bytes
Binary file not shown.

Release/PushBox_Macos_ARM

48 Bytes
Binary file not shown.

cmake-build-debug/.cmake/api/v1/reply/cache-v2-78609689bc4d4ff6b034.json renamed to cmake-build-debug/.cmake/api/v1/reply/cache-v2-8a99cfe55e3606e2bede.json

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
}
4444
],
4545
"type" : "FILEPATH",
46-
"value" : "/usr/bin/ar"
46+
"value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar"
4747
},
4848
{
4949
"name" : "CMAKE_BUILD_TYPE",
@@ -142,7 +142,7 @@
142142
"value" : "/Applications/CLion.app/Contents/bin/cmake/mac/bin/ctest"
143143
},
144144
{
145-
"name" : "CMAKE_C_COMPILER",
145+
"name" : "CMAKE_CXX_COMPILER",
146146
"properties" :
147147
[
148148
{
@@ -151,14 +151,14 @@
151151
},
152152
{
153153
"name" : "HELPSTRING",
154-
"value" : "C compiler"
154+
"value" : "CXX compiler"
155155
}
156156
],
157-
"type" : "STRING",
158-
"value" : "/usr/bin/cc"
157+
"type" : "FILEPATH",
158+
"value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++"
159159
},
160160
{
161-
"name" : "CMAKE_C_FLAGS",
161+
"name" : "CMAKE_CXX_FLAGS",
162162
"properties" :
163163
[
164164
{
@@ -167,14 +167,14 @@
167167
},
168168
{
169169
"name" : "HELPSTRING",
170-
"value" : "Flags used by the C compiler during all build types."
170+
"value" : "Flags used by the CXX compiler during all build types."
171171
}
172172
],
173173
"type" : "STRING",
174174
"value" : ""
175175
},
176176
{
177-
"name" : "CMAKE_C_FLAGS_DEBUG",
177+
"name" : "CMAKE_CXX_FLAGS_DEBUG",
178178
"properties" :
179179
[
180180
{
@@ -183,14 +183,14 @@
183183
},
184184
{
185185
"name" : "HELPSTRING",
186-
"value" : "Flags used by the C compiler during DEBUG builds."
186+
"value" : "Flags used by the CXX compiler during DEBUG builds."
187187
}
188188
],
189189
"type" : "STRING",
190-
"value" : ""
190+
"value" : "-g"
191191
},
192192
{
193-
"name" : "CMAKE_C_FLAGS_MINSIZEREL",
193+
"name" : "CMAKE_CXX_FLAGS_MINSIZEREL",
194194
"properties" :
195195
[
196196
{
@@ -199,14 +199,14 @@
199199
},
200200
{
201201
"name" : "HELPSTRING",
202-
"value" : "Flags used by the C compiler during MINSIZEREL builds."
202+
"value" : "Flags used by the CXX compiler during MINSIZEREL builds."
203203
}
204204
],
205205
"type" : "STRING",
206-
"value" : ""
206+
"value" : "-Os -DNDEBUG"
207207
},
208208
{
209-
"name" : "CMAKE_C_FLAGS_RELEASE",
209+
"name" : "CMAKE_CXX_FLAGS_RELEASE",
210210
"properties" :
211211
[
212212
{
@@ -215,14 +215,14 @@
215215
},
216216
{
217217
"name" : "HELPSTRING",
218-
"value" : "Flags used by the C compiler during RELEASE builds."
218+
"value" : "Flags used by the CXX compiler during RELEASE builds."
219219
}
220220
],
221221
"type" : "STRING",
222-
"value" : ""
222+
"value" : "-O3 -DNDEBUG"
223223
},
224224
{
225-
"name" : "CMAKE_C_FLAGS_RELWITHDEBINFO",
225+
"name" : "CMAKE_CXX_FLAGS_RELWITHDEBINFO",
226226
"properties" :
227227
[
228228
{
@@ -231,11 +231,11 @@
231231
},
232232
{
233233
"name" : "HELPSTRING",
234-
"value" : "Flags used by the C compiler during RELWITHDEBINFO builds."
234+
"value" : "Flags used by the CXX compiler during RELWITHDEBINFO builds."
235235
}
236236
],
237237
"type" : "STRING",
238-
"value" : ""
238+
"value" : "-O2 -g -DNDEBUG"
239239
},
240240
{
241241
"name" : "CMAKE_DLLTOOL",
@@ -263,7 +263,7 @@
263263
}
264264
],
265265
"type" : "INTERNAL",
266-
"value" : "Unknown"
266+
"value" : "MACHO"
267267
},
268268
{
269269
"name" : "CMAKE_EXE_LINKER_FLAGS",
@@ -475,7 +475,7 @@
475475
}
476476
],
477477
"type" : "FILEPATH",
478-
"value" : "/usr/bin/ld"
478+
"value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"
479479
},
480480
{
481481
"name" : "CMAKE_MAKE_PROGRAM",
@@ -583,7 +583,7 @@
583583
}
584584
],
585585
"type" : "FILEPATH",
586-
"value" : "/usr/bin/nm"
586+
"value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm"
587587
},
588588
{
589589
"name" : "CMAKE_NUMBER_OF_MAKEFILES",
@@ -627,7 +627,7 @@
627627
}
628628
],
629629
"type" : "FILEPATH",
630-
"value" : "/usr/bin/objdump"
630+
"value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump"
631631
},
632632
{
633633
"name" : "CMAKE_OSX_ARCHITECTURES",
@@ -662,8 +662,8 @@
662662
"value" : "The product will be built against the headers and libraries located inside the indicated SDK."
663663
}
664664
],
665-
"type" : "STRING",
666-
"value" : ""
665+
"type" : "PATH",
666+
"value" : "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk"
667667
},
668668
{
669669
"name" : "CMAKE_PLATFORM_INFO_INITIALIZED",
@@ -723,7 +723,7 @@
723723
}
724724
],
725725
"type" : "STATIC",
726-
"value" : "1.1.4"
726+
"value" : "1.2.3"
727727
},
728728
{
729729
"name" : "CMAKE_PROJECT_VERSION_MAJOR",
@@ -747,7 +747,7 @@
747747
}
748748
],
749749
"type" : "STATIC",
750-
"value" : "1"
750+
"value" : "2"
751751
},
752752
{
753753
"name" : "CMAKE_PROJECT_VERSION_PATCH",
@@ -759,7 +759,7 @@
759759
}
760760
],
761761
"type" : "STATIC",
762-
"value" : "4"
762+
"value" : "3"
763763
},
764764
{
765765
"name" : "CMAKE_PROJECT_VERSION_TWEAK",
@@ -787,7 +787,7 @@
787787
}
788788
],
789789
"type" : "FILEPATH",
790-
"value" : "/usr/bin/ranlib"
790+
"value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib"
791791
},
792792
{
793793
"name" : "CMAKE_READELF",
@@ -1023,7 +1023,7 @@
10231023
}
10241024
],
10251025
"type" : "FILEPATH",
1026-
"value" : "/usr/bin/strip"
1026+
"value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip"
10271027
},
10281028
{
10291029
"name" : "CMAKE_UNAME",
@@ -1067,7 +1067,7 @@
10671067
}
10681068
],
10691069
"type" : "FILEPATH",
1070-
"value" : "/opt/local/lib/libcurses.dylib"
1070+
"value" : "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/lib/libcurses.tbd"
10711071
},
10721072
{
10731073
"name" : "CURSES_FORM_LIBRARY",
@@ -1083,7 +1083,7 @@
10831083
}
10841084
],
10851085
"type" : "FILEPATH",
1086-
"value" : "/opt/local/lib/libform.dylib"
1086+
"value" : "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/lib/libform.tbd"
10871087
},
10881088
{
10891089
"name" : "CURSES_INCLUDE_PATH",
@@ -1099,7 +1099,7 @@
10991099
}
11001100
],
11011101
"type" : "PATH",
1102-
"value" : "/opt/local/include"
1102+
"value" : "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include"
11031103
},
11041104
{
11051105
"name" : "CURSES_NCURSES_LIBRARY",
@@ -1115,7 +1115,7 @@
11151115
}
11161116
],
11171117
"type" : "FILEPATH",
1118-
"value" : "/opt/local/lib/libncurses.dylib"
1118+
"value" : "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/lib/libncurses.tbd"
11191119
},
11201120
{
11211121
"name" : "FIND_PACKAGE_MESSAGE_DETAILS_Curses",
@@ -1127,7 +1127,7 @@
11271127
}
11281128
],
11291129
"type" : "INTERNAL",
1130-
"value" : "[/opt/local/lib/libcurses.dylib][/opt/local/include][v()]"
1130+
"value" : "[/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/lib/libcurses.tbd][/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include][v()]"
11311131
},
11321132
{
11331133
"name" : "NCURSES_CFLAGS",

cmake-build-debug/.cmake/api/v1/reply/cmakeFiles-v1-44adb284786399516791.json renamed to cmake-build-debug/.cmake/api/v1/reply/cmakeFiles-v1-aad4a595d257e0954c42.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
{
2222
"isGenerated" : true,
23-
"path" : "cmake-build-debug/CMakeFiles/3.22.3/CMakeCCompiler.cmake"
23+
"path" : "cmake-build-debug/CMakeFiles/3.22.3/CMakeCXXCompiler.cmake"
2424
},
2525
{
2626
"isCMake" : true,
@@ -50,7 +50,7 @@
5050
{
5151
"isCMake" : true,
5252
"isExternal" : true,
53-
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.22/Modules/CMakeCInformation.cmake"
53+
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.22/Modules/CMakeCXXInformation.cmake"
5454
},
5555
{
5656
"isCMake" : true,
@@ -60,7 +60,7 @@
6060
{
6161
"isCMake" : true,
6262
"isExternal" : true,
63-
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.22/Modules/Compiler/AppleClang-C.cmake"
63+
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.22/Modules/Compiler/AppleClang-CXX.cmake"
6464
},
6565
{
6666
"isCMake" : true,
@@ -85,12 +85,12 @@
8585
{
8686
"isCMake" : true,
8787
"isExternal" : true,
88-
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.22/Modules/Platform/Apple-AppleClang-C.cmake"
88+
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.22/Modules/Platform/Apple-AppleClang-CXX.cmake"
8989
},
9090
{
9191
"isCMake" : true,
9292
"isExternal" : true,
93-
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.22/Modules/Platform/Apple-Clang-C.cmake"
93+
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.22/Modules/Platform/Apple-Clang-CXX.cmake"
9494
},
9595
{
9696
"isCMake" : true,

cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-40decc4139d75523ebfc.json renamed to cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-35784163edd2a586cf82.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
{
4040
"directoryIndex" : 0,
4141
"id" : "PushBox::@6890427a1f51a3e7e1df",
42-
"jsonFile" : "target-PushBox-Debug-638460a8165858b15d40.json",
42+
"jsonFile" : "target-PushBox-Debug-3ce21134addee10a65d1.json",
4343
"name" : "PushBox",
4444
"projectIndex" : 0
4545
}

0 commit comments

Comments
 (0)