Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Working on unit movement commands
  • Loading branch information
mansoor-s committed Mar 31, 2012
1 parent 37c96ed commit 157e11f
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 50 deletions.
3 changes: 3 additions & 0 deletions data/systemData.js
Expand Up @@ -94,6 +94,7 @@ systemData = {
ships:[
{
type:"frigate",
id: 0,
subtype:"cruiser",
position:{
x:2780,
Expand All @@ -109,6 +110,7 @@ systemData = {
{
type:"frigate",
subtype:"cruiser",
id: 1,
position:{
x:2820,
y:50,
Expand All @@ -123,6 +125,7 @@ systemData = {
{
type:"frigate",
subtype:"cruiser",
id: 2,
position:{
x:2800,
y:50,
Expand Down
2 changes: 1 addition & 1 deletion index.html
Expand Up @@ -66,7 +66,7 @@
<script src="./js/lib/postprocessing/MaskPass.js"></script>
<script src="./js/lib/postprocessing/BloomPass.js"></script>

<script type="text/javascript" src="./data/systemData.js"></script>
<script src="./data/systemData.js"></script>


<script src="./js/app/Settings.js"></script>
Expand Down
39 changes: 24 additions & 15 deletions js/app/EventLoop.js
Expand Up @@ -13,27 +13,36 @@
};

EventLoop.prototype._getEventLoop = function() {

var x = 2780;
var y = 50;
var z = 50;

var self = this;
return function() {
x -= 1;
y -= 1;
z -= 1;

var tasks = self.sockets.recv();
self.sockets.flush();

tasks.push({
id: 0,
task: {
unitId: 0,
order: 0,
pos: {
x: x,
y: y,
z: z
}
}

});

//route the tasks

for(var i = 0, len = tasks.length; i < len; ++i) {
var task = tasks[i];

if (task.id === 0 || task.id === 1) {
self._webglController.handleUnitUpdates(task);
} else if (task.id === 2) {
self._webglController.handlePlayerUpdates(task);
} else if (task.id === 3) {
self._webglController.handlePrivateChat(task);
} else if (task.id === 4) {
self._webglController.handleAllianceChat(task);
}
}
self._webglController.routeUpdateEvents(tasks);

};
};
Expand All @@ -57,7 +66,7 @@ tasks: [
id: 0,
task: {
order: 0
destinaion: {
pos: {
x:
y:
z:
Expand Down
2 changes: 1 addition & 1 deletion js/app/controlers.app.js
Expand Up @@ -3,7 +3,7 @@
App.Controllers.App = function() {
var webglController = new App.Controllers.Webgl($('.gs-viewport'));

var eventLoop = new App.eventLoop(webglController);
var eventLoop = new App.EventLoop(webglController);

eventLoop.start();

Expand Down
45 changes: 37 additions & 8 deletions js/app/controlers.webgl.js
Expand Up @@ -117,22 +117,51 @@

};

Webgl.prototype.handleUnitUpdates = function() {



/*
task ids:
0 - unit movement
1 - unit position update
2 - player/infrustrcuture updates
3 - private chat
4 - alliance chat
*/
Webgl.prototype.routeUpdateEvents = function(tasks) {
for(var i = 0, len = tasks.length; i < len; ++i) {
var task = tasks[i];

if (task.id === 0 || task.id === 1) {
this.currentStage.handleUnitUpdates(task.task);
} else if (task.id === 2) {
this.currentStage.handlePlayerUpdates(task.task);
} else if (task.id === 3) {
this.currentStage.handlePrivateChat(task.task);
} else if (task.id === 4) {
this.currentStage.handleAllianceChat(task.task);
}
}
};

Webgl.prototype.handleUnitUpdates = function(data) {
this.currentStage.handleUnitUpdates(data);
};

Webgl.prototype.handlePlayerUpdates = function() {


Webgl.prototype.handlePlayerUpdates = function(data) {
this.currentStage.handlePlayerUpdates(data);
};


Webgl.prototype.handlePrivateChat = function() {

Webgl.prototype.handlePrivateChat = function(data) {
this.currentStage.handlePrivateChat(data);
};


Webgl.prototype.handleAllianceChat = function() {

Webgl.prototype.handleAllianceChat = function(data) {
this.currentStage.handleAllianceChat(data);
};
})();

0 comments on commit 157e11f

Please sign in to comment.