added scaling

This commit is contained in:
meadowstream 2014-05-25 11:16:33 -04:00
parent 2a4c971d67
commit 9c3521880b
2 changed files with 11 additions and 6 deletions

View file

@ -22,7 +22,7 @@ function Block(lane, color, iter, distFromHex, settled) {
if (distFromHex) {
this.distFromHex = distFromHex;
} else {
this.distFromHex = 320 * settings.scale;
this.distFromHex = 340 * settings.scale;
}
this.incrementOpacity = function() {
@ -271,6 +271,10 @@ function Clock(sideLength) {
};
this.draw = function() {
if (gameState == 1) {
this.x = canvas.width/2;
this.y = canvas.height/2;
}
this.sideLength = settings.hexWidth;
gdx = 0;
gdy = 0;

View file

@ -6,6 +6,11 @@ function scaleCanvas() {
canvas.height = $(window).height();
canvas.originalHeight = canvas.height;
canvas.originalWidth = canvas.width;
if (canvas.height > canvas.width) {
settings.scale = canvas.width/800;
} else {
settings.scale = canvas.height/800;
}
}
var canvas = document.getElementById('canvas');
@ -52,7 +57,6 @@ if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigat
};
}
var firstTime = 1;
var gameState = 0;
var framerate = 60;
var history = {};
@ -99,10 +103,6 @@ function init() {
MainClock.y = -100/(window.devicePixelRatio ? window.devicePixelRatio : 1);
startTime = Date.now();
waveone = new waveGen(MainClock,Date.now(),[1,1,0],[1,1],[1,1]);
if (firstTime) {
firstTime = 0;
requestAnimFrame(animLoop);
}
}
function addNewBlock(blocklane, color, iter, distFromHex, settled) { //last two are optional parameters
@ -305,6 +305,7 @@ function animLoop() {
}
}
else if (gameState === 0) {
requestAnimFrame(animLoop);
clearGameBoard();
showModal('Start!', 'Press enter to start!');
}