Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions vfx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ function VFX.init()
-- Generic effects
sparkle = "assets/sprites/sparkle.png",
impactRing = "assets/sprites/impact-ring.png",

-- Pixel primitive effects
pixel1 = "assets/sprites/1px.png",
twinkle1 = "assets/sprites/3px-twinkle1.png",
twinkle2 = "assets/sprites/3px-twinkle2.png",

-- Bolt effects
boltFrames = {
Expand Down Expand Up @@ -146,6 +151,12 @@ function VFX.init()
-- Preload sparkle asset (used in many effects)
print("[VFX] Preloading essential asset: sparkle")
VFX.assets.sparkle = AssetCache.getImage(VFX.assetPaths.sparkle)

-- Preload pixel primitives used for hard-edged effects
print("[VFX] Preloading pixel primitive assets")
VFX.assets.pixel1 = AssetCache.getImage(VFX.assetPaths.pixel1)
VFX.assets.twinkle1 = AssetCache.getImage(VFX.assetPaths.twinkle1)
VFX.assets.twinkle2 = AssetCache.getImage(VFX.assetPaths.twinkle2)

-- Preload bolt frames for the bolt effects
print("[VFX] Preloading bolt frame assets")
Expand Down Expand Up @@ -214,6 +225,7 @@ function VFX.init()
flickerRate = 12, -- Rate at which particles flicker (Hz)
flickerIntensity = 0.3, -- Intensity of the flicker effect (0-1)
useSprites = true, -- Flag to indicate this effect uses sprite frames
pixelTrail = true, -- Use pixel primitives for the trail
spriteFrameRate = 15, -- Frames per second for sprite animation
spriteRotationOffset = 0.78, -- Radians to rotate the sprite by default (≈45 degrees)
spriteScale = 0.85, -- Base scale factor for the sprite
Expand All @@ -223,6 +235,7 @@ function VFX.init()
criticalAssets = {"boltFrames"} -- Mark bolt frames as critical assets to preload
},


warp_base = {
type = "warp_base", -- Template name as type
duration = 1.0, -- Standard duration
Expand Down
56 changes: 42 additions & 14 deletions vfx/effects/projectile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,12 @@ local function updateProjectile(effect, dt)
if math.random() < particleRate then
-- Create a new particle using specialized helper
local particle = ParticleManager.createProjectileTrailParticle(effect, head.x, head.y)


if effect.pixelTrail then
particle.assetId = (math.random() < 0.5) and "twinkle1" or "twinkle2"
particle.size = 3
end

-- Add the particle to the effect
table.insert(effect.particles, particle)
end
Expand Down Expand Up @@ -316,6 +321,9 @@ local function drawProjectile(effect)
local particleImage = getAssetInternal("fireParticle")
local glowImage = getAssetInternal("fireGlow")
local impactImage = getAssetInternal("impactRing")
local pixelImage = getAssetInternal("pixel1")
local twinkle1 = getAssetInternal("twinkle1")
local twinkle2 = getAssetInternal("twinkle2")

-- Get bolt frames if needed
local boltFrames = nil
Expand Down Expand Up @@ -348,18 +356,25 @@ local function drawProjectile(effect)
local point = effect.trailPoints[i]
local trailSize = (effect.size or 1.0) * 3 * (1 - (i-1)/#effect.trailPoints)
local trailAlpha = point.alpha * 0.4

-- Draw trail glow at each point
local color = effect.color or {1, 1, 1} -- Default to white if no color
love.graphics.setColor(
color[1],
color[2],
color[3],
color[1],
color[2],
color[3],
trailAlpha
)

-- Draw a circle for each trail point
if glowImage then

if effect.pixelTrail and pixelImage then
love.graphics.draw(
pixelImage,
point.x, point.y,
0,
trailSize, trailSize,
0.5, 0.5
)
elseif glowImage then
love.graphics.draw(
glowImage,
point.x, point.y,
Expand All @@ -368,7 +383,6 @@ local function drawProjectile(effect)
glowImage:getWidth()/2, glowImage:getHeight()/2
)
else
-- Fallback to a circle if glow asset is missing
love.graphics.circle("fill", point.x, point.y, trailSize * 10)
end
end
Expand All @@ -391,16 +405,30 @@ local function drawProjectile(effect)
)

-- Draw particle
if particleImage then
local img = particleImage
local scale = (particle.size or 5)/20
if effect.pixelTrail then
if particle.assetId == "twinkle1" and twinkle1 then
img = twinkle1
scale = effect.size or 1
elseif particle.assetId == "twinkle2" and twinkle2 then
img = twinkle2
scale = effect.size or 1
elseif pixelImage then
img = pixelImage
scale = effect.size or 1
end
end

if img then
love.graphics.draw(
particleImage,
img,
particle.x, particle.y,
0,
(particle.size or 5)/20, (particle.size or 5)/20,
particleImage:getWidth()/2, particleImage:getHeight()/2
scale, scale,
(img:getWidth()/2), (img:getHeight()/2)
)
else
-- Fallback to a circle if particle asset is missing
love.graphics.circle("fill", particle.x, particle.y, particle.size or 5)
end

Expand Down