Compare commits

..

2 commits

Author SHA1 Message Date
200c716393 updated README.md 2020-04-15 12:10:28 +02:00
142024a315 added built assets 2020-04-15 12:08:21 +02:00
27 changed files with 28 additions and 7 deletions

3
.gitignore vendored
View file

@ -1,9 +1,6 @@
node_modules/ node_modules/
public/assets/*.png
public/assets/*.json
public/css/*.css public/css/*.css
public/js/*.js public/js/*.js
public/favicon.ico
build/*.png build/*.png
db.sqlite db.sqlite

View file

@ -82,7 +82,7 @@ public/assets/portal-d-anim.png: public/assets/portal-a-anim.png
convert $^ -modulate 100,100,50 $@ convert $^ -modulate 100,100,50 $@
public/assets/%.json: assets/%.json public/assets/%.json: assets/%.json
cp $^ $@ ln -s ../../$^ $@
public/css/snek.css: src/less/snek.less $(wildcard src/less/*.less) public/css/snek.css: src/less/snek.less $(wildcard src/less/*.less)
node_modules/.bin/lessc $< $@ node_modules/.bin/lessc $< $@

View file

@ -25,14 +25,20 @@ A "simple" Snake, done as my final JS class project
## Running the game (dev) ## Running the game (dev)
- `git clone` this repo - `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 - `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) - Get the [Dockerfile](https://gitdab.com/Codinget/Snek/raw/branch/master/Dockerfile)
- `docker build` it - `docker build` it
- `docker run -it -p80:3000` the container - `docker run -it -p80:3000` the container
- ideally, put it behind a reverse proxy - 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 ## License
[MIT](https://opensource.org/licenses/MIT) [MIT](https://opensource.org/licenses/MIT)

View file

@ -1,5 +1,19 @@
const DB=require('better-sqlite3'); const DB=require('better-sqlite3');
const fs=require('fs'); 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'); const db=new DB('db.sqlite');
db.exec(fs.readFileSync('init.sql', 'utf8')); 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);

View file

@ -5,7 +5,7 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "node index.js", "start": "node index.js",
"prepare": "rm -f db.sqlite && make clean all && node install.js" "prepare": "node install.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

BIN
public/assets/apple32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

1
public/assets/config.json Symbolic link
View file

@ -0,0 +1 @@
../../assets/config.json

BIN
public/assets/door32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
public/assets/fire-anim.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

BIN
public/assets/hole-ts.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
public/assets/icon256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

BIN
public/assets/icon32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
public/assets/key32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

View file

@ -0,0 +1 @@
../../assets/levelList.json

View file

@ -0,0 +1 @@
../../assets/metaConfig.json

BIN
public/assets/oil32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

1
public/assets/snake.json Symbolic link
View file

@ -0,0 +1 @@
../../assets/snake.json

BIN
public/assets/spikes-ts.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
public/assets/switch-ts.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
public/assets/wall32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB