fixed merge conflict

This commit is contained in:
Richard Harrington
2013-08-19 13:07:04 -04:00
parent 33c32856ea
commit 2fde950905
+29 -14
View File
@@ -25,25 +25,41 @@
var debugAnimationCounter = 0;
var debugSimulationCounter = 0;
var ROBOT_RADIUS = 10;
var ROBOT_MAX_X = 256.0;
var ROBOT_MAX_Y = 256.0;
var ROBOT_COLORS = ["#6aea2a", "#380bfa", "#fa2d0b", "#0bfaf7", "#faf20b"];
var arenaWidth = ROBOT_MAX_X + (ROBOT_RADIUS * 2);
var arenaHeight = ROBOT_MAX_Y + (ROBOT_RADIUS * 2);
// TODO: This game info should probably come from the server
// in a preliminary ajax call.
var GAME_INFO = {
robotRadius: 7,
robotXMax: 256.0,
robotYMax: 256.0,
gameSecondsPerTick: 0.03
}
var canvas = (function(el) {
var width = parseInt(el.width);
var height = parseInt(el.height);
var scaleFactor = parseInt(width / arenaWidth);
var offsetX = function(x) {return scaleFactor * (ROBOT_RADIUS + x)};
var offsetY = function(y) {return scaleFactor * (ROBOT_RADIUS + y)};
var robotDisplayRadius = ROBOT_RADIUS * scaleFactor;
var roomForRobots = GAME_INFO.robotRadius * 2;
var arenaWidth = GAME_INFO.robotXMax + roomForRobots;
var arenaHeight = GAME_INFO.robotYMax + roomForRobots;
var scaleFactorX = parseInt(width / arenaWidth);
var scaleFactorY = parseInt(height / arenaHeight);
var offsetX = function(x) {
return scaleFactorX * (GAME_INFO.robotRadius + x)
}
var offsetY = function(y) {
return scaleFactorY * (GAME_INFO.robotRadius + y)
}
// TODO: regularize this here and on the server so that
// the arena is always square, and there's no ambiguity or question,
// like why are we using scaleFactorX here and don't need
// scaleFactorY?
var robotDisplayRadius = GAME_INFO.robotRadius * scaleFactorX;
var ctx = el.getContext('2d');
var drawRobot = function(robot, idx) {
console.log("ji");
ctx.fillStyle = ROBOT_COLORS[idx];
ctx.beginPath();
ctx.arc(
@@ -57,7 +73,7 @@
}
var draw = function(world) {
ctx.clearRect(0, 0, canvasWidth, canvasHeight);
ctx.clearRect(0, 0, width, height);
world.robots.forEach(drawRobot);
}
@@ -66,7 +82,6 @@
var tickQueue = new Queue();
var fastForward = 5;
var GAME_SECONDS_PER_TICK = 0.03;
// fastForward can't be more than 5 if we want tickDuration to be greater
// than 6 milliseconds, which is close to the official 4-millisecond limit
@@ -76,7 +91,7 @@
// to happen. Perhaps if we make sure to animate collisions over
// several ticks, it will work.
var tickDuration = parseInt (GAME_SECONDS_PER_TICK / fastForward * 1000);
var tickDuration = parseInt (GAME_INFO.gameSecondsPerTick / fastForward * 1000);
console.log(tickDuration);
var fps = 60;