summaryrefslogtreecommitdiff
path: root/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game')
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/jump.lua9
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/keypressed.lua29
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/keyreleased.lua33
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/motion.lua40
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/stand.lua4
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_down.lua6
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_left.lua6
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_right.lua6
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_up.lua6
9 files changed, 139 insertions, 0 deletions
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/jump.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/jump.lua
new file mode 100644
index 0000000..1891af5
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/jump.lua
@@ -0,0 +1,9 @@
+game.jump = function(metaSprites, character, dt)
+ if character.jump.limitButtonJump == false then
+ character.jump.higher = character.jump.higher - dt
+ character.jump.velocity = character.jump.velocity + character.jump.height * (dt / character.jump.higherMax)
+
+ -- game.animation(character.jump, dt)
+ -- metaSprites.quad = character.jump[character.jump.currentFrame]
+ end
+end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/keypressed.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/keypressed.lua
new file mode 100644
index 0000000..1035b05
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/keypressed.lua
@@ -0,0 +1,29 @@
+game.keypressed = function(character, key, scancode, isrepeat)
+ isrepeat = true
+
+ if scancode == button.quit then
+ love.event.quit()
+ end
+
+ if scancode == button.a then
+ character.actionA = true
+ character.actionDown = false
+ character.actionUp = false
+ end
+
+ if scancode == button.left then
+ character.actionLeft = true
+ end
+
+ if scancode == button.right then
+ character.actionRight = true
+ end
+
+ if scancode == button.up and character.jump.isJumping == false then
+ character.actionUp = true
+ end
+
+ if scancode == button.down and character.jump.isJumping == false then
+ character.actionDown = true
+ end
+end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/keyreleased.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/keyreleased.lua
new file mode 100644
index 0000000..fef6cf2
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/keyreleased.lua
@@ -0,0 +1,33 @@
+game.keyreleased = function(character, key, scancode)
+ if scancode == button.a then
+ character.actionA = false
+ end
+
+ if scancode == button.left then
+ character.actionLeft = false
+ end
+
+ if scancode == button.right then
+ character.actionRight = false
+ end
+
+ if scancode == button.up then
+ character.actionUp = false
+ end
+
+ if scancode == button.down then
+ character.actionDown = false
+ end
+
+ if scancode == button.b then
+ character.actionB = false
+ end
+
+ if scancode == button.a then
+ character.actionA = false
+
+ if character.jump.velocity ~= 0 then
+ character.jump.limitButtonJump = true
+ end
+ end
+end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/motion.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/motion.lua
new file mode 100644
index 0000000..7fb8fb0
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/motion.lua
@@ -0,0 +1,40 @@
+require 'scripts.game.animation'
+require 'scripts.game.jump'
+require 'scripts.game.stand'
+require 'scripts.game.walk_left'
+require 'scripts.game.walk_right'
+require 'scripts.game.walk_up'
+require 'scripts.game.walk_down'
+
+game.motion = function(metaSprites, character, dt)
+ game.animation(character.stand, dt)
+ metaSprites.quad = character.stand[character.stand.currentFrame]
+
+ if character.jump.higher > 0 and character.actionA == true then
+ game.jump(metaSprites, character, dt)
+ end
+
+ if character.actionLeft == true and character.actionRight == false then
+ game.walkLeft(metaSprites, character, dt)
+ end
+
+ if character.actionRight == true and character.actionLeft == false then
+ game.walkRight(metaSprites, character, dt)
+ end
+
+ if character.actionLeft == true and character.actionRight == true then
+ game.stand(metaSprites, character, dt)
+ end
+
+ if character.actionUp == true and character.actionDown == false then
+ game.walkUp(metaSprites, character, dt)
+ end
+
+ if character.actionDown == true and character.actionUp == false then
+ game.walkDown(metaSprites, character, dt)
+ end
+
+ if character.actionUp == true and character.actionDown == true then
+ game.stand(metaSprites, character, dt)
+ end
+end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/stand.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/stand.lua
new file mode 100644
index 0000000..3c31d68
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/stand.lua
@@ -0,0 +1,4 @@
+game.stand = function(metaSprites, character, dt)
+ game.animation(character.stand, dt)
+ metaSprites.quad = character.stand[character.stand.currentFrame]
+end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_down.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_down.lua
new file mode 100644
index 0000000..26d8103
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_down.lua
@@ -0,0 +1,6 @@
+game.walkDown = function(metaSprites, character, dt)
+ character.position.y = character.position.y + (character.velocity * dt)
+ character.jump.ground = character.position.y
+ game.animation(character.walk, dt)
+ metaSprites.quad = character.walk[character.walk.currentFrame]
+end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_left.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_left.lua
new file mode 100644
index 0000000..9588f9c
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_left.lua
@@ -0,0 +1,6 @@
+game.walkLeft = function(metaSprites, character, dt)
+ character.position.x = character.position.x - (character.velocity * dt)
+ game.animation(character.walk, dt)
+ metaSprites.quad = character.walk[character.walk.currentFrame]
+ character.scale.x = -1
+end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_right.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_right.lua
new file mode 100644
index 0000000..38ba327
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_right.lua
@@ -0,0 +1,6 @@
+game.walkRight = function(metaSprites, character, dt)
+ character.position.x = character.position.x + (character.velocity * dt)
+ game.animation(character.walk, dt)
+ metaSprites.quad = character.walk[character.walk.currentFrame]
+ character.scale.x = 1
+end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_up.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_up.lua
new file mode 100644
index 0000000..f85913c
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_up.lua
@@ -0,0 +1,6 @@
+game.walkUp = function(metaSprites, character, dt)
+ character.position.y = character.position.y - (character.velocity * dt)
+ character.jump.ground = character.position.y
+ game.animation(character.walk, dt)
+ metaSprites.quad = character.walk[character.walk.currentFrame]
+end