animated siren sprite

This commit is contained in:
2024-12-08 13:15:41 -06:00
parent 79cd77dfb4
commit 20eef4ec69
3 changed files with 8 additions and 4 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 385 B

After

Width:  |  Height:  |  Size: 591 B

View File

@@ -1,5 +1,6 @@
local LoveNode = require 'src.utils.love_node'
local vector = require 'packages.vector-light'
local anim8 = require 'packages.anim8'
local random = require 'src.utils.random'
require 'src.utils.math'
@@ -19,10 +20,12 @@ function Siren.new(game)
maxEffectiveRadius = 8 * TILE_SIZE
}
self.texture = love.graphics.newImage 'assets/images/siren.png'
self.size = {}
self.size.w, self.size.h = self.texture:getDimensions()
self.size.w, self.size.h = 16, 16
self.texture = love.graphics.newImage 'assets/images/siren.png'
local g = anim8.newGrid(self.size.w, self.size.h, self.texture:getDimensions())
self.animation = anim8.newAnimation(g('1-1', 1), 0.1)
self.isEnemy = true
self.pos = self:_findSpawnPoint()
@@ -33,6 +36,7 @@ function Siren.new(game)
end
function Siren:update(dt)
self.animation:update(dt)
self:_updateDistanceToPlayer()
if self.distanceToPlayer < self.stats.minEffectiveRadius then
self.pos = self:_findSpawnPoint()
@@ -49,7 +53,7 @@ function Siren:update(dt)
end
function Siren:draw()
love.graphics.draw(self.texture, self.pos.x, self.pos.y)
self.animation:draw(self.texture, self.pos.x, self.pos.y)
end
function Siren:getPos() return self.pos.x, self.pos.y end