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
|
love: clean_love
|
||||||
mkdir -p build
|
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
|
win32: clean_windows download-love-win32 love
|
||||||
mkdir -p build/win32/$(name)
|
mkdir -p build/win32/$(name)
|
||||||
|
@ -106,8 +106,10 @@ function Player:update(dt)
|
|||||||
|
|
||||||
if e.acc.x ~= 0 or e.acc.y ~= 0 then
|
if e.acc.x ~= 0 or e.acc.y ~= 0 then
|
||||||
e.sprite.variant = "walk"
|
e.sprite.variant = "walk"
|
||||||
|
e.sprite.wobble = true
|
||||||
else
|
else
|
||||||
e.sprite.variant = "idle"
|
e.sprite.variant = "idle"
|
||||||
|
e.sprite.wobble = false
|
||||||
end
|
end
|
||||||
|
|
||||||
if e.acc.x < 0 then
|
if e.acc.x < 0 then
|
||||||
|
@ -39,6 +39,7 @@ function Sprite:draw()
|
|||||||
if not e.hidden then
|
if not e.hidden then
|
||||||
local variant = sprite.variants[e.sprite.variant or "default"]
|
local variant = sprite.variants[e.sprite.variant or "default"]
|
||||||
if variant and e.sprite.frame then
|
if variant and e.sprite.frame then
|
||||||
|
local rotation = nil
|
||||||
local frame = variant[e.sprite.frame]
|
local frame = variant[e.sprite.frame]
|
||||||
if not frame then
|
if not frame then
|
||||||
frame = variant[1]
|
frame = variant[1]
|
||||||
@ -47,11 +48,17 @@ function Sprite:draw()
|
|||||||
if e.sprite.flip then
|
if e.sprite.flip then
|
||||||
sx = -1
|
sx = -1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if e.sprite.wobble then
|
||||||
|
rotation = math.sin(love.timer.getTime()*10)*0.15
|
||||||
|
end
|
||||||
|
|
||||||
love.graphics.draw(
|
love.graphics.draw(
|
||||||
frame.image,
|
frame.image,
|
||||||
e.pos.x,
|
e.pos.x,
|
||||||
e.pos.y,
|
e.pos.y,
|
||||||
0, sx, 1,
|
rotation,
|
||||||
|
sx, 1,
|
||||||
sprite.width/2, sprite.height/2
|
sprite.width/2, sprite.height/2
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user