diff options
author | Jorge <jorginho@riseup.net> | 2016-11-21 22:19:09 +0100 |
---|---|---|
committer | Jorge <jorginho@riseup.net> | 2016-11-21 22:19:09 +0100 |
commit | c7fd30e293dbb8fe3049716951c2e369afcb97e5 (patch) | |
tree | a2b834ae6c9cda35e2c30c7249af93da3ecf682c | |
parent | ed9476d0af54bfd679eeb13fe8bd46afbc85bbf6 (diff) |
Collisions with the x axis window limit
-rw-r--r-- | test0/main.lua | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/test0/main.lua b/test0/main.lua index 206662f..5919324 100644 --- a/test0/main.lua +++ b/test0/main.lua @@ -174,23 +174,27 @@ function love.update(dt) } if love.keyboard.isDown(button.left) then - character.bola.acceleration = character.bola.acceleration + dt - if character.bola.acceleration < 3 then - character.bola.position.x = character.bola.position.x - (character.bola.speed * dt) - character.bola.acceleration - else - character.bola.position.x = character.bola.position.x - (character.bola.speed * dt) - 3 + if character.bola.position.x >= character.bola.origin.x then + character.bola.acceleration = character.bola.acceleration + dt + if character.bola.acceleration < 3 then + character.bola.position.x = character.bola.position.x - (character.bola.speed * dt) - character.bola.acceleration + else + character.bola.position.x = character.bola.position.x - (character.bola.speed * dt) - 3 + end + quad = character.bola.spriteWalk[animation.bola.spriteWalk] + character.bola.scale.x = -1 end - quad = character.bola.spriteWalk[animation.bola.spriteWalk] - character.bola.scale.x = -1 elseif love.keyboard.isDown(button.right) then - character.bola.acceleration = character.bola.acceleration + dt - if character.bola.acceleration < 3 then - character.bola.position.x = character.bola.position.x + (character.bola.speed * dt) + character.bola.acceleration - else - character.bola.position.x = character.bola.position.x + (character.bola.speed * dt) + 3 + if character.bola.position.x <= windowProfile.mode.width - character.bola.origin.x then + character.bola.acceleration = character.bola.acceleration + dt + if character.bola.acceleration < 3 then + character.bola.position.x = character.bola.position.x + (character.bola.speed * dt) + character.bola.acceleration + else + character.bola.position.x = character.bola.position.x + (character.bola.speed * dt) + 3 + end + quad = character.bola.spriteWalk[animation.bola.spriteWalk] + character.bola.scale.x = 1 end - quad = character.bola.spriteWalk[animation.bola.spriteWalk] - character.bola.scale.x = 1 else character.bola.acceleration = 0 quad = character.bola.spriteStand[animation.bola.spriteStand] |