Fixed scaling for setUpTransforms

This commit is contained in:
domdoc 2022-05-31 21:30:52 +02:00
parent c3ad3b6323
commit 614dcfe9b7
3 changed files with 15 additions and 13 deletions

View File

@ -48,9 +48,11 @@ end
---@param rotation number ---@param rotation number
---@return number, boolean # The scale applied to the transform and the current landscape state ---@return number, boolean # The scale applied to the transform and the current landscape state
function dimtable.setUpTransforms(x, y, rotation) function dimtable.setUpTransforms(x, y, rotation)
local scale = dimtable.screen.width / dimtable.view.width;
local isLandscape = dimtable.view.width > dimtable.view.height; local isLandscape = dimtable.view.width > dimtable.view.height;
local designWidth = isLandscape and dimtable.design.height or dimtable.design.width
local scale = dimtable.view.width / designWidth
gfx.ResetTransform(); gfx.ResetTransform();
gfx.Translate(x, y); gfx.Translate(x, y);
gfx.Rotate(rotation); gfx.Rotate(rotation);

View File

@ -22,13 +22,12 @@ local cursorTailImages = {
gfx.CreateSkinImage("gameplay/crit_line/cursor_tail_r.png", 0), gfx.CreateSkinImage("gameplay/crit_line/cursor_tail_r.png", 0),
} }
local CRITBAR_W = 1080 local CRITBAR_W = 1080 * 1.4
local CRITBAR_H = 251 local CRITBAR_H = 251 * 1.4
local scale = 1;
local isLandscape = false; local isLandscape = false;
local drawCursors = function (centerX, centerY,cursors, laserActive) local drawCursors = function (scale, cursors, laserActive)
local cursorW = 598 * 0.165; local cursorW = 598 * 0.165;
local cursorH = 673 * 0.14; local cursorH = 673 * 0.14;
@ -45,12 +44,13 @@ local drawCursors = function (centerX, centerY,cursors, laserActive)
local skew = cursor.pos * 0.001; local skew = cursor.pos * 0.001;
gfx.SkewX(skew); gfx.SkewX(skew);
local cursorX = cursor.pos * (1 / scale) - cursorW / 2; local cursorPos = cursor.pos * (1 / scale)
local cursorX = cursorPos - cursorW / 2;
local cursorY = -cursorH / 2; local cursorY = -cursorH / 2;
if laserActive[luaIndex] then if laserActive[luaIndex] then
gfx.ImageRect( gfx.ImageRect(
cursor.pos - tailW / 2, cursorPos - tailW / 2,
- tailH / 2, - tailH / 2,
tailW, tailW,
tailH, tailH,
@ -105,7 +105,7 @@ local drawCursors = function (centerX, centerY,cursors, laserActive)
end end
local renderBase = function (deltaTime, centerX, centerY, rotation) local renderBase = function (deltaTime, centerX, centerY, rotation)
scale, isLandscape = Dimensions.setUpTransforms(centerX, centerY, rotation) _, isLandscape = Dimensions.setUpTransforms(centerX, centerY, rotation)
gfx.BeginPath() gfx.BeginPath()
gfx.FillColor(0, 0, 0, 192) gfx.FillColor(0, 0, 0, 192)
@ -124,9 +124,9 @@ local renderBase = function (deltaTime, centerX, centerY, rotation)
end end
local renderOverlay = function (deltaTime, centerX, centerY, rotation, cursors, laserActive) local renderOverlay = function (deltaTime, centerX, centerY, rotation, cursors, laserActive)
scale, isLandscape = Dimensions.setUpTransforms(centerX, centerY, rotation) scale, _ = Dimensions.setUpTransforms(centerX, centerY, rotation)
drawCursors(centerX, centerY, cursors, laserActive) drawCursors(scale, cursors, laserActive)
gfx.ResetTransform() gfx.ResetTransform()
end end

View File

@ -126,10 +126,10 @@ function HitFX.renderLasers(deltaTime, critCenterX, critCenterY, critRotation, c
end end
-- Render -- Render
local laserColor = {game.GetLaserColor(laser - 1)} scale, _ = Dimensions.setUpTransforms(critCenterX, critCenterY, critRotation)
local x = cursors[laser - 1].pos
Dimensions.setUpTransforms(critCenterX, critCenterY, critRotation) local laserColor = {game.GetLaserColor(laser - 1)}
local x = cursors[laser - 1].pos * (1 / scale)
laserState.Dome:render(deltaTime, { laserState.Dome:render(deltaTime, {
centered = true, centered = true,