From 59a13f2a85601e80542b2e7f9f7eda2add68233f Mon Sep 17 00:00:00 2001 From: Alexandre Bour Date: Sat, 5 Jul 2014 17:03:24 +0200 Subject: [PATCH] Game objects color can now be configured in GameConfig.js file --- Color.js | 7 +++++++ GameConfig.js | 6 +++++- PlayerDisplayer.js | 6 ++++-- SolidLineDisplayer.js | 4 +++- 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 Color.js diff --git a/Color.js b/Color.js new file mode 100644 index 0000000..425edc9 --- /dev/null +++ b/Color.js @@ -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; diff --git a/GameConfig.js b/GameConfig.js index 2f7a598..e3ca2ec 100644 --- a/GameConfig.js +++ b/GameConfig.js @@ -1 +1,5 @@ -exports.FPS = 40; \ No newline at end of file +var Color = require('./Color.js'); + +exports.FPS = 40; +exports.PLAYER_COLOR = Color.WHITE; +exports.LINE_COLOR = Color.CYAN; \ No newline at end of file diff --git a/PlayerDisplayer.js b/PlayerDisplayer.js index 3b20ca8..a83e306 100644 --- a/PlayerDisplayer.js +++ b/PlayerDisplayer.js @@ -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; @@ -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); } } diff --git a/SolidLineDisplayer.js b/SolidLineDisplayer.js index cdb8d3b..e0665ce 100644 --- a/SolidLineDisplayer.js +++ b/SolidLineDisplayer.js @@ -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; @@ -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); } }