Skip to content

Commit 1639299

Browse files
committed
update get_ncurses.sh, and enable clear score command
1 parent b07f45f commit 1639299

File tree

6 files changed

+25
-7
lines changed

6 files changed

+25
-7
lines changed

.DS_Store

0 Bytes
Binary file not shown.

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ main: main.o start_menu.o new_game.o snake.o save_and_load.o visuals.o pause_men
3535
@echo "Compilation finished!"
3636

3737
ncurses: FORCE
38-
@chmod u+x get_curses.sh
39-
@./get_curses.sh
38+
@chmod u+x get_ncurses.sh
39+
@./get_ncurses.sh
4040
FORCE:
4141

4242
clean:
4343
@rm -f *.o main
4444
@echo "Object files and executable cleaned!"
45+
clear-score:
46+
@chmod u+x ./log/clear-score.sh
47+
@./log/clear-score.sh
4548

46-
.PHONY: clean
49+
.PHONY: clean clear-score

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
- `make ncurses` will automatically run upon `make all`, it will clone the `ncurses` library under the project directory (`./ncurses`), and install it under your home directory (`~/ncurses_files`). Make sure that no non-empty colliding directories exist.
5353
- The clone, install and compile process takes around 1-2 minutes when running `make all` the first time.
5454
- `make clean` can remove object files and executable.
55+
- `make clear-score` can clear the game score history.
5556
- Fully built and tested on HKU `academy11` server.
5657

5758
## External Library
@@ -67,7 +68,7 @@
6768
│ ├── demo_2.png
6869
│ ├── demo_3.png
6970
│ └── demo_4.png
70-
├── get_curses.sh
71+
├── get_ncurses.sh
7172
├── include
7273
│ ├── new_game.hpp
7374
│ ├── pause_menu.hpp
@@ -76,6 +77,7 @@
7677
│ ├── start_menu.hpp
7778
│ └── visuals.hpp
7879
├── log
80+
│ ├── clear-score.sh
7981
│ ├── leaderboard.txt
8082
│ └── state.txt
8183
├── main.cpp

get_curses.sh renamed to get_ncurses.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/bin/bash
22

3-
if [ ! -d ./ncurses ] || [ "`ls $./ncurses | wc -l`" -eq "0" ] # directory exists or is empty
3+
if [ ! -d ./ncurses ] || [ "`ls ./ncurses | wc -l`" -eq "0" ] # directory exists or is empty
44
then
55
git clone https://github.com/mirror/ncurses.git
66
echo "Cloning finished."
77
fi
88

9-
if [ ! -d ~/ncurses_files ] || [ "`ls $~/ncurses_files | wc -l`" -eq "0" ]
9+
if [ ! -d ~/ncurses_files ] || [ "`ls ~/ncurses_files | wc -l`" -eq "0" ]
1010
then
1111

1212
cd ./ncurses

include/snake.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Snake{
6060
std::string sHead = "00"; // head char of the snake
6161
std::string sBody = "[]"; // body char of the snake
6262

63-
int snakeSpeed = 135; // usleep(snakeSpeed*1000)
63+
int snakeSpeed = 140; // usleep(snakeSpeed*1000)
6464

6565
WINDOW * curwin;
6666

log/clear-score.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
echo -n "Your score history will be deleted, do you want to continue [Y/n]? "
4+
confirm="n"
5+
read confirm
6+
if [ "$confirm" == "Y" ]
7+
then
8+
echo " === LEADERBOARD === " > ./log/leaderboard.txt
9+
echo " SCORE DATE" >> ./log/leaderboard.txt
10+
echo "Score history deleted."
11+
else
12+
echo "Abort."
13+
fi

0 commit comments

Comments
 (0)