Added laser HitFX

This commit is contained in:
domdoc 2022-05-15 11:07:07 +02:00
parent 48d1424b63
commit f2288ecf71
2 changed files with 113 additions and 12 deletions

View File

@ -65,12 +65,13 @@ function render(deltaTime)
end end
function render_crit_base(deltaTime) function render_crit_base(deltaTime)
HitFX.renderLasers(deltaTime, gameplay.critLine.x, gameplay.critLine.y, -gameplay.critLine.rotation, gameplay.critLine.cursors);
CritLine.renderBase(deltaTime, gameplay.critLine.x, gameplay.critLine.y, -gameplay.critLine.rotation, gameplay.critLine.cursors); CritLine.renderBase(deltaTime, gameplay.critLine.x, gameplay.critLine.y, -gameplay.critLine.rotation, gameplay.critLine.cursors);
Console.render(deltaTime, gameplay.critLine.x, gameplay.critLine.y, -gameplay.critLine.rotation); Console.render(deltaTime, gameplay.critLine.x, gameplay.critLine.y, -gameplay.critLine.rotation);
end end
function render_crit_overlay(deltaTime) function render_crit_overlay(deltaTime)
HitFX.render(deltaTime, gameplay.critLine.x, gameplay.critLine.y, -gameplay.critLine.rotation, gameplay.critLine.cursors); HitFX.renderButtons(deltaTime, gameplay.critLine.x, gameplay.critLine.y, -gameplay.critLine.rotation);
end end
function render_intro(deltaTime) function render_intro(deltaTime)

View File

@ -33,8 +33,44 @@ local Animations = {
centered = true, centered = true,
loop = true, loop = true,
}), }),
LaserCrit = Animation.new('gameplay/hit_animation_frames/laser_critical', {
loop = true,
}),
LaserDome = Animation.new('gameplay/hit_animation_frames/laser_dome', {
loop = true,
}),
LaserEndOuter = Animation.new('gameplay/hit_animation_frames/laser_end_outer', {}),
LaserEndLeft = Animation.new('gameplay/hit_animation_frames/laser_end_l_inner', {}),
LaserEndRight = Animation.new('gameplay/hit_animation_frames/laser_end_r_inner', {}),
}; };
---@class LaserStateTable
---@field Crit AnimationState
---@field Dome AnimationState
---@field EndInner AnimationState
---@field EndOuter AnimationState
---@type LaserStateTable[]
local laserStateTables = {
{
Crit = Animations.LaserCrit:createState(),
Dome = Animations.LaserDome:createState(),
EndInner = Animations.LaserEndLeft:createState(),
EndOuter = Animations.LaserEndOuter:createState()
},
{
Crit = Animations.LaserCrit:createState(),
Dome = Animations.LaserDome:createState(),
EndInner = Animations.LaserEndRight:createState(),
EndOuter = Animations.LaserEndOuter:createState()
}
}
---@class HoldStateTable ---@class HoldStateTable
---@field Crit AnimationState ---@field Crit AnimationState
---@field Dome AnimationState ---@field Dome AnimationState
@ -58,16 +94,77 @@ local tapStates = {}
local HitFX = { }; local HitFX = { };
local function setupLaneTransform(lanePosition, critCenterX, critCenterY) local function setUpTransform(critCenterX, critCenterY, critRotation, xScalar)
local critLine = gameplay.critLine; local critLine = gameplay.critLine
local x = critCenterX + (critLine.line.x2 - critLine.line.x1) * lanePosition; local x = critCenterX + (critLine.line.x2 - critLine.line.x1) * xScalar
local y = critCenterY + (critLine.line.y2 - critLine.line.y1) * lanePosition; local y = critCenterY + (critLine.line.y2 - critLine.line.y1) * xScalar
Dimensions.setUpTransforms(x, y, -critLine.rotation);
Dimensions.setUpTransforms(x, y, critRotation)
end end
function HitFX.render(deltaTime, critCenterX, critCenterY, critRotation, cursors) function HitFX.renderLasers(deltaTime, critCenterX, critCenterY, critRotation, cursors)
local baseHitSize = 325 * 1.25;
-- Lasers
for laser = 1, 2 do
-- Update
local isActive = gameplay.laserActive[laser]
local laserState = laserStateTables[laser]
local isAnimationPlaying = laserState.Dome.running
if isActive and not isAnimationPlaying then
laserState.Crit:restart()
laserState.Dome:restart()
end
if not isActive and isAnimationPlaying then
laserState.Crit:stop()
laserState.Dome:stop()
laserState.EndInner:restart()
laserState.EndOuter:restart()
end
-- Render
local laserColor = {game.GetLaserColor(laser - 1)}
local x = cursors[laser - 1].pos
Dimensions.setUpTransforms(critCenterX, critCenterY, critRotation)
laserState.Dome:render(deltaTime, {
centered = true,
width = baseHitSize,
height = baseHitSize,
color = laserColor,
x = x,
})
laserState.Crit:render(deltaTime, {
centered = true,
width = baseHitSize,
height = baseHitSize,
x = x,
})
laserState.EndInner:render(deltaTime, {
centered = true,
width = baseHitSize,
height = baseHitSize,
x = x,
})
laserState.EndOuter:render(deltaTime, {
centered = true,
width = baseHitSize,
height = baseHitSize,
color = laserColor,
x = x,
})
end
end
function HitFX.renderButtons(deltaTime, critCenterX, critCenterY, critRotation)
local baseHitSize = 325; local baseHitSize = 325;
-- BT + FX
for i = 1, 6 do for i = 1, 6 do
local hitSize = baseHitSize; local hitSize = baseHitSize;
if (i > 4) then if (i > 4) then
@ -80,7 +177,7 @@ function HitFX.render(deltaTime, critCenterX, critCenterY, critRotation, cursors
lanePosition = -track.GetCurrentLaneXPos(6) - laneWidth / 2 lanePosition = -track.GetCurrentLaneXPos(6) - laneWidth / 2
end end
-- Holds -- Update Holds
local isHeld = gameplay.noteHeld[i] local isHeld = gameplay.noteHeld[i]
local holdStates = holdStateTables[i] local holdStates = holdStateTables[i]
local isAnimationPlaying = holdStates.Dome.running local isAnimationPlaying = holdStates.Dome.running
@ -99,7 +196,9 @@ function HitFX.render(deltaTime, critCenterX, critCenterY, critRotation, cursors
holdStates.End:restart() holdStates.End:restart()
end end
setupLaneTransform(lanePosition, critCenterX, critCenterY) -- Render holds
setUpTransform(critCenterX, critCenterY, critRotation, lanePosition)
holdStates.Inner:render(deltaTime, { holdStates.Inner:render(deltaTime, {
centered = true, centered = true,
width = hitSize, width = hitSize,
@ -121,7 +220,7 @@ function HitFX.render(deltaTime, critCenterX, critCenterY, critRotation, cursors
height = hitSize height = hitSize
}) })
-- Taps -- Render Taps
local tapState = tapStates[i] local tapState = tapStates[i]
if tapState then if tapState then
@ -131,8 +230,9 @@ function HitFX.render(deltaTime, critCenterX, critCenterY, critRotation, cursors
height = hitSize, height = hitSize,
}); });
end end
gfx.ResetTransform()
end end
gfx.ResetTransform()
end end
function HitFX.TriggerAnimation(name, lane) function HitFX.TriggerAnimation(name, lane)