ExperimentalGear/scripts/gameplay/crit_line.lua

135 lines
3.5 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),
}
local CRITBAR_W = 1080
local CRITBAR_H = 251
2022-04-27 00:12:14 +02:00
local scale = 1;
2021-11-26 20:56:56 +01:00
local isLandscape = false;
local drawCursors = function (centerX, centerY,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);
local cursorX = cursor.pos * (1 / scale) - cursorW / 2;
local cursorY = -cursorH / 2;
2021-11-27 17:03:03 +01:00
if laserActive[luaIndex] then
gfx.ImageRect(
cursor.pos - tailW / 2,
- tailH / 2,
tailW,
tailH,
cursorTailImages[luaIndex],
cursor.alpha,
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
local renderBase = function (deltaTime, centerX, centerY, rotation, cursors, laserActive)
scale, 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
drawCursors(centerX, centerY, cursors, laserActive)
2022-04-27 00:12:14 +02:00
gfx.ResetTransform()
end
local renderOverlay = function (deltaTime)
2022-04-27 00:12:14 +02:00
end
return {
renderBase=renderBase,
renderOverlay=renderOverlay
}