summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Fabian Silva Delgado <emulatorman@parabola.nu>2016-12-04 11:43:03 -0300
committerAndré Fabian Silva Delgado <emulatorman@parabola.nu>2016-12-04 11:43:03 -0300
commitbe92c47794d735812daca917fb1ff6b0d621f948 (patch)
tree53c3d1bfbc4e35341abbf19f92dbf45c763d2012
parente474d4bf0565a46e59cad616f2cf1be8b1536ed2 (diff)
Keep the code more KISS - part 5
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/update.lua8
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion.lua75
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/default.lua32
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/jump.lua9
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/stand.lua4
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_down.lua6
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_left.lua6
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_right.lua7
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_up.lua6
9 files changed, 77 insertions, 76 deletions
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/update.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/update.lua
index 4123173..bb5cc39 100644
--- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/update.lua
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/update.lua
@@ -1,5 +1,11 @@
require 'scripts.update.default'
require 'scripts.update.fps'
-require 'scripts.update.motion'
+require 'scripts.update.motion.default'
+require 'scripts.update.motion.jump'
+require 'scripts.update.motion.stand'
+require 'scripts.update.motion.walk_left'
+require 'scripts.update.motion.walk_right'
+require 'scripts.update.motion.walk_up'
+require 'scripts.update.motion.walk_down'
require 'scripts.update.gravity'
require 'scripts.update.limit'
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion.lua
deleted file mode 100644
index 34bd73d..0000000
--- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion.lua
+++ /dev/null
@@ -1,75 +0,0 @@
-update.motion = function(dt)
- game.animation(character.bola.stand, dt)
- metaSprites.bola.quad = character.bola.stand[character.bola.stand.currentFrame]
-
- if character.bola.jump.higher > 0 and character.bola.actionA == true then
- jump(dt)
- end
-
- if character.bola.actionLeft == true and character.bola.actionRight == false then
- walkLeft(dt)
- end
-
- if character.bola.actionRight == true and character.bola.actionLeft == false then
- walkRight(dt)
- end
-
- if character.bola.actionLeft == true and character.bola.actionRight == true then
- stand(dt)
- end
-
- if character.bola.actionUp == true and character.bola.actionDown == false then
- walkUp(dt)
- end
-
- if character.bola.actionDown == true and character.bola.actionUp == false then
- walkDown(dt)
- end
-
- if character.bola.actionUp == true and character.bola.actionDown == true then
- stand(dt)
- end
-end
-
-function jump(dt)
- if character.bola.jump.limitButtonJump == false then
- character.bola.jump.higher = character.bola.jump.higher - dt
- character.bola.jump.velocity = character.bola.jump.velocity + character.bola.jump.height * (dt / character.bola.jump.higherMax)
-
- -- game.animation(character.bola.jump, dt)
- -- metaSprites.bola.quad = character.bola.jump[character.bola.jump.currentFrame]
- end
-end
-
-function stand(dt)
- game.animation(character.bola.stand, dt)
- metaSprites.bola.quad = character.bola.stand[character.bola.stand.currentFrame]
-end
-
-function walkLeft(dt)
- character.bola.position.x = character.bola.position.x - (character.bola.velocity * dt)
- game.animation(character.bola.walk, dt)
- metaSprites.bola.quad = character.bola.walk[character.bola.walk.currentFrame]
- character.bola.scale.x = -1
-end
-
-function walkRight(dt)
- character.bola.position.x = character.bola.position.x + (character.bola.velocity * dt)
- game.animation(character.bola.walk, dt)
- metaSprites.bola.quad = character.bola.walk[character.bola.walk.currentFrame]
- 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
- game.animation(character.bola.walk, dt)
- metaSprites.bola.quad = character.bola.walk[character.bola.walk.currentFrame]
-end
-
-function walkDown(dt)
- character.bola.position.y = character.bola.position.y + (character.bola.velocity * dt)
- character.bola.jump.ground = character.bola.position.y
- game.animation(character.bola.walk, dt)
- metaSprites.bola.quad = character.bola.walk[character.bola.walk.currentFrame]
-end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/default.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/default.lua
new file mode 100644
index 0000000..d260891
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/default.lua
@@ -0,0 +1,32 @@
+update.motion = function(dt)
+ game.animation(character.bola.stand, dt)
+ metaSprites.bola.quad = character.bola.stand[character.bola.stand.currentFrame]
+
+ if character.bola.jump.higher > 0 and character.bola.actionA == true then
+ jump(dt)
+ end
+
+ if character.bola.actionLeft == true and character.bola.actionRight == false then
+ walkLeft(dt)
+ end
+
+ if character.bola.actionRight == true and character.bola.actionLeft == false then
+ walkRight(dt)
+ end
+
+ if character.bola.actionLeft == true and character.bola.actionRight == true then
+ stand(dt)
+ end
+
+ if character.bola.actionUp == true and character.bola.actionDown == false then
+ walkUp(dt)
+ end
+
+ if character.bola.actionDown == true and character.bola.actionUp == false then
+ walkDown(dt)
+ end
+
+ if character.bola.actionUp == true and character.bola.actionDown == true then
+ stand(dt)
+ end
+end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/jump.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/jump.lua
new file mode 100644
index 0000000..1005a53
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/jump.lua
@@ -0,0 +1,9 @@
+function jump(dt)
+ if character.bola.jump.limitButtonJump == false then
+ character.bola.jump.higher = character.bola.jump.higher - dt
+ character.bola.jump.velocity = character.bola.jump.velocity + character.bola.jump.height * (dt / character.bola.jump.higherMax)
+
+ -- game.animation(character.bola.jump, dt)
+ -- metaSprites.bola.quad = character.bola.jump[character.bola.jump.currentFrame]
+ end
+end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/stand.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/stand.lua
new file mode 100644
index 0000000..04010ce
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/stand.lua
@@ -0,0 +1,4 @@
+function stand(dt)
+ game.animation(character.bola.stand, dt)
+ metaSprites.bola.quad = character.bola.stand[character.bola.stand.currentFrame]
+end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_down.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_down.lua
new file mode 100644
index 0000000..ba393c7
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_down.lua
@@ -0,0 +1,6 @@
+function walkDown(dt)
+ character.bola.position.y = character.bola.position.y + (character.bola.velocity * dt)
+ character.bola.jump.ground = character.bola.position.y
+ game.animation(character.bola.walk, dt)
+ metaSprites.bola.quad = character.bola.walk[character.bola.walk.currentFrame]
+end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_left.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_left.lua
new file mode 100644
index 0000000..17f31f3
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_left.lua
@@ -0,0 +1,6 @@
+function walkLeft(dt)
+ character.bola.position.x = character.bola.position.x - (character.bola.velocity * dt)
+ game.animation(character.bola.walk, dt)
+ metaSprites.bola.quad = character.bola.walk[character.bola.walk.currentFrame]
+ character.bola.scale.x = -1
+end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_right.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_right.lua
new file mode 100644
index 0000000..712c680
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_right.lua
@@ -0,0 +1,7 @@
+function walkRight(dt)
+ character.bola.position.x = character.bola.position.x + (character.bola.velocity * dt)
+ game.animation(character.bola.walk, dt)
+ metaSprites.bola.quad = character.bola.walk[character.bola.walk.currentFrame]
+ character.bola.scale.x = 1
+end
+
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_up.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_up.lua
new file mode 100644
index 0000000..a8bd29b
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_up.lua
@@ -0,0 +1,6 @@
+function walkUp(dt)
+ character.bola.position.y = character.bola.position.y - (character.bola.velocity * dt)
+ character.bola.jump.ground = character.bola.position.y
+ game.animation(character.bola.walk, dt)
+ metaSprites.bola.quad = character.bola.walk[character.bola.walk.currentFrame]
+end