Compare commits
3 Commits
451d710326
...
86d33a7fc5
Author | SHA1 | Date |
---|---|---|
Simon Kellet | 86d33a7fc5 | 4 months ago |
Simon Kellet | 65f4ee3473 | 4 months ago |
Simon Kellet | e13114a736 | 4 months ago |
After Width: | Height: | Size: 2.8 KiB |
@ -0,0 +1,70 @@ |
||||
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 |
Loading…
Reference in new issue