Compare commits
2 commits
3e8eb69329
...
200c716393
Author | SHA1 | Date | |
---|---|---|---|
200c716393 | |||
142024a315 |
3
.gitignore
vendored
|
@ -1,9 +1,6 @@
|
|||
node_modules/
|
||||
public/assets/*.png
|
||||
public/assets/*.json
|
||||
public/css/*.css
|
||||
public/js/*.js
|
||||
public/favicon.ico
|
||||
build/*.png
|
||||
db.sqlite
|
||||
|
||||
|
|
2
Makefile
|
@ -82,7 +82,7 @@ public/assets/portal-d-anim.png: public/assets/portal-a-anim.png
|
|||
convert $^ -modulate 100,100,50 $@
|
||||
|
||||
public/assets/%.json: assets/%.json
|
||||
cp $^ $@
|
||||
ln -s ../../$^ $@
|
||||
|
||||
public/css/snek.css: src/less/snek.less $(wildcard src/less/*.less)
|
||||
node_modules/.bin/lessc $< $@
|
||||
|
|
10
README.md
|
@ -25,14 +25,20 @@ A "simple" Snake, done as my final JS class project
|
|||
|
||||
## Running the game (dev)
|
||||
- `git clone` this repo
|
||||
- `npm install` the dependencies (this will also build the ressources and initialize the database)
|
||||
- `npm install` the dependencies (this will also build the less and js and initialize the database)
|
||||
- `npm start` the server
|
||||
- `make` every time you change something
|
||||
|
||||
## Running the game (prod)
|
||||
## Running the game (prod, docker)
|
||||
- Get the [Dockerfile](https://gitdab.com/Codinget/Snek/raw/branch/master/Dockerfile)
|
||||
- `docker build` it
|
||||
- `docker run -it -p80:3000` the container
|
||||
- ideally, put it behind a reverse proxy
|
||||
|
||||
## Running the game (prod, direct)
|
||||
- `git clone` this repo
|
||||
- `npm install` the dependencies (this will also build the less and js and initialize the database)
|
||||
- `npm start` the server
|
||||
|
||||
## License
|
||||
[MIT](https://opensource.org/licenses/MIT)
|
||||
|
|
14
install.js
|
@ -1,5 +1,19 @@
|
|||
const DB=require('better-sqlite3');
|
||||
const fs=require('fs');
|
||||
const child_process=require('child_process');
|
||||
|
||||
// prepare database
|
||||
console.log('Preparing database');
|
||||
fs.unlinkSync('db.sqlite');
|
||||
const db=new DB('db.sqlite');
|
||||
db.exec(fs.readFileSync('init.sql', 'utf8'));
|
||||
|
||||
// compile less
|
||||
console.log('Compiling less');
|
||||
child_process.execFileSync('node_modules/.bin/lessc', ['src/less/snek.less', 'public/css/snek.css']);
|
||||
|
||||
// merge js
|
||||
console.log('Merging js');
|
||||
const jsFiles=fs.readdirSync('src/js').map(f => 'src/js/'+f);
|
||||
const merged=child_process.execFileSync('node', ['mergejs.js', ...jsFiles]);
|
||||
fs.writeFileSync('public/js/snek.js', merged);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node index.js",
|
||||
"prepare": "rm -f db.sqlite && make clean all && node install.js"
|
||||
"prepare": "node install.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
BIN
public/assets/apple32.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
1
public/assets/config.json
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../assets/config.json
|
BIN
public/assets/door32.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
public/assets/fire-anim.png
Normal file
After Width: | Height: | Size: 150 KiB |
BIN
public/assets/hole-ts.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
public/assets/icon256.png
Normal file
After Width: | Height: | Size: 94 KiB |
BIN
public/assets/icon32.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
public/assets/key32.png
Normal file
After Width: | Height: | Size: 7.9 KiB |
1
public/assets/levelList.json
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../assets/levelList.json
|
1
public/assets/metaConfig.json
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../assets/metaConfig.json
|
BIN
public/assets/oil32.png
Normal file
After Width: | Height: | Size: 6 KiB |
BIN
public/assets/peach-decay-anim.png
Normal file
After Width: | Height: | Size: 63 KiB |
BIN
public/assets/peach-rainbow-anim.png
Normal file
After Width: | Height: | Size: 54 KiB |
BIN
public/assets/portal-a-anim.png
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
public/assets/portal-b-anim.png
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
public/assets/portal-c-anim.png
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
public/assets/portal-d-anim.png
Normal file
After Width: | Height: | Size: 38 KiB |
1
public/assets/snake.json
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../assets/snake.json
|
BIN
public/assets/spikes-ts.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
public/assets/switch-ts.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
public/assets/wall32.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
public/favicon.ico
Normal file
After Width: | Height: | Size: 4.2 KiB |