You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.4 KiB
70 lines
1.4 KiB
PowerUp = Object:extend()
|
|
|
|
-- PowerUp is the super class for all power-ups
|
|
-- found in the game
|
|
|
|
function PowerUp:new(name, x, y, image, time, lifetime)
|
|
self.name = name
|
|
self.x = x
|
|
self.y = y
|
|
self.image = love.graphics.newImage(image)
|
|
self.time = time
|
|
self.lifetime = lifetime
|
|
|
|
self.width = self.image:getWidth()
|
|
self.height = self.image:getHeight()
|
|
|
|
self.rotation = 1
|
|
self.scaleX = 1
|
|
self.scaleY = 1
|
|
self.originX = self.width / 2
|
|
self.originY = self.height / 2
|
|
|
|
-- Collider
|
|
self.collider = World:newRectangleCollider(x, y, 20, 20)
|
|
self.collider:setCollisionClass("PowerUp")
|
|
self.collider:setType("static")
|
|
self.collider:setPosition(self.x, self.y)
|
|
end
|
|
-- TODO: clean up colliosn on reset
|
|
-- make image draw
|
|
-- more stuff
|
|
-- see you later
|
|
|
|
function PowerUp:apply(player) end
|
|
|
|
function PowerUp:remove(player) end
|
|
|
|
function PowerUp:update(dt)
|
|
--check if the power up is past its lifetime
|
|
|
|
--spinnnnnn
|
|
self.rotation = self.rotation + 1.5 * dt
|
|
|
|
--grown and shrink
|
|
--[[
|
|
if self.scaleX >= 1.0 then
|
|
self.scaleX = self.scaleX - 0.2 * dt
|
|
elseif self.scaleX <= 1.8 then
|
|
self.scaleX = self.scaleX + 0.2 * dt
|
|
end
|
|
]]
|
|
|
|
self.x = self.collider:getX()
|
|
self.y = self.collider:getY()
|
|
end
|
|
|
|
function PowerUp:draw()
|
|
for _, _ in ipairs(PowerUps) do
|
|
love.graphics.draw(
|
|
self.image,
|
|
self.x,
|
|
self.y,
|
|
self.rotation,
|
|
self.scaleX,
|
|
self.scaleY,
|
|
self.originX,
|
|
self.originY
|
|
)
|
|
end
|
|
end
|
|
|