Skip to content

Commit

Permalink
Game objects color can now be configured in GameConfig.js file
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Bour committed Jul 5, 2014
1 parent f2a10e5 commit 59a13f2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
7 changes: 7 additions & 0 deletions Color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
exports.RED = 1;
exports.LIME = 2;
exports.YELLOW = 3;
exports.BLUE = 4;
exports.FUCHSIA = 5;
exports.CYAN = 6;
exports.WHITE = 7;
6 changes: 5 additions & 1 deletion GameConfig.js
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
exports.FPS = 40;
var Color = require('./Color.js');

exports.FPS = 40;
exports.PLAYER_COLOR = Color.WHITE;
exports.LINE_COLOR = Color.CYAN;
6 changes: 4 additions & 2 deletions PlayerDisplayer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var GameConfig = require("./GameConfig.js")

// Closure to display a solidLine (capture the display interface i.e the networkCommunicationManager)
exports.createDisplayerFunc = function(networkCommunicationManager) {
var networkCommunicationManager = networkCommunicationManager;
Expand All @@ -8,7 +10,7 @@ exports.createDisplayerFunc = function(networkCommunicationManager) {
var subCircleX = p.getRayon() * 0.8 * Math.cos((millisecTime % 36000 * 1000) * (horizontalSpeed) / -10000000.);
var subCircleY = p.getRayon() * 0.8 * Math.sin((millisecTime % 36000 * 1000) * (horizontalSpeed) / -10000000.);

networkCommunicationManager.drawCircle(p.getX() + subCircleX, p.getY() + subCircleY, p.getRayon() / 2, 6);
networkCommunicationManager.drawCircle(p.getX(), p.getY(), p.getRayon() * 2, 6);
networkCommunicationManager.drawCircle(p.getX() + subCircleX, p.getY() + subCircleY, p.getRayon() / 2, GameConfig.PLAYER_COLOR);
networkCommunicationManager.drawCircle(p.getX(), p.getY(), p.getRayon() * 2, GameConfig.PLAYER_COLOR);
}
}
4 changes: 3 additions & 1 deletion SolidLineDisplayer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var GameConfig = require("./GameConfig.js")

// Closure to display a player (capture the display interface i.e the networkCommunicationManager)
exports.createDisplayerFunc = function(networkCommunicationManager) {
var networkCommunicationManager = networkCommunicationManager;
Expand All @@ -7,7 +9,7 @@ exports.createDisplayerFunc = function(networkCommunicationManager) {
adjust(solidLine.getLine().getPoint1().getY()),
adjust(solidLine.getLine().getPoint2().getX()),
adjust(solidLine.getLine().getPoint2().getY()),
5);
GameConfig.LINE_COLOR);
}
}

Expand Down

0 comments on commit 59a13f2

Please sign in to comment.