Skip to content

Commit

Permalink
推箱子v1.2.3
Browse files Browse the repository at this point in the history
从C代码修改为C++代码
优化部分代码
修改部分逻辑
修改部分文件
  • Loading branch information
LanYunDev committed Jun 27, 2022
1 parent b36f747 commit 8fbb4cb
Show file tree
Hide file tree
Showing 36 changed files with 996 additions and 866 deletions.
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.22) #设置CMake的最低版本

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

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

# 在本机查找依赖
find_package(Curses REQUIRED) #查找Curses库

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

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

if (CMAKE_SYSTEM_NAME MATCHES "Darwin") #判断是否是Mac平台
target_link_libraries(${CMAKE_PROJECT_NAME} ${CURSES_LIBRARY}) #链接Curses库
Expand Down
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 前言 Foreword

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

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

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

```bash
cd src && gcc PushBox.c -o PushBox -lncurses && ./PushBox
cd src && gcc PushBox.cpp -o PushBox -lncurses && ./PushBox
```

**启动脚本命令:**

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

</details>

Expand Down
Binary file removed Release/PushBox_Linu_x64
Binary file not shown.
Binary file modified Release/PushBox_Linux_ARM
Binary file not shown.
Binary file modified Release/PushBox_Macos_ARM
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
}
],
"type" : "FILEPATH",
"value" : "/usr/bin/ar"
"value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar"
},
{
"name" : "CMAKE_BUILD_TYPE",
Expand Down Expand Up @@ -142,7 +142,7 @@
"value" : "/Applications/CLion.app/Contents/bin/cmake/mac/bin/ctest"
},
{
"name" : "CMAKE_C_COMPILER",
"name" : "CMAKE_CXX_COMPILER",
"properties" :
[
{
Expand All @@ -151,14 +151,14 @@
},
{
"name" : "HELPSTRING",
"value" : "C compiler"
"value" : "CXX compiler"
}
],
"type" : "STRING",
"value" : "/usr/bin/cc"
"type" : "FILEPATH",
"value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++"
},
{
"name" : "CMAKE_C_FLAGS",
"name" : "CMAKE_CXX_FLAGS",
"properties" :
[
{
Expand All @@ -167,14 +167,14 @@
},
{
"name" : "HELPSTRING",
"value" : "Flags used by the C compiler during all build types."
"value" : "Flags used by the CXX compiler during all build types."
}
],
"type" : "STRING",
"value" : ""
},
{
"name" : "CMAKE_C_FLAGS_DEBUG",
"name" : "CMAKE_CXX_FLAGS_DEBUG",
"properties" :
[
{
Expand All @@ -183,14 +183,14 @@
},
{
"name" : "HELPSTRING",
"value" : "Flags used by the C compiler during DEBUG builds."
"value" : "Flags used by the CXX compiler during DEBUG builds."
}
],
"type" : "STRING",
"value" : ""
"value" : "-g"
},
{
"name" : "CMAKE_C_FLAGS_MINSIZEREL",
"name" : "CMAKE_CXX_FLAGS_MINSIZEREL",
"properties" :
[
{
Expand All @@ -199,14 +199,14 @@
},
{
"name" : "HELPSTRING",
"value" : "Flags used by the C compiler during MINSIZEREL builds."
"value" : "Flags used by the CXX compiler during MINSIZEREL builds."
}
],
"type" : "STRING",
"value" : ""
"value" : "-Os -DNDEBUG"
},
{
"name" : "CMAKE_C_FLAGS_RELEASE",
"name" : "CMAKE_CXX_FLAGS_RELEASE",
"properties" :
[
{
Expand All @@ -215,14 +215,14 @@
},
{
"name" : "HELPSTRING",
"value" : "Flags used by the C compiler during RELEASE builds."
"value" : "Flags used by the CXX compiler during RELEASE builds."
}
],
"type" : "STRING",
"value" : ""
"value" : "-O3 -DNDEBUG"
},
{
"name" : "CMAKE_C_FLAGS_RELWITHDEBINFO",
"name" : "CMAKE_CXX_FLAGS_RELWITHDEBINFO",
"properties" :
[
{
Expand All @@ -231,11 +231,11 @@
},
{
"name" : "HELPSTRING",
"value" : "Flags used by the C compiler during RELWITHDEBINFO builds."
"value" : "Flags used by the CXX compiler during RELWITHDEBINFO builds."
}
],
"type" : "STRING",
"value" : ""
"value" : "-O2 -g -DNDEBUG"
},
{
"name" : "CMAKE_DLLTOOL",
Expand Down Expand Up @@ -263,7 +263,7 @@
}
],
"type" : "INTERNAL",
"value" : "Unknown"
"value" : "MACHO"
},
{
"name" : "CMAKE_EXE_LINKER_FLAGS",
Expand Down Expand Up @@ -475,7 +475,7 @@
}
],
"type" : "FILEPATH",
"value" : "/usr/bin/ld"
"value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"
},
{
"name" : "CMAKE_MAKE_PROGRAM",
Expand Down Expand Up @@ -583,7 +583,7 @@
}
],
"type" : "FILEPATH",
"value" : "/usr/bin/nm"
"value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm"
},
{
"name" : "CMAKE_NUMBER_OF_MAKEFILES",
Expand Down Expand Up @@ -627,7 +627,7 @@
}
],
"type" : "FILEPATH",
"value" : "/usr/bin/objdump"
"value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump"
},
{
"name" : "CMAKE_OSX_ARCHITECTURES",
Expand Down Expand Up @@ -662,8 +662,8 @@
"value" : "The product will be built against the headers and libraries located inside the indicated SDK."
}
],
"type" : "STRING",
"value" : ""
"type" : "PATH",
"value" : "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk"
},
{
"name" : "CMAKE_PLATFORM_INFO_INITIALIZED",
Expand Down Expand Up @@ -723,7 +723,7 @@
}
],
"type" : "STATIC",
"value" : "1.1.4"
"value" : "1.2.3"
},
{
"name" : "CMAKE_PROJECT_VERSION_MAJOR",
Expand All @@ -747,7 +747,7 @@
}
],
"type" : "STATIC",
"value" : "1"
"value" : "2"
},
{
"name" : "CMAKE_PROJECT_VERSION_PATCH",
Expand All @@ -759,7 +759,7 @@
}
],
"type" : "STATIC",
"value" : "4"
"value" : "3"
},
{
"name" : "CMAKE_PROJECT_VERSION_TWEAK",
Expand Down Expand Up @@ -787,7 +787,7 @@
}
],
"type" : "FILEPATH",
"value" : "/usr/bin/ranlib"
"value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib"
},
{
"name" : "CMAKE_READELF",
Expand Down Expand Up @@ -1023,7 +1023,7 @@
}
],
"type" : "FILEPATH",
"value" : "/usr/bin/strip"
"value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip"
},
{
"name" : "CMAKE_UNAME",
Expand Down Expand Up @@ -1067,7 +1067,7 @@
}
],
"type" : "FILEPATH",
"value" : "/opt/local/lib/libcurses.dylib"
"value" : "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/lib/libcurses.tbd"
},
{
"name" : "CURSES_FORM_LIBRARY",
Expand All @@ -1083,7 +1083,7 @@
}
],
"type" : "FILEPATH",
"value" : "/opt/local/lib/libform.dylib"
"value" : "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/lib/libform.tbd"
},
{
"name" : "CURSES_INCLUDE_PATH",
Expand All @@ -1099,7 +1099,7 @@
}
],
"type" : "PATH",
"value" : "/opt/local/include"
"value" : "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include"
},
{
"name" : "CURSES_NCURSES_LIBRARY",
Expand All @@ -1115,7 +1115,7 @@
}
],
"type" : "FILEPATH",
"value" : "/opt/local/lib/libncurses.dylib"
"value" : "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/lib/libncurses.tbd"
},
{
"name" : "FIND_PACKAGE_MESSAGE_DETAILS_Curses",
Expand All @@ -1127,7 +1127,7 @@
}
],
"type" : "INTERNAL",
"value" : "[/opt/local/lib/libcurses.dylib][/opt/local/include][v()]"
"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()]"
},
{
"name" : "NCURSES_CFLAGS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
{
"isGenerated" : true,
"path" : "cmake-build-debug/CMakeFiles/3.22.3/CMakeCCompiler.cmake"
"path" : "cmake-build-debug/CMakeFiles/3.22.3/CMakeCXXCompiler.cmake"
},
{
"isCMake" : true,
Expand Down Expand Up @@ -50,7 +50,7 @@
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.22/Modules/CMakeCInformation.cmake"
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.22/Modules/CMakeCXXInformation.cmake"
},
{
"isCMake" : true,
Expand All @@ -60,7 +60,7 @@
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.22/Modules/Compiler/AppleClang-C.cmake"
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.22/Modules/Compiler/AppleClang-CXX.cmake"
},
{
"isCMake" : true,
Expand All @@ -85,12 +85,12 @@
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.22/Modules/Platform/Apple-AppleClang-C.cmake"
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.22/Modules/Platform/Apple-AppleClang-CXX.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.22/Modules/Platform/Apple-Clang-C.cmake"
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.22/Modules/Platform/Apple-Clang-CXX.cmake"
},
{
"isCMake" : true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{
"directoryIndex" : 0,
"id" : "PushBox::@6890427a1f51a3e7e1df",
"jsonFile" : "target-PushBox-Debug-638460a8165858b15d40.json",
"jsonFile" : "target-PushBox-Debug-3ce21134addee10a65d1.json",
"name" : "PushBox",
"projectIndex" : 0
}
Expand Down
Loading

0 comments on commit 8fbb4cb

Please sign in to comment.