add command line arguments
This commit is contained in:
parent
4f42723f4a
commit
1160466cf9
13 changed files with 129 additions and 7 deletions
14
README.md
14
README.md
|
@ -1,7 +1,9 @@
|
|||
Wingbase
|
||||
===
|
||||
|
||||
This is a stupid little game where you fly around and bump into asteroids and stuff.
|
||||
Wingbase is a top-down spaceship game in which two teams of four players each compete to destroy their enemy's base while at the same time collecting resources for their own base. These resources can then be used to purchase more powerful ships upon respawn, to build defense turrets, or to research new weapons and upgrades.
|
||||
|
||||
The game is built in Javascript using HTML5 Canvas for client rendering, Box2D for physics, and Node.js with Socket.io for the server.
|
||||
|
||||
###Installation
|
||||
|
||||
|
@ -9,11 +11,15 @@ Clone the Git repository, install Node.js version 5.6.0 or higher then run `npm
|
|||
|
||||
Make sure that the command `node` links to this Node.js version and not `nodejs`.
|
||||
|
||||
If you have an older version of Node.js you can upgrade by running `sudo npm install -g n` and then `sudo n latest`.
|
||||
|
||||
###Running
|
||||
|
||||
Run `node index.js` or `npm start`.
|
||||
Run `node index` or `npm start`.
|
||||
|
||||
Port 8080 is used by default and this must be open for people to play across the internet. To use a different port, set the `process.env.PORT` variable.
|
||||
If you use `npm start` arguments must be preceded by `--` e.g. `npm start -- -p 8000`.
|
||||
|
||||
Run `node index --help` or `node index -h` for a list of command line arguments.
|
||||
|
||||
###Tests
|
||||
|
||||
|
@ -28,3 +34,5 @@ Mouse to aim and shoot.
|
|||
E/Q to change weapons.
|
||||
|
||||
Enter to chat.
|
||||
|
||||
Type `/commands` in chat for a list of in-game commands.
|
||||
|
|
50
npm-debug.log
Normal file
50
npm-debug.log
Normal file
|
@ -0,0 +1,50 @@
|
|||
0 info it worked if it ends with ok
|
||||
1 verbose cli [ '/usr/local/bin/node',
|
||||
1 verbose cli '/usr/local/bin/npm',
|
||||
1 verbose cli 'start',
|
||||
1 verbose cli '--',
|
||||
1 verbose cli '-p',
|
||||
1 verbose cli '70' ]
|
||||
2 info using npm@3.7.3
|
||||
3 info using node@v5.9.1
|
||||
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
|
||||
5 info lifecycle wingbase@0.0.1~prestart: wingbase@0.0.1
|
||||
6 silly lifecycle wingbase@0.0.1~prestart: no script for prestart, continuing
|
||||
7 info lifecycle wingbase@0.0.1~start: wingbase@0.0.1
|
||||
8 verbose lifecycle wingbase@0.0.1~start: unsafe-perm in lifecycle true
|
||||
9 verbose lifecycle wingbase@0.0.1~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/home/asraelite/code/nodejs/wingbase/node_modules/.bin:/usr/local/bin:/usr/local/heroku/bin:/home/asraelite/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/asraelite/bin:/usr/local/java/jdk1.7.0_45/bin:/home/asraelite/bin:/usr/local/java/jdk1.7.0_45/jre/bin:/home/asraelite/.rvm/bin:/usr/local/bin:/usr/local/bin:/usr/local/go/bin:/home/asraelite/Code/go/bin:/home/asraelite/.rvm/bin
|
||||
10 verbose lifecycle wingbase@0.0.1~start: CWD: /home/asraelite/code/nodejs/wingbase
|
||||
11 silly lifecycle wingbase@0.0.1~start: Args: [ '-c', 'node index.js "-p" "70"' ]
|
||||
12 silly lifecycle wingbase@0.0.1~start: Returned: code: 1 signal: null
|
||||
13 info lifecycle wingbase@0.0.1~start: Failed to exec start script
|
||||
14 verbose stack Error: wingbase@0.0.1 start: `node index.js "-p" "70"`
|
||||
14 verbose stack Exit status 1
|
||||
14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:239:16)
|
||||
14 verbose stack at emitTwo (events.js:100:13)
|
||||
14 verbose stack at EventEmitter.emit (events.js:185:7)
|
||||
14 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14)
|
||||
14 verbose stack at emitTwo (events.js:100:13)
|
||||
14 verbose stack at ChildProcess.emit (events.js:185:7)
|
||||
14 verbose stack at maybeClose (internal/child_process.js:850:16)
|
||||
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
|
||||
15 verbose pkgid wingbase@0.0.1
|
||||
16 verbose cwd /home/asraelite/code/nodejs/wingbase
|
||||
17 error Linux 3.13.0-24-generic
|
||||
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "start" "--" "-p" "70"
|
||||
19 error node v5.9.1
|
||||
20 error npm v3.7.3
|
||||
21 error code ELIFECYCLE
|
||||
22 error wingbase@0.0.1 start: `node index.js "-p" "70"`
|
||||
22 error Exit status 1
|
||||
23 error Failed at the wingbase@0.0.1 start script 'node index.js "-p" "70"'.
|
||||
23 error Make sure you have the latest version of node.js and npm installed.
|
||||
23 error If you do, this is most likely a problem with the wingbase package,
|
||||
23 error not with npm itself.
|
||||
23 error Tell the author that this fails on your system:
|
||||
23 error node index.js "-p" "70"
|
||||
23 error You can get information on how to open an issue for this project with:
|
||||
23 error npm bugs wingbase
|
||||
23 error Or if that isn't available, you can get their info via:
|
||||
23 error npm owner ls wingbase
|
||||
23 error There is likely additional logging output above.
|
||||
24 verbose exit [ 1, true ]
|
|
@ -17,13 +17,16 @@
|
|||
"dependencies": {
|
||||
"box2d-html5": "^0.1.230",
|
||||
"colors": "^1.1.2",
|
||||
"commander": "^2.9.0",
|
||||
"escape-html": "^1.0.3",
|
||||
"express": "^4.13.4",
|
||||
"jade": "^1.11.0",
|
||||
"nib": "^1.1.0",
|
||||
"poly-decomp": "git://github.com/schteppe/poly-decomp.js.git",
|
||||
"recursive-readdir": "^1.3.0",
|
||||
"socket.io": "^1.4.5",
|
||||
"socket.io-client": "^1.4.5",
|
||||
"stylus": "^0.54.2",
|
||||
"uglify-js": "^2.6.2",
|
||||
"uuid": "^2.0.1"
|
||||
}
|
||||
|
|
|
@ -64,3 +64,11 @@ body {
|
|||
#gui #chat input:focus {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
#gui #weapons {
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
transform: translate(-50%, 0);
|
||||
}
|
||||
|
||||
#gui #weapons
|
||||
|
|
3
public/static/css/test.css
Normal file
3
public/static/css/test.css
Normal file
|
@ -0,0 +1,3 @@
|
|||
# test {
|
||||
ayy: 5;
|
||||
}
|
|
@ -4,7 +4,22 @@ class CommandProcessor {
|
|||
}
|
||||
|
||||
run(command, arg) {
|
||||
if (command == 'setname') this.setName(arg);
|
||||
if (command == 'setname') {
|
||||
this.setName(arg);
|
||||
} else if (command == 'commands') {
|
||||
game.gui.chat.addMessage({
|
||||
type: 'server',
|
||||
message: 'Available commands:<br /> ' +
|
||||
'/setname [name]<br /> ' +
|
||||
'/commands'
|
||||
});
|
||||
} else {
|
||||
game.gui.chat.addMessage({
|
||||
type: 'server',
|
||||
message: 'Unrecognised command<br />' +
|
||||
'Type /commands for a list'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
setName(name) {
|
||||
|
|
0
public/static/js/wingbase/gui/weapons.js
Normal file
0
public/static/js/wingbase/gui/weapons.js
Normal file
4
public/stylus/test.css
Normal file
4
public/stylus/test.css
Normal file
|
@ -0,0 +1,4 @@
|
|||
# test {
|
||||
ayy: 5;
|
||||
b: 2;
|
||||
}
|
3
public/stylus/test.styl
Normal file
3
public/stylus/test.styl
Normal file
|
@ -0,0 +1,3 @@
|
|||
# test {
|
||||
ayy: 5;
|
||||
}
|
|
@ -1,3 +1,6 @@
|
|||
#chat.container
|
||||
#chat-messages
|
||||
input(type="text", maxLength="100")#chat-input
|
||||
|
||||
#weapons.container
|
||||
#weapon-selection
|
||||
|
|
|
@ -13,7 +13,7 @@ class Room {
|
|||
this.teamB = new Set();
|
||||
this.world = new World(this);
|
||||
this.name = (Math.random() * 100000 | 0).toString(36);
|
||||
this.tps = 60;
|
||||
this.tps = 5;
|
||||
|
||||
this.idGenerator = (function*() {
|
||||
let i = 0;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const commander = require('commander');
|
||||
|
||||
const GameServer = require('./game/');
|
||||
const WebServer = require('./web/');
|
||||
const ServerInterface = require('./interface.js');
|
||||
|
@ -10,6 +12,17 @@ class WingbaseServer extends ServerInterface {
|
|||
constructor() {
|
||||
super();
|
||||
|
||||
let port = process.env.PORT || 8080;
|
||||
|
||||
commander
|
||||
.version(packageJson.version)
|
||||
.option('-d, --development', 'run in development mode')
|
||||
.option('-p, --port [port]', 'specify port to use', port)
|
||||
.parse(process.argv);
|
||||
|
||||
this.args = commander;
|
||||
console.log(commander.port);
|
||||
|
||||
process.on('SIGINT', this.stop.bind(this));
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
const express = require('express');
|
||||
const http = require('http');
|
||||
const nib = require('nib');
|
||||
const stylus = require('stylus');
|
||||
|
||||
const minify = require('./minify.js');
|
||||
|
||||
|
@ -12,14 +14,24 @@ class WebServer {
|
|||
}
|
||||
|
||||
start() {
|
||||
this.appServer.listen(process.env.PORT || 8080);
|
||||
this.appServer.listen(wingbase.args.port);
|
||||
|
||||
let app = this.app;
|
||||
|
||||
app.set('views', './public/views');
|
||||
app.set('views', 'public/views');
|
||||
app.set('view engine', 'jade');
|
||||
app.engine('jade', require('jade').__express);
|
||||
|
||||
app.use(stylus.middleware({
|
||||
src: 'public/stylus',
|
||||
dest: 'public/static/css',
|
||||
compile: (str, path) => {
|
||||
return stylus(str)
|
||||
.set('filename', path)
|
||||
.use(nib())
|
||||
}
|
||||
}));
|
||||
|
||||
app.get('/wingbase.min.js', (req, res) => {
|
||||
minify(result => {
|
||||
res.contentType('wingbase.min.js');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue