summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Fabian Silva Delgado <emulatorman@parabola.nu>2016-11-26 16:33:47 -0300
committercoadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu>2016-11-28 12:25:57 -0300
commitb6e0a385398f2b6f4a5595415e725dc9f0f11c85 (patch)
treeaef9b96d3390de5d2af99ec565b9aadde7d8c497
parent8dc408a1360c2df6629f40aa5a8683a59c7c984c (diff)
Add platformer-style jumping
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/jump.lua12
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/gravity.lua1
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/motion.lua7
3 files changed, 11 insertions, 9 deletions
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/jump.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/jump.lua
index e736323..42c1868 100644
--- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/jump.lua
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/jump.lua
@@ -1,8 +1,10 @@
return {
love.graphics.newQuad(metaSprites.bola.x * 5, metaSprites.bola.y * 2, metaSprites.bola.x, metaSprites.bola.y, metaSprites.bola.image:getDimensions()),
- start = 1,
- fps = 9,
- height = -300,
- velocity = 0,
- ground = windowProfile.mode.height / 2,
+ start = 1,
+ fps = 9,
+ height = -250,
+ velocity = 0,
+ ground = windowProfile.mode.height / 2,
+ higher = 0.15,
+ higherMax = 0.15,
}
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/gravity.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/gravity.lua
index 4cc76c4..98ba985 100644
--- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/gravity.lua
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/gravity.lua
@@ -13,6 +13,7 @@ function gravity(dt)
if character.bola.position.y > character.bola.jump.ground then
character.bola.jump.velocity = 0
character.bola.position.y = character.bola.jump.ground
+ character.bola.jump.higher = character.bola.jump.higherMax
end
end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/motion.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/motion.lua
index 2da8f69..89d3832 100644
--- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/motion.lua
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/motion.lua
@@ -1,7 +1,7 @@
local motionModule = {}
function motionModule.motion(dt)
- if love.keyboard.isScancodeDown(button.a) then
+ if character.bola.jump.higher > 0 and love.keyboard.isScancodeDown(button.a) then
jump(dt)
end
if love.keyboard.isScancodeDown(button.left) then
@@ -12,9 +12,8 @@ function motionModule.motion(dt)
end
function jump(dt)
- if character.bola.jump.velocity == 0 then
- character.bola.jump.velocity = character.bola.jump.height
- end
+ character.bola.jump.higher = character.bola.jump.higher - dt
+ character.bola.jump.velocity = character.bola.jump.velocity + character.bola.jump.height * (dt / character.bola.jump.higherMax)
-- quad.bola = character.bola.jump[math.floor(character.bola.jump.start)]
end