summaryrefslogtreecommitdiff
path: root/src/gnu_and_bola_brawlers/update/default.lua
diff options
context:
space:
mode:
authorJorge Lopez Seijas <jorginho@riseup.net>2016-12-18 23:55:14 +0100
committerJorge Lopez Seijas <jorginho@riseup.net>2016-12-19 00:00:31 +0100
commit581d69b76cf4b17e9fc77bbbe9ec0274b4de26d2 (patch)
tree33ecc4e6a7e0aefcb59ac81e6fb5ed9571a2e602 /src/gnu_and_bola_brawlers/update/default.lua
parent98c969520e5f4696650d6fd1837992c0445cd9d6 (diff)
Add jump and fall meta sprites, fix some issues, comment update.motion code and add prints for debuggingHEADmasterjorginhoemulatorman
Diffstat (limited to 'src/gnu_and_bola_brawlers/update/default.lua')
-rw-r--r--src/gnu_and_bola_brawlers/update/default.lua60
1 files changed, 47 insertions, 13 deletions
diff --git a/src/gnu_and_bola_brawlers/update/default.lua b/src/gnu_and_bola_brawlers/update/default.lua
index 8f37f6c..b14349b 100644
--- a/src/gnu_and_bola_brawlers/update/default.lua
+++ b/src/gnu_and_bola_brawlers/update/default.lua
@@ -23,48 +23,82 @@ update.animation = function(metaSprite, images, dt)
end
update.motion = function(character, images, metaSprite, dt)
- 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.actionA == false then
- metaSprite = character.stand
+ -- Check if press button up/down, left/right at same time, no button press and character is not jumping then metaSprite is stand
+ if ((character.actionUp == true and character.actionDown == true) or (character.actionLeft == true and character.actionRight == true) or (character.actionLeft == false and character.actionRight == false and character.actionUp == false and character.actionDown == false)) and character.actionA == false and character.jump.isJumping == false then
+ if metaSprite ~= character.stand then
+ print("(update.motion) -> load stand meta sprite")
+ metaSprite = character.stand
+ metaSprite.currentFrame = 1
+ metaSprite.fps = 9
+ end
end
+ -- Check if it is jumping or falling
if character.jump.higher > 0 and character.actionUp == false and character.actionDown == false and character.actionA == true then
- metaSprite = character.jump
+ if metaSprite ~= character.jump then
+ print("(update.motion) -> load jump meta sprite")
+ metaSprite = character.jump
+ metaSprite.currentFrame = 1
+ metaSprite.fps = 6
+ end
+
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
+ elseif (character.jump.velocity > 0 and character.actionUp == false and character.actionDown == false) then
+ if metaSprite ~= character.fall then
+ print("(update.motion) -> load fall meta sprite")
+ metaSprite = character.fall
+ metaSprite.currentFrame = 1
+ metaSprite.fps = 6
+ end
end
+ --Check if left button has been pressed
if character.actionLeft == true and character.actionRight == false then
- if character.jump.higher > 0 and character.actionA == false then
+ if character.jump.higher > 0 and character.actionA == false and character.jump.isJumping == false and metaSprite ~= character.walk then
+ print("(update.motion) -> load walk meta sprite")
metaSprite = character.walk
+ metaSprite.currentFrame = 1
+ metaSprite.fps = 9
end
character.position.x = character.position.x - (character.velocity * dt)
character.scale.x = -1
end
+ --Check if right button has been pressed
if character.actionRight == true and character.actionLeft == false then
- if character.jump.higher > 0 and character.actionA == false then
+ if character.jump.higher > 0 and character.actionA == false and character.jump.isJumping == false and metaSprite ~= character.walk then
+ print("(update.motion) -> load walk meta sprite")
metaSprite = character.walk
+ metaSprite.currentFrame = 1
+ metaSprite.fps = 9
end
character.position.x = character.position.x + (character.velocity * dt)
character.scale.x = 1
end
+ --Check if up button has been pressed
if character.actionUp == true and character.actionDown == false then
- metaSprite = character.walk
+ if metaSprite ~= character.walk then
+ print("(update.motion) -> load walk meta sprite")
+ metaSprite = character.walk
+ metaSprite.currentFrame = 1
+ metaSprite.fps = 9
+ end
character.position.y = character.position.y - (character.velocity * dt)
character.jump.ground = character.position.y
end
+ --Check if down button has been pressed
if character.actionDown == true and character.actionUp == false then
- metaSprite = character.walk
+ if metaSprite ~= character.walk then
+ print("(update.motion) -> load walk meta sprite")
+ metaSprite = character.walk
+ metaSprite.currentFrame = 1
+ metaSprite.fps = 9
+ end
character.position.y = character.position.y + (character.velocity * dt)
character.jump.ground = character.position.y
end