diff options
author | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-11-25 12:49:58 -0300 |
---|---|---|
committer | coadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu> | 2016-11-26 12:16:00 -0300 |
commit | db1a6b18423356a9c8dd92ccd83dab42350ab876 (patch) | |
tree | 8542cb667d76b606a82e27a66f4c25e736a5a95e /src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts | |
parent | 4c0a1a574e4afe9754bbe7a39669db680af8ffab (diff) |
Add initial jump and rename speed to velocity
Diffstat (limited to 'src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts')
5 files changed, 49 insertions, 12 deletions
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/animation.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/animation.lua index eacfe42..fcab58a 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/animation.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/animation.lua @@ -3,6 +3,7 @@ local animationModule = {} function animationModule.animation(dt) character.bola.stand.start = character.bola.stand.start + (dt * character.bola.stand.fps) character.bola.walk.start = character.bola.walk.start + (dt * character.bola.walk.fps) + character.bola.jump.start = character.bola.jump.start + (dt * character.bola.jump.fps) frames = { bola = require 'scripts.bola.frames' @@ -38,6 +39,7 @@ function animationModule.animation(dt) character.bola.stand.start = game.animation(character.bola.stand.start, frames.bola.stand, -1, false) character.bola.walk.start = game.animation(character.bola.walk.start, frames.bola.walk, -1, false) + character.bola.jump.start = game.animation(character.bola.jump.start, frames.bola.jump, -1, false) end return animationModule diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/default.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/default.lua index 6ab0b13..aa04fac 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/default.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/default.lua @@ -1,11 +1,13 @@ return { orientation = 0, acceleration = 0, - speed = 125, + velocity = 125, + gravity = -500, position = require 'scripts.bola.position', scale = require 'scripts.bola.scale', origin = require 'scripts.bola.origin', stand = require 'scripts.bola.stand', walk = require 'scripts.bola.walk', run = require 'scripts.bola.run', + jump = require 'scripts.bola.jump', } diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/frames.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/frames.lua index 053b8e6..89fec44 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/frames.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/frames.lua @@ -1,4 +1,5 @@ return { stand = # character.bola.stand, walk = # character.bola.walk, + jump = # character.bola.jump, } 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 new file mode 100644 index 0000000..3dab4dc --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/jump.lua @@ -0,0 +1,17 @@ +return { + love.graphics.newQuad(metaSprites.bola.x * 5, metaSprites.bola.y * 1, metaSprites.bola.x, metaSprites.bola.y, metaSprites.bola.image:getDimensions()), + love.graphics.newQuad(metaSprites.bola.x * 6, metaSprites.bola.y * 1, metaSprites.bola.x, metaSprites.bola.y, metaSprites.bola.image:getDimensions()), + love.graphics.newQuad(metaSprites.bola.x * 7, metaSprites.bola.y * 1, metaSprites.bola.x, metaSprites.bola.y, metaSprites.bola.image:getDimensions()), + love.graphics.newQuad(metaSprites.bola.x * 8, metaSprites.bola.y * 1, metaSprites.bola.x, metaSprites.bola.y, metaSprites.bola.image:getDimensions()), + love.graphics.newQuad(metaSprites.bola.x * 9, metaSprites.bola.y * 1, metaSprites.bola.x, metaSprites.bola.y, metaSprites.bola.image:getDimensions()), + love.graphics.newQuad(metaSprites.bola.x * 5, metaSprites.bola.y * 2, metaSprites.bola.x, metaSprites.bola.y, metaSprites.bola.image:getDimensions()), + love.graphics.newQuad(metaSprites.bola.x * 8, metaSprites.bola.y * 2, metaSprites.bola.x, metaSprites.bola.y, metaSprites.bola.image:getDimensions()), + love.graphics.newQuad(metaSprites.bola.x * 9, metaSprites.bola.y * 2, metaSprites.bola.x, metaSprites.bola.y, metaSprites.bola.image:getDimensions()), + love.graphics.newQuad(metaSprites.bola.x * 5, metaSprites.bola.y * 3, metaSprites.bola.x, metaSprites.bola.y, metaSprites.bola.image:getDimensions()), + love.graphics.newQuad(metaSprites.bola.x * 6, metaSprites.bola.y * 3, metaSprites.bola.x, metaSprites.bola.y, metaSprites.bola.image:getDimensions()), + start = 1, + fps = 9, + height = -300, + velocity = 0, + ground = windowProfile.mode.height / 2, +} 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 fcb617c..903809e 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 @@ -21,9 +21,7 @@ function motionModule.motion(dt) if menu == true then accept(dt) elseif menu == false then - if ground == true then - jump(dt) - end + jump(dt) end elseif love.keyboard.isDown(button.b) then if menu == true then @@ -94,6 +92,23 @@ function pause(dt) end function jump(dt) + if character.bola.jump.velocity == 0 then + character.bola.jump.velocity = character.bola.jump.height + end + + if character.bola.jump.velocity ~= 0 then + character.bola.position.y = character.bola.position.y + (character.bola.jump.velocity * dt) + character.bola.jump.velocity = character.bola.jump.velocity - (character.bola.gravity * dt) + end + + if character.bola.position.y > character.bola.jump.ground then + character.bola.jump.velocity = 0 + character.bola.position.y = character.bola.jump.ground + end + + quad = { + bola = character.bola.jump[math.floor(character.bola.jump.start)] + } end function hitGround(dt) @@ -118,9 +133,9 @@ function walkLeft(dt) character.bola.acceleration = character.bola.acceleration + dt if character.bola.position.x >= character.bola.origin.x then if character.bola.acceleration < 3 then - character.bola.position.x = character.bola.position.x - (character.bola.speed * dt) - character.bola.acceleration + character.bola.position.x = character.bola.position.x - (character.bola.velocity * dt) - character.bola.acceleration else - character.bola.position.x = character.bola.position.x - (character.bola.speed * dt) - 3 + character.bola.position.x = character.bola.position.x - (character.bola.velocity * dt) - 3 end end quad = { @@ -133,9 +148,9 @@ function walkRight(dt) character.bola.acceleration = character.bola.acceleration + dt if character.bola.position.x <= windowProfile.mode.width - character.bola.origin.x then if character.bola.acceleration < 3 then - character.bola.position.x = character.bola.position.x + (character.bola.speed * dt) + character.bola.acceleration + character.bola.position.x = character.bola.position.x + (character.bola.velocity * dt) + character.bola.acceleration else - character.bola.position.x = character.bola.position.x + (character.bola.speed * dt) + 3 + character.bola.position.x = character.bola.position.x + (character.bola.velocity * dt) + 3 end end quad = { @@ -148,9 +163,9 @@ function walkUp(dt) character.bola.acceleration = character.bola.acceleration + dt if character.bola.position.y >= character.bola.origin.y then if character.bola.acceleration < 3 then - character.bola.position.y = character.bola.position.y - (character.bola.speed * dt) - character.bola.acceleration + character.bola.position.y = character.bola.position.y - (character.bola.velocity * dt) - character.bola.acceleration else - character.bola.position.y = character.bola.position.y - (character.bola.speed * dt) - 3 + character.bola.position.y = character.bola.position.y - (character.bola.velocity * dt) - 3 end end quad = { @@ -162,9 +177,9 @@ function walkDown(dt) character.bola.acceleration = character.bola.acceleration + dt if character.bola.position.y <= windowProfile.mode.height - character.bola.origin.y then if character.bola.acceleration < 3 then - character.bola.position.y = character.bola.position.y + (character.bola.speed * dt) + character.bola.acceleration + character.bola.position.y = character.bola.position.y + (character.bola.velocity * dt) + character.bola.acceleration else - character.bola.position.y = character.bola.position.y + (character.bola.speed * dt) + 3 + character.bola.position.y = character.bola.position.y + (character.bola.velocity * dt) + 3 end end quad = { |