Skip to content

Commit

Permalink
Mouse movement propotional to screen resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
s-macke committed Nov 26, 2017
1 parent a57082e commit abc1290
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions VoxelSpace.html
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@
if (input.mouseposition == null) return;
if (input.forwardbackward == 0) return;

input.leftright = (input.mouseposition[0]-e.pageX)*1e-3;
camera.horizon = 100 + (input.mouseposition[1]-e.pageY)*0.5;
input.updown = (input.mouseposition[1]-e.pageY)*1e-2;
input.leftright = (input.mouseposition[0]-e.pageX) / window.innerWidth * 2;
camera.horizon = 100 + (input.mouseposition[1]-e.pageY) / window.innerHeight * 500;
input.updown = (input.mouseposition[1]-e.pageY) / window.innerHeight * 10;
}


Expand Down Expand Up @@ -385,7 +385,7 @@
{
var mapoffset = ((Math.floor(ply) & 1023) << 10) + (Math.floor(plx) & 1023)|0;
var heightonscreen = (camera.height - map.height[mapoffset]) * invz + camera.horizon|0;
DrawVerticalLine(i, heightonscreen, hiddeny[i], map.color[mapoffset]);
DrawVerticalLine(i, heightonscreen|0, hiddeny[i], map.color[mapoffset]);
if (heightonscreen < hiddeny[i]) hiddeny[i] = heightonscreen;
plx += dx;
ply += dy;
Expand Down

0 comments on commit abc1290

Please sign in to comment.