summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndré Fabian Silva Delgado <emulatorman@parabola.nu>2016-11-27 18:05:36 -0300
committercoadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu>2016-11-28 12:25:57 -0300
commit65bedc623f667e9b218b5dd5193433d5599fa1ff (patch)
tree1aa3b21fb29e9aa624b7e581651d1d2570510006 /src
parente5f5e6b27405bf70749468ba7d88f5fd8dd9c822 (diff)
Add walking up and walking down again, modularize motion limitation and fix jumping
Diffstat (limited to 'src')
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua2
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/limit.lua16
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion.lua25
3 files changed, 37 insertions, 6 deletions
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua
index c54f601..3afcce6 100644
--- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua
@@ -19,6 +19,7 @@ function love.load()
bolaAnimation = require 'scripts.bola.animation'
bolaMotion = require 'scripts.bola.motion'
bolaGravity = require 'scripts.bola.gravity'
+ bolaLimit = require 'scripts.bola.limit'
end
function love.keypressed(key)
@@ -33,6 +34,7 @@ function love.update(dt)
bolaAnimation.animation(dt)
bolaMotion.motion(dt)
bolaGravity.motion(dt)
+ bolaLimit.motion(dt)
end
function love.draw()
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/limit.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/limit.lua
new file mode 100644
index 0000000..5bc2f2f
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/limit.lua
@@ -0,0 +1,16 @@
+local limitModule = {}
+
+function limitModule.motion(dt)
+ if character.bola.position.x <= character.bola.origin.x then
+ character.bola.position.x = character.bola.origin.x
+ elseif character.bola.position.x >= windowProfile.mode.width - character.bola.origin.x then
+ character.bola.position.x = windowProfile.mode.width - character.bola.origin.x
+ end
+ if character.bola.position.y <= character.bola.origin.y then
+ character.bola.position.y = character.bola.origin.y
+ elseif character.bola.position.y >= windowProfile.mode.height - character.bola.origin.y then
+ character.bola.position.y = windowProfile.mode.height - character.bola.origin.y
+ end
+end
+
+return limitModule
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion.lua
index 89d3832..e0d5465 100644
--- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion.lua
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion.lua
@@ -9,6 +9,11 @@ function motionModule.motion(dt)
elseif love.keyboard.isScancodeDown(button.right) then
walkRight(dt)
end
+ if love.keyboard.isScancodeDown(button.up) then
+ walkUp(dt)
+ elseif love.keyboard.isScancodeDown(button.down) then
+ walkDown(dt)
+ end
end
function jump(dt)
@@ -19,19 +24,27 @@ function jump(dt)
end
function walkLeft(dt)
- if character.bola.position.x >= character.bola.origin.x then
- character.bola.position.x = character.bola.position.x - (character.bola.velocity * dt)
- end
+ character.bola.position.x = character.bola.position.x - (character.bola.velocity * dt)
quad.bola = character.bola.walk[math.floor(character.bola.walk.start)]
character.bola.scale.x = -1
end
function walkRight(dt)
- if character.bola.position.x <= windowProfile.mode.width - character.bola.origin.x then
- character.bola.position.x = character.bola.position.x + (character.bola.velocity * dt)
- end
+ character.bola.position.x = character.bola.position.x + (character.bola.velocity * dt)
quad.bola = character.bola.walk[math.floor(character.bola.walk.start)]
character.bola.scale.x = 1
end
+function walkUp(dt)
+ character.bola.position.y = character.bola.position.y - (character.bola.velocity * dt)
+ character.bola.jump.ground = character.bola.position.y
+ quad.bola = character.bola.walk[math.floor(character.bola.walk.start)]
+end
+
+function walkDown(dt)
+ character.bola.position.y = character.bola.position.y + (character.bola.velocity * dt)
+ character.bola.jump.ground = character.bola.position.y
+ quad.bola = character.bola.walk[math.floor(character.bola.walk.start)]
+end
+
return motionModule