diff --git a/Source/Main.lua b/Source/Main.lua index e44e7f7..27365e4 100644 --- a/Source/Main.lua +++ b/Source/Main.lua @@ -46,4 +46,5 @@ function playdate.update() gfx.sprite.update() drawTiles() end + updateSaws() end \ No newline at end of file diff --git a/Source/Player.lua b/Source/Player.lua index 32614fc..cbc6910 100644 --- a/Source/Player.lua +++ b/Source/Player.lua @@ -1,9 +1,11 @@ import "CoreLibs/math" +import "CoreLibs/animator" local velocity = {x=0,y=0} local lerpmnt = 0.5 local grav = 0.2 scale = 1 +local dead = false local exists = false local active = false @@ -22,6 +24,7 @@ sprBigRocket:setGroups({2}) function addPlayer(_x,_y,__x,__y) exists = true + dead = false scale = 1 active = false velocity = {x=0,y=0} @@ -42,6 +45,7 @@ end local function playerWin() active = false exists = false + dead = true end local function die() @@ -77,7 +81,10 @@ function updatePlayer() end local cx, cy = gfx.getDrawOffset() gfx.setDrawOffset(playdate.math.lerp(cx,(-sprRocket.x + 200), lerpmnt), playdate.math.lerp(cy,(-sprRocket.y + 120), lerpmnt)) - + elseif dead == true then + if scale > 0.1 then + scale -= 0.05 + end end updateExit() diff --git a/Source/Saws.lua b/Source/Saws.lua index 05b6ee4..c29c899 100644 --- a/Source/Saws.lua +++ b/Source/Saws.lua @@ -1,3 +1,4 @@ +import "CoreLibs/animator" local gfx = playdate.graphics local imgSaw = gfx.image.new("gfx/sawblade") @@ -17,6 +18,10 @@ function loadBlades(_blades) b.saw:setCollideRect(0,0,16,16) b.saw:add() + local a = gfx.animator.new(b.speed*1000, b.start, b.ends) + + b.saw:setAnimator(a) + b.t1 = gfx.sprite.new(imgTarget) b.t1:moveTo(b.start) b.t2 = gfx.sprite.new(imgTarget) @@ -27,6 +32,22 @@ function loadBlades(_blades) end end +function updateSaws() + for b=1, #blades, 1 do + b = blades[b] + local pos = playdate.geometry.point.new(b.saw:getPosition()) + if pos == b.start then + local a = gfx.animator.new(b.speed*1000, b.start, b.ends) + + b.saw:setAnimator(a) + elseif pos == b.ends then + local a = gfx.animator.new(b.speed*1000, b.ends, b.start) + + b.saw:setAnimator(a) + end + end +end + function killBlades() for i = 1, #blades, 1 do blades[i].t1:remove()