make player wobble as he walks
This commit is contained in:
parent
e40b9a959e
commit
7f26575942
6
Makefile
6
Makefile
@ -10,7 +10,11 @@ all: win32 win64 linux
|
||||
|
||||
love: clean_love
|
||||
mkdir -p build
|
||||
cd src && zip -9 -r ../build/$(name).love .
|
||||
cd src && zip -9 -r ../build/$(name).love . \
|
||||
-x *.tiled-project \
|
||||
-x *.tiled-session \
|
||||
-x *.tsx \
|
||||
-x *.tmx \
|
||||
|
||||
win32: clean_windows download-love-win32 love
|
||||
mkdir -p build/win32/$(name)
|
||||
|
@ -106,8 +106,10 @@ function Player:update(dt)
|
||||
|
||||
if e.acc.x ~= 0 or e.acc.y ~= 0 then
|
||||
e.sprite.variant = "walk"
|
||||
e.sprite.wobble = true
|
||||
else
|
||||
e.sprite.variant = "idle"
|
||||
e.sprite.wobble = false
|
||||
end
|
||||
|
||||
if e.acc.x < 0 then
|
||||
|
@ -39,6 +39,7 @@ function Sprite:draw()
|
||||
if not e.hidden then
|
||||
local variant = sprite.variants[e.sprite.variant or "default"]
|
||||
if variant and e.sprite.frame then
|
||||
local rotation = nil
|
||||
local frame = variant[e.sprite.frame]
|
||||
if not frame then
|
||||
frame = variant[1]
|
||||
@ -47,11 +48,17 @@ function Sprite:draw()
|
||||
if e.sprite.flip then
|
||||
sx = -1
|
||||
end
|
||||
|
||||
if e.sprite.wobble then
|
||||
rotation = math.sin(love.timer.getTime()*10)*0.15
|
||||
end
|
||||
|
||||
love.graphics.draw(
|
||||
frame.image,
|
||||
e.pos.x,
|
||||
e.pos.y,
|
||||
0, sx, 1,
|
||||
rotation,
|
||||
sx, 1,
|
||||
sprite.width/2, sprite.height/2
|
||||
)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user