Skip to content

Commit 789bc74

Browse files
committed
推箱子v1.1.5
优化了启动脚本 优化了CMake配置 优化了README.md 针对Linux某些平台进行了优化
1 parent ae274c0 commit 789bc74

6 files changed

Lines changed: 96 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ chmod +x 启动脚本.sh && ./启动脚本.sh
9292

9393
- [x] 无限回滚操作
9494
- [ ] 自动寻路算法
95-
- [ ] 支持直接链接编译
95+
- [x] 支持自动链接编译
9696
- [ ] 自动生成地图文件
9797
- [ ] 优化代码及其性能
9898
- [ ] 支持3D图形化显示

Release/PushBox_Linux

-23.8 KB
Binary file not shown.

Release/PushBox_Macos

-51.1 KB
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Start testing: May 20 00:05 CST
1+
Start testing: May 26 15:41 CST
22
----------------------------------------------------------
3-
End testing: May 20 00:05 CST
3+
End testing: May 26 15:41 CST

src/PushBox.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#pragma clang diagnostic push
33
#pragma ide diagnostic ignored "cert-err34-c"
44
//推箱子小游戏 Powered By LanYun
5+
//推箱子专业网站: http://sokoban.ws/
56
#include <ncurses.h>//对于代码内容关于ncurses.h库那些函数不太明白可以看看我写的[这篇文章](https://lanyundev.vercel.app/posts/a5945d21.html)噢
67
#include <stdlib.h>//声明了数值与字符串转换函数, 伪随机数生成函数, 动态内存分配函数, 进程控制函数等公共函数.
78
#include <locale.h> // 定义了特定地域的设置,实际上为了让程序在不同地域下运行,需要在程序开始处调用setlocale()函数。

启动脚本.sh

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,79 @@
44
# Blog: https://lanyundev.vercel.app
55
# Email: zestlanyun@gmail.com
66

7+
# 注由于会使用github仓库的clone,如果感觉很慢,所以请使用科学上网.
8+
79
# 建议不要修改文件夹名,👇下面这段代码用于判断本脚本是否处于当前项目的根目录
8-
if [[ "`basename "$PWD"`" != "PushBox" ]]; then
10+
Catalog=$PWD
11+
if [[ "`basename "$Catalog"`" != "PushBox" ]]; then
912
echo "请确保本脚本位于本项目根目录处运行以便程序能够正常运行"
1013
echo "本程序当前运行目录:$PWD"
1114
echo "若你只修改了文件夹📁名,那么请按任意键继续."
12-
read -s -n 1 -p "按任意键继续.按q退出.30秒超时自动继续." -t 30 input
15+
read -s -n 1 -p "按任意键继续.按q键退出.30秒超时自动继续." -t 30 input
1316
if [[ $input == "q" || $input == "Q" ]]; then
1417
exit 0
1518
fi
1619
fi
1720

21+
# 检测CMake是否存在,若不存在就安装
22+
if ! command -v cmake >/dev/null 2>&1; then
23+
echo "发现你的系统环境未安装CMake,即将尝试自动安装."
24+
if [[ "$(uname)" == "Darwin" || `uname -a` =~ "Darwin" ]]; then
25+
echo "为避免您的系统环境过旧,即将尝试更新你的系统环境."
26+
read -s -n 1 -p "按q键取消.否则3秒后自动开始." -t 3 input
27+
if [[ $input == "q" || $input == "Q" ]]; then
28+
echo "取消成功!"
29+
else brew update && brew upgrade && brew cleanup
30+
fi
31+
brew install cmake
32+
elif [[ `uname -a` =~ "Manjaro" ]]; then
33+
echo "为避免您的系统环境过旧,即将尝试更新你的系统环境."
34+
read -s -n 1 -p "按q键取消.否则3秒后自动开始." -t 3 input
35+
if [[ $input == "q" || $input == "Q" ]]; then
36+
echo "取消成功!"
37+
else sudo pacman -Syu
38+
fi
39+
sudo pacman -S cmake
40+
elif [[ (-f "/etc/redhat-release" && `cat /etc/redhat-release` =~ "CentOS") || `uname -a` =~ "CentOS" ]]; then
41+
sudo yum install cmake
42+
elif [[ "$(expr substr $(uname -s) 1 5)" == "Linux" || `uname -a` =~ "Linux" ]]; then
43+
echo "为避免您的系统环境过旧,即将尝试更新你的系统环境."
44+
read -s -n 1 -p "按q键取消.否则3秒后自动开始." -t 3 input
45+
if [[ $input == "q" || $input == "Q" ]]; then
46+
echo "取消成功!"
47+
else
48+
sudo apt update && apt full-upgrade
49+
sudo apt-get update && apt-get upgrade && apt autoremove
50+
fi
51+
sudo apt install cmake
52+
else
53+
echo "未能识别你的OS,即将尝试编译安装最新版."
54+
git clone https://github.com/Kitware/CMake.git
55+
cd CMake
56+
./bootstrap && make && sudo make install
57+
# if [[ `arch` =~ "aarch64" ]]; then
58+
# fi
59+
fi
60+
fi
61+
1862
# 检测ninja是否存在,若不存在就安装
1963
if ! command -v ninja >/dev/null 2>&1; then
2064
if [[ "$(uname)" == "Darwin" || `uname -a` =~ "Darwin" ]]; then
65+
echo "为避免您的系统环境过旧,即将尝试更新你的系统环境."
66+
read -s -n 1 -p "按q键取消.否则3秒后自动开始." -t 3 input
67+
if [[ $input == "q" || $input == "Q" ]]; then
68+
echo "取消成功!"
69+
else brew update && brew upgrade && brew cleanup
70+
fi
2171
brew install ninja
72+
elif [[ `uname -a` =~ "Manjaro" ]]; then
73+
echo "为避免您的系统环境过旧,即将尝试更新你的系统环境."
74+
read -s -n 1 -p "按q键取消.否则3秒后自动开始." -t 3 input
75+
if [[ $input == "q" || $input == "Q" ]]; then
76+
echo "取消成功!"
77+
else sudo pacman -Syu
78+
fi
79+
sudo pacman -S ninja
2280
elif [[ (-f "/etc/redhat-release" && `cat /etc/redhat-release` =~ "CentOS") || `uname -a` =~ "CentOS" ]]; then
2381
if ! command -v re2c >/dev/null 2>&1; then
2482
yum -y install git automake gcc+ gcc-c++ libtool
@@ -30,6 +88,14 @@ if ! command -v ninja >/dev/null 2>&1; then
3088
./configure.py --bootstrap
3189
cp ninja /usr/bin/
3290
elif [[ "$(expr substr $(uname -s) 1 5)" == "Linux" || `uname -a` =~ "Linux" ]]; then
91+
echo "为避免您的系统环境过旧,即将尝试更新你的系统环境."
92+
read -s -n 1 -p "按q键取消.否则3秒后自动开始." -t 3 input
93+
if [[ $input == "q" || $input == "Q" ]]; then
94+
echo "取消成功!"
95+
else
96+
sudo apt update && apt full-upgrade
97+
sudo apt-get update && apt-get upgrade && apt autoremove
98+
fi
3399
sudo apt install ninja-build
34100
else
35101
echo "未能识别你的OS,即将尝试编译安装."
@@ -45,8 +111,22 @@ fi
45111
# 检测并判断是否需要安装ncurses.h库
46112
if [[ "$(uname)" == "Darwin" || `uname -a` =~ "Darwin" ]]; then
47113
if [[ ! -d "/opt/homebrew/Cellar/ncurses" ]]; then
114+
echo "为避免您的系统环境过旧,即将尝试更新你的系统环境."
115+
read -s -n 1 -p "按q键取消.否则3秒后自动开始." -t 3 input
116+
if [[ $input == "q" || $input == "Q" ]]; then
117+
echo "取消成功!"
118+
else brew update && brew upgrade && brew cleanup
119+
fi
48120
brew install ncurses
49121
fi
122+
elif [[ `uname -a` =~ "Manjaro" ]]; then
123+
echo "为避免您的系统环境过旧,即将尝试更新你的系统环境."
124+
read -s -n 1 -p "按q键取消.否则3秒后自动开始." -t 3 input
125+
if [[ $input == "q" || $input == "Q" ]]; then
126+
echo "取消成功!"
127+
else sudo pacman -Syu
128+
fi
129+
sudo pacman -S ncurses
50130
elif [[ (-f "/etc/redhat-release" && `cat /etc/redhat-release` =~ "CentOS") || `uname -a` =~ "CentOS" ]]; then
51131
if [[ ! -d "/usr/share/doc/libncursesw5-dev" ]]; then
52132
sudo yum install libncurses5 libncursesw5 libncursesw5-dbg
@@ -58,6 +138,14 @@ elif [[ "$(expr substr $(uname -s) 1 5)" == "Linux" || `uname -a` =~ "Linux" ]];
58138
# sudo apt install libncurses5-dev
59139
# fi
60140
if [[ ! -d "/usr/share/doc/libncursesw5-dev" ]]; then
141+
echo "为避免您的系统环境过旧,即将尝试更新你的系统环境."
142+
read -s -n 1 -p "按q键取消.否则3秒后自动开始." -t 3 input
143+
if [[ $input == "q" || $input == "Q" ]]; then
144+
echo "取消成功!"
145+
else
146+
sudo apt update && apt full-upgrade
147+
sudo apt-get update && apt-get upgrade && apt autoremove
148+
fi
61149
sudo apt-get install libncursesw5-dev
62150
fi
63151
elif [[ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]]; then
@@ -66,9 +154,11 @@ elif [[ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]]; then
66154
sleep 10
67155
else
68156
echo "未能识别你的OS,即将尝试编译安装."
157+
cd $Catalog
69158
cd include/ncurses-6.3 && ./configure && make && sudo make install
70159
fi
71160

161+
cd $Catalog
72162
if [[ ! -d "build" ]]; then
73163
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
74164
cmake --build build --target all

0 commit comments

Comments
 (0)