ExperimentalGear/scripts/gameplay/crit_line.lua

128 lines
3.0 KiB
Lua
Raw Normal View History

local baseImage = gfx.CreateSkinImage("gameplay/crit_line/base.png", 0)
2022-02-20 05:01:15 +01:00
local baseImageLandscape = gfx.CreateSkinImage("gameplay/crit_line/base_landscape.png", 0)
local textImage = gfx.CreateSkinImage("gameplay/crit_line/text.png", 0)
2021-11-27 17:03:03 +01:00
local cursorImage = gfx.CreateSkinImage("gameplay/crit_line/cursor.png", 0);
local cursorTopImage = gfx.CreateSkinImage("gameplay/crit_line/cursor_top.png", 0);
local cursorGlowBottomImages = {
gfx.CreateSkinImage("gameplay/crit_line/cursor_glow_bottom_left.png", 0),
gfx.CreateSkinImage("gameplay/crit_line/cursor_glow_bottom_right.png", 0),
}
local cursorGlowTopImages = {
gfx.CreateSkinImage("gameplay/crit_line/cursor_glow_top_left.png", 0),
gfx.CreateSkinImage("gameplay/crit_line/cursor_glow_top_right.png", 0),
}
local CRITBAR_W = 1496
local CRITBAR_H = 348
2021-11-23 21:17:25 +01:00
local scale;
2021-11-26 20:56:56 +01:00
local isLandscape = false;
local setUpTransforms = function (x,y,rotation)
2021-11-26 20:56:56 +01:00
local resx, resy = game.GetResolution();
isLandscape = resx > resy;
local desw, desh;
if (isLandscape) then
desw = 1920;
desh = 1080;
else
desw = 1080;
desh = 1920;
end
2021-11-23 21:17:25 +01:00
scale = resx / desw
2021-10-28 17:27:26 +02:00
gfx.Translate(x, y)
gfx.Rotate(rotation)
2021-10-28 17:27:26 +02:00
gfx.Scale(scale,scale)
end
2021-11-23 21:17:25 +01:00
local drawCursors = function (centerX, centerY,cursors)
2021-11-21 16:56:23 +01:00
local cursorW = 598*0.2;
local cursorH = 673*0.2;
for i = 0, 1, 1 do
gfx.Save();
local cursor = cursors[i];
gfx.BeginPath();
gfx.SkewX(cursor.skew)
2021-11-27 17:03:03 +01:00
local cursorX = (cursor.pos *(1/scale) - cursorW/2);
local cursorY = (-cursorH/2);
2021-11-21 16:56:23 +01:00
gfx.ImageRect(
2021-11-27 17:03:03 +01:00
cursorX,
cursorY,
2021-11-21 16:56:23 +01:00
cursorW,
cursorH,
cursorImage,
cursor.alpha,
0
);
2021-11-27 17:03:03 +01:00
gfx.ImageRect(
cursorX,
cursorY,
cursorW,
cursorH,
cursorGlowBottomImages[i+1],
cursor.alpha,
0
);
gfx.ImageRect(
cursorX,
cursorY,
cursorW,
cursorH,
cursorTopImage,
cursor.alpha,
0
);
gfx.ImageRect(
cursorX,
cursorY,
cursorW,
cursorH,
cursorGlowTopImages[i+1],
cursor.alpha,
0
);
2021-11-21 16:56:23 +01:00
gfx.Restore();
end
end
local renderBase = function (deltaTime, centerX, centerY, rotation, cursors)
setUpTransforms(centerX, centerY, rotation)
2021-10-28 17:56:57 +02:00
gfx.BeginPath()
gfx.FillColor(0, 0, 0, 192)
gfx.Rect(-1080/2, 0, 1080, 1080)
gfx.Fill()
gfx.BeginPath();
2022-02-20 05:01:15 +01:00
if (isLandscape) then
gfx.ImageRect(-CRITBAR_W/2, -CRITBAR_H/2, CRITBAR_W, CRITBAR_H, baseImageLandscape, 1, 0);
else
gfx.ImageRect(-CRITBAR_W/2, -CRITBAR_H/2, CRITBAR_W, CRITBAR_H, baseImage, 1, 0);
end
2021-11-23 21:17:25 +01:00
drawCursors(centerX, centerY, cursors)
gfx.ResetTransform()
end
local renderOverlay = function (deltaTime)
end
return {
renderBase=renderBase,
renderOverlay=renderOverlay
}