Compare commits
No commits in common. "200c716393dcaf2db75bacb3a9f627f38cea0992" and "3e8eb69329af84451d28efeb13222cba29bae693" have entirely different histories.
200c716393
...
3e8eb69329
3
.gitignore
vendored
|
@ -1,6 +1,9 @@
|
||||||
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
|
||||||
|
|
||||||
|
|
2
Makefile
|
@ -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
|
||||||
ln -s ../../$^ $@
|
cp $^ $@
|
||||||
|
|
||||||
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 $< $@
|
||||||
|
|
10
README.md
|
@ -25,20 +25,14 @@ 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 less and js and initialize the database)
|
- `npm install` the dependencies (this will also build the ressources and initialize the database)
|
||||||
- `npm start` the server
|
- `npm start` the server
|
||||||
- `make` every time you change something
|
|
||||||
|
|
||||||
## Running the game (prod, docker)
|
## Running the game (prod)
|
||||||
- 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)
|
||||||
|
|
14
install.js
|
@ -1,19 +1,5 @@
|
||||||
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);
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node index.js",
|
"start": "node index.js",
|
||||||
"prepare": "node install.js"
|
"prepare": "rm -f db.sqlite && make clean all && node install.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
Before Width: | Height: | Size: 7.8 KiB |
|
@ -1 +0,0 @@
|
||||||
../../assets/config.json
|
|
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 150 KiB |
Before Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 94 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 7.9 KiB |
|
@ -1 +0,0 @@
|
||||||
../../assets/levelList.json
|
|
|
@ -1 +0,0 @@
|
||||||
../../assets/metaConfig.json
|
|
Before Width: | Height: | Size: 6 KiB |
Before Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 38 KiB |
|
@ -1 +0,0 @@
|
||||||
../../assets/snake.json
|
|
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 4.2 KiB |