mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-07-14 01:00:07 +08:00
Shared physics code - meant to show sharing, not best practices
This commit is contained in:
+4
-20
@@ -9,7 +9,8 @@ var express = require('express'),
|
||||
http = require('http'),
|
||||
path = require('path'),
|
||||
io = require('socket.io'),
|
||||
garageServer = require('../lib/server/garageserver.io');
|
||||
garageServer = require('../lib/server/garageserver.io'),
|
||||
gamePhysics = require('./shared/core');
|
||||
|
||||
var app = express();
|
||||
|
||||
@@ -24,6 +25,7 @@ app.configure(function () {
|
||||
app.use(app.router);
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
app.use(express.static(path.join(__dirname, '..', 'client')));
|
||||
app.use(express.static(path.join(__dirname, 'shared')));
|
||||
});
|
||||
|
||||
app.configure('development', function () {
|
||||
@@ -45,23 +47,5 @@ sockets.set('log level', 0);
|
||||
|
||||
garageServer.createGarageServer(sockets,{
|
||||
logging: true,
|
||||
onUpdatePlayerPhysics: function (state, inputs) {
|
||||
var i = 0;
|
||||
if (!state.x && !state.y) {
|
||||
state.x = 0;
|
||||
state.y = 0;
|
||||
}
|
||||
for (i = 0; i < inputs.length; i ++) {
|
||||
if (inputs[i].input === 'left') {
|
||||
state.x -= 1;
|
||||
} else if (inputs[i].input === 'right') {
|
||||
state.x += 1;
|
||||
} else if (inputs[i].input === 'down') {
|
||||
state.y += 1;
|
||||
} else if (inputs[i].input === 'up') {
|
||||
state.y -= 1;
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
onUpdatePlayerPhysics: gamePhysics.OnProcessGamePhysics
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user