summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJorge Lopez Seijas <jorginho@riseup.net>2016-12-13 23:01:47 +0100
committerJorge Lopez Seijas <jorginho@riseup.net>2016-12-13 23:01:47 +0100
commit928b839749e44351c75f1a9df664174c9ea84f35 (patch)
treecee41ac4b7d19dd92c7f5ea85f5d7ce3c2f335af /src
parent0ebd8cbf7f022d769274af2dab6bab4a76df8c13 (diff)
Clean code
Diffstat (limited to 'src')
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua20
1 files changed, 11 insertions, 9 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 fff4f5d..531a5bc 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
@@ -165,7 +165,7 @@ function love.update(dt)
end
animation(sprite.bola, metaSprites.bola, dt)
- motion = function(character, metaSprites, dt)
+ motion = function(character, metaSprites, sprite, dt)
if character.jump.higher > 0 and character.actionA == true then
if character.jump.limitButtonJump == false then
character.jump.higher = character.jump.higher - dt
@@ -174,38 +174,40 @@ function love.update(dt)
end
if character.actionLeft == true and character.actionRight == false then
- sprite.bola = require 'walk'
+ sprite = require 'walk'
character.position.x = character.position.x - (character.velocity * dt)
character.scale.x = -1
end
if character.actionRight == true and character.actionLeft == false then
- sprite.bola = require 'walk'
+ sprite = require 'walk'
character.position.x = character.position.x + (character.velocity * dt)
character.scale.x = 1
end
if character.actionUp == true and character.actionDown == false then
- sprite.bola = require 'walk'
+ sprite = require 'walk'
character.position.y = character.position.y - (character.velocity * dt)
character.jump.ground = character.position.y
end
if character.actionDown == true and character.actionUp == false then
- sprite.bola = require 'walk'
+ sprite = require 'walk'
character.position.y = character.position.y + (character.velocity * dt)
character.jump.ground = character.position.y
end
if character.actionUp == true and character.actionDown == true then
- sprite.bola = require 'stand'
+ sprite = require 'stand'
elseif character.actionLeft == true and character.actionRight == true then
- sprite.bola = require 'stand'
+ sprite = require 'stand'
elseif character.actionLeft == false and character.actionRight == false and character.actionUp == false and character.actionDown == false then
- sprite.bola = require 'stand'
+ sprite = require 'stand'
end
+
+ return sprite
end
- motion(character.bola, metaSprites.bola, dt)
+ sprite.bola = motion(character.bola, metaSprites.bola, sprite.bola, dt)
gravity = function(character, dt)
if character.jump.velocity ~= 0 then