made player shrink on win
This commit is contained in:
parent
07b48b6e0d
commit
49f32674e5
3 changed files with 30 additions and 1 deletions
|
@ -46,4 +46,5 @@ function playdate.update()
|
||||||
gfx.sprite.update()
|
gfx.sprite.update()
|
||||||
drawTiles()
|
drawTiles()
|
||||||
end
|
end
|
||||||
|
updateSaws()
|
||||||
end
|
end
|
|
@ -1,9 +1,11 @@
|
||||||
import "CoreLibs/math"
|
import "CoreLibs/math"
|
||||||
|
import "CoreLibs/animator"
|
||||||
|
|
||||||
local velocity = {x=0,y=0}
|
local velocity = {x=0,y=0}
|
||||||
local lerpmnt <const> = 0.5
|
local lerpmnt <const> = 0.5
|
||||||
local grav <const> = 0.2
|
local grav <const> = 0.2
|
||||||
scale = 1
|
scale = 1
|
||||||
|
local dead = false
|
||||||
|
|
||||||
local exists = false
|
local exists = false
|
||||||
local active = false
|
local active = false
|
||||||
|
@ -22,6 +24,7 @@ sprBigRocket:setGroups({2})
|
||||||
|
|
||||||
function addPlayer(_x,_y,__x,__y)
|
function addPlayer(_x,_y,__x,__y)
|
||||||
exists = true
|
exists = true
|
||||||
|
dead = false
|
||||||
scale = 1
|
scale = 1
|
||||||
active = false
|
active = false
|
||||||
velocity = {x=0,y=0}
|
velocity = {x=0,y=0}
|
||||||
|
@ -42,6 +45,7 @@ end
|
||||||
local function playerWin()
|
local function playerWin()
|
||||||
active = false
|
active = false
|
||||||
exists = false
|
exists = false
|
||||||
|
dead = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local function die()
|
local function die()
|
||||||
|
@ -77,7 +81,10 @@ function updatePlayer()
|
||||||
end
|
end
|
||||||
local cx, cy = gfx.getDrawOffset()
|
local cx, cy = gfx.getDrawOffset()
|
||||||
gfx.setDrawOffset(playdate.math.lerp(cx,(-sprRocket.x + 200), lerpmnt), playdate.math.lerp(cy,(-sprRocket.y + 120), lerpmnt))
|
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
|
end
|
||||||
updateExit()
|
updateExit()
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import "CoreLibs/animator"
|
||||||
local gfx <const> = playdate.graphics
|
local gfx <const> = playdate.graphics
|
||||||
|
|
||||||
local imgSaw = gfx.image.new("gfx/sawblade")
|
local imgSaw = gfx.image.new("gfx/sawblade")
|
||||||
|
@ -17,6 +18,10 @@ function loadBlades(_blades)
|
||||||
b.saw:setCollideRect(0,0,16,16)
|
b.saw:setCollideRect(0,0,16,16)
|
||||||
b.saw:add()
|
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 = gfx.sprite.new(imgTarget)
|
||||||
b.t1:moveTo(b.start)
|
b.t1:moveTo(b.start)
|
||||||
b.t2 = gfx.sprite.new(imgTarget)
|
b.t2 = gfx.sprite.new(imgTarget)
|
||||||
|
@ -27,6 +32,22 @@ function loadBlades(_blades)
|
||||||
end
|
end
|
||||||
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()
|
function killBlades()
|
||||||
for i = 1, #blades, 1 do
|
for i = 1, #blades, 1 do
|
||||||
blades[i].t1:remove()
|
blades[i].t1:remove()
|
||||||
|
|
Loading…
Reference in a new issue