- [NEW] Animació de caminar i d'estar quet de Morcus activades
- [NEW] Es pot pasar quan es vullga del joc al editor i viceversa - [NEW] Els shaders s'activen en el joc i se desactiven en l'editor
This commit is contained in:
@@ -9,14 +9,35 @@ sprites = {
|
||||
pos = { x=24, y=15 },
|
||||
size= { w=16, h=17 },
|
||||
bbo = { left=0, top=0, right=0, bottom=0 },
|
||||
animation = "hero_walk",
|
||||
flipped = false,
|
||||
animation = "hero_stand",
|
||||
current_frame = 1,
|
||||
current_wait = 1
|
||||
}
|
||||
end,
|
||||
|
||||
set_animation=function(sprite, animation)
|
||||
if sprite.animation ~= animation then
|
||||
sprite.animation = animation
|
||||
sprite.current_frame = 1
|
||||
sprite.current_wait = 1
|
||||
end
|
||||
end,
|
||||
|
||||
update = function()
|
||||
sprites.update_sprite(sprites.hero)
|
||||
|
||||
if key.down(key.LEFT) then
|
||||
sprites.hero.flipped = true
|
||||
sprites.set_animation(sprites.hero, "hero_walk")
|
||||
sprites.hero.pos.x = sprites.hero.pos.x - 1
|
||||
elseif key.down(key.RIGHT) then
|
||||
sprites.hero.flipped = false
|
||||
sprites.set_animation(sprites.hero, "hero_walk")
|
||||
sprites.hero.pos.x = sprites.hero.pos.x + 1
|
||||
else
|
||||
sprites.set_animation(sprites.hero, "hero_stand")
|
||||
end
|
||||
end,
|
||||
|
||||
update_sprite = function(sprite)
|
||||
@@ -43,6 +64,6 @@ sprites = {
|
||||
draw_sprite = function(sprite)
|
||||
local cycle = animations[sprite.animation].cycle[sprite.current_frame]
|
||||
local frame = animations[sprite.animation].frames[cycle]
|
||||
draw.surf(frame.frame.x, frame.frame.y, frame.frame.w, frame.frame.h, sprite.pos.x, sprite.pos.y, sprite.size.w, sprite.size.h)
|
||||
draw.surf(frame.frame.x, frame.frame.y, frame.frame.w, frame.frame.h, sprite.pos.x, sprite.pos.y, sprite.size.w, sprite.size.h, sprite.flipped)
|
||||
end
|
||||
}
|
||||
Reference in New Issue
Block a user