fix for narrow screens (phone)

This commit is contained in:
Neale Pickett 2012-03-15 19:01:05 -06:00
parent 290b198f9b
commit b85d0774ca
1 changed files with 3 additions and 5 deletions

View File

@ -48,7 +48,7 @@ function player(color, pos) {
e.moveTo = function(x, y) { e.moveTo = function(x, y) {
var wx = ((x - midpoint) * scale) + window.innerWidth/2; var wx = ((x - midpoint) * scale) + window.innerWidth/2;
var wy = (y - midpoint) * scale + window.innerHeight/2; var wy = (y - midpoint) * scale + canvas.height/2;
e.pos = [x, y]; e.pos = [x, y];
e.style.left = wx + "px"; e.style.left = wx + "px";
@ -58,7 +58,7 @@ function player(color, pos) {
function mouseMove(evt) { function mouseMove(evt) {
var x = (evt.pageX - window.innerWidth/2) / scale; var x = (evt.pageX - window.innerWidth/2) / scale;
var y = (evt.pageY - window.innerHeight/2) / scale; var y = (evt.pageY - canvas.height/2) / scale;
e.moveTo(x, y); e.moveTo(x, y);
} }
@ -150,9 +150,7 @@ function start() {
canvas = document.getElementById("canvas"); canvas = document.getElementById("canvas");
ctx = canvas.getContext("2d"); ctx = canvas.getContext("2d");
var win_width = window.innerWidth; scale = Math.min(window.innerWidth / 100, (window.innerHeight - 20) / 60);
var win_height = window.innerHeight - 20; // room for pentaly box
scale = Math.min(win_width / 100, win_height / 60);
canvas.width = scale * 100; canvas.width = scale * 100;
canvas.height = scale * 60; canvas.height = scale * 60;