From 41db1087eeb5f3d2ceabf7f84fc95463202af23e Mon Sep 17 00:00:00 2001 From: Martin Haye Date: Sun, 3 Nov 2013 09:47:44 -0800 Subject: [PATCH] Do sprite math strictly in Apple II coordinates. --- .../virtual/src/raycast/javascript/intcast.js | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Platform/Apple/virtual/src/raycast/javascript/intcast.js b/Platform/Apple/virtual/src/raycast/javascript/intcast.js index 7a89477f..058da0ef 100644 --- a/Platform/Apple/virtual/src/raycast/javascript/intcast.js +++ b/Platform/Apple/virtual/src/raycast/javascript/intcast.js @@ -376,7 +376,7 @@ function intRenderSprites() { var wLog256 = log2_w_w(256); - var wLogViewDist = log2_w_w(viewDist*256); + var wLogViewDist = log2_w_w(viewDist/8*256); // div by 8 to get to Apple II coords for (var i=0;i screenWidth) { + else if (spriteLeft > (screenWidth/8)) { if (sprite.index == debugSprite) console.log(" off-screen to right."); sprite.visible = false; @@ -445,10 +451,15 @@ function intRenderSprites() { continue; } + // Adjust from Apple II coordinates to PC coords (we render 8 pixels for each 1 Apple pix) + spriteLeft *= 8; + spriteTop *= 8; + wSize *= 8; + // Update the image with the calculated values sprite.visible = true; - img.style.left = (screenWidth/2 + wX - wSize/2) + "px"; - img.style.top = ((screenHeight-wSize)/2)+"px"; + img.style.left = spriteLeft + "px"; + img.style.top = spriteTop+"px"; img.style.width = wSize + "px"; img.style.height = wSize + "px"; img.style.zIndex = wSize;