ExperimentalGear/scripts/gameplay/crit_line.lua

137 lines
3.6 KiB
Lua
Raw Normal View History

local Dimensions = require 'common.dimensions'
2022-04-27 00:12:14 +02:00
local blackGradientImage = gfx.CreateSkinImage('gameplay/crit_line/black_gradient.png', 0)
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 cursorTailImages = {
gfx.CreateSkinImage("gameplay/crit_line/cursor_tail_l.png", 0),
gfx.CreateSkinImage("gameplay/crit_line/cursor_tail_r.png", 0),
}
2022-05-31 21:30:52 +02:00
local CRITBAR_W = 1080 * 1.4
local CRITBAR_H = 251 * 1.4
2021-11-26 20:56:56 +01:00
local isLandscape = false;
2022-05-31 21:30:52 +02:00
local drawCursors = function (scale, cursors, laserActive)
2022-04-27 00:12:14 +02:00
local cursorW = 598 * 0.165;
local cursorH = 673 * 0.14;
local tailW = cursorW * 9
local tailH = cursorH * 9
2021-11-21 16:56:23 +01:00
for i = 0, 1, 1 do
local luaIndex = i + 1
2021-11-21 16:56:23 +01:00
local cursor = cursors[i];
2022-04-27 00:12:14 +02:00
gfx.Save();
2021-11-21 16:56:23 +01:00
gfx.BeginPath();
2021-11-27 17:03:03 +01:00
2022-04-27 00:12:14 +02:00
local skew = cursor.pos * 0.001;
gfx.SkewX(skew);
2022-05-31 21:30:52 +02:00
local cursorPos = cursor.pos * (1 / scale)
local cursorX = cursorPos - cursorW / 2;
2022-04-27 00:12:14 +02:00
local cursorY = -cursorH / 2;
2021-11-27 17:03:03 +01:00
if laserActive[luaIndex] then
gfx.ImageRect(
2022-05-31 21:30:52 +02:00
cursorPos - tailW / 2,
- tailH / 2,
tailW,
tailH,
cursorTailImages[luaIndex],
2022-05-16 10:35:11 +02:00
cursor.alpha / 2,
0
)
end
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[luaIndex],
2021-11-27 17:03:03 +01:00
cursor.alpha,
0
);
gfx.ImageRect(
cursorX,
cursorY,
cursorW,
cursorH,
cursorTopImage,
cursor.alpha,
0
);
gfx.ImageRect(
cursorX,
cursorY,
cursorW,
cursorH,
cursorGlowTopImages[luaIndex],
2021-11-27 17:03:03 +01:00
cursor.alpha,
0
);
2021-11-21 16:56:23 +01:00
gfx.Restore();
end
end
2022-05-16 10:32:41 +02:00
local renderBase = function (deltaTime, centerX, centerY, rotation)
2022-05-31 21:30:52 +02:00
_, isLandscape = Dimensions.setUpTransforms(centerX, centerY, rotation)
2021-10-28 17:56:57 +02:00
gfx.BeginPath()
gfx.FillColor(0, 0, 0, 192)
2022-04-27 00:12:14 +02:00
gfx.Rect(-9999, 0, 9999 * 2, 1080)
2021-10-28 17:56:57 +02:00
gfx.Fill()
2022-02-20 05:01:15 +01:00
if (isLandscape) then
2022-04-27 00:12:14 +02:00
gfx.BeginPath();
gfx.ImageRect(-9999, -CRITBAR_H/2, 9999 * 2, CRITBAR_H, baseImageLandscape, 1, 0);
2022-02-20 05:01:15 +01:00
else
2022-04-27 00:12:14 +02:00
gfx.BeginPath();
2022-02-20 05:01:15 +01:00
gfx.ImageRect(-CRITBAR_W/2, -CRITBAR_H/2, CRITBAR_W, CRITBAR_H, baseImage, 1, 0);
end
gfx.ResetTransform()
end
2022-05-16 10:32:41 +02:00
local renderOverlay = function (deltaTime, centerX, centerY, rotation, cursors, laserActive)
2022-05-31 21:30:52 +02:00
scale, _ = Dimensions.setUpTransforms(centerX, centerY, rotation)
2022-05-16 10:32:41 +02:00
2022-05-31 21:30:52 +02:00
drawCursors(scale, cursors, laserActive)
2022-04-27 00:12:14 +02:00
2022-05-16 10:32:41 +02:00
gfx.ResetTransform()
end
return {
renderBase=renderBase,
renderOverlay=renderOverlay
}