From 62f3cd6b655d3cceede0945060420009db8fc388 Mon Sep 17 00:00:00 2001 From: André Fabian Silva Delgado Date: Sun, 18 Dec 2016 14:37:04 -0300 Subject: Enable initial jumping animation --- src/gnu_and_bola_brawlers/update/default.lua | 29 +++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'src/gnu_and_bola_brawlers/update') diff --git a/src/gnu_and_bola_brawlers/update/default.lua b/src/gnu_and_bola_brawlers/update/default.lua index 064f7d0..d53dbc3 100644 --- a/src/gnu_and_bola_brawlers/update/default.lua +++ b/src/gnu_and_bola_brawlers/update/default.lua @@ -23,21 +23,36 @@ update.animation = function(metaSprite, images, dt) end update.motion = function(character, images, metaSprite, dt) - if character.jump.higher > 0 and character.actionA == true then + if character.actionUp == true and character.actionDown == true then + metaSprite = character.stand + elseif character.actionLeft == true and character.actionRight == true then + metaSprite = character.stand + elseif character.actionLeft == false and character.actionRight == false and character.actionUp == false and character.actionDown == false and character.jump.higher > 0 and character.actionA == false then + metaSprite = character.stand + end + + if character.jump.higher > 0 and character.actionUp == false and character.actionDown == false and character.actionA == true then + metaSprite = character.jump if character.jump.limitButtonJump == false then character.jump.higher = character.jump.higher - dt character.jump.velocity = character.jump.velocity + character.jump.height * (dt / character.jump.higherMax) end + elseif character.jump.higher < 0 and character.actionUp == false and character.actionDown == false and character.actionA == false then + metaSprite = character.fall end if character.actionLeft == true and character.actionRight == false then - metaSprite = character.walk + if character.jump.higher > 0 and character.actionA == false then + metaSprite = character.walk + end character.position.x = character.position.x - (character.velocity * dt) character.scale.x = -1 end if character.actionRight == true and character.actionLeft == false then - metaSprite = character.walk + if character.jump.higher > 0 and character.actionA == false then + metaSprite = character.walk + end character.position.x = character.position.x + (character.velocity * dt) character.scale.x = 1 end @@ -54,14 +69,6 @@ update.motion = function(character, images, metaSprite, dt) character.jump.ground = character.position.y end - if character.actionUp == true and character.actionDown == true then - metaSprite = character.stand - elseif character.actionLeft == true and character.actionRight == true then - metaSprite = character.stand - elseif character.actionLeft == false and character.actionRight == false and character.actionUp == false and character.actionDown == false then - metaSprite = character.stand - end - return metaSprite end -- cgit v1.2.3-54-g00ecf