From 928b839749e44351c75f1a9df664174c9ea84f35 Mon Sep 17 00:00:00 2001 From: Jorge Lopez Seijas Date: Tue, 13 Dec 2016 23:01:47 +0100 Subject: Clean code --- .../main.lua | 20 +++++++++++--------- 1 file 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 -- cgit v1.2.3