diff options
Diffstat (limited to 'src/gnu_and_bola_brawlers/main.lua')
-rw-r--r-- | src/gnu_and_bola_brawlers/main.lua | 114 |
1 files changed, 21 insertions, 93 deletions
diff --git a/src/gnu_and_bola_brawlers/main.lua b/src/gnu_and_bola_brawlers/main.lua index b9aed5e..78a4e98 100644 --- a/src/gnu_and_bola_brawlers/main.lua +++ b/src/gnu_and_bola_brawlers/main.lua @@ -1,139 +1,67 @@ function love.load() - fps = 30 - upTime = love.timer.getTime() - nextTime = upTime - - windowProfile = { - mode = { - width = 256, - height = 240, - }, - scale = { - x = 2, - y = 2, - }, - title = "GNU & Bola Brawlers", - } - - love.graphics.setBackgroundColor(0, 232, 216) - love.graphics.setDefaultFilter('nearest', 'nearest') - - love.window.setMode(windowProfile.mode.width * windowProfile.scale.x, windowProfile.mode.height * windowProfile.scale.y) - love.window.setTitle(windowProfile.title) - - button = { - left = 'a', - right = 'd', - up = 'w', - down = 's', - a = 'j', - b = 'k', - select = 'g', - start = 'h', - quit = 'escape', - } - - metaSprites = { - bola = { - image = love.graphics.newImage('multimedia/ppu_rp2c0x/meta_sprites/bola/default_sheet_color0_alpha.png'), - x = 24, - y = 32, - } - } - - character = { - bola = { - orientation = 0, - acceleration = 0, - velocity = 125, - gravity = -500, - position = { - x = windowProfile.mode.width / 2, - y = windowProfile.mode.height / 2, - }, - scale = { - x = 1, - y = 1, - }, - origin = { - x = metaSprites.bola.x / 2, - y = metaSprites.bola.y / 2, - }, - stand = require 'stand', - walk = require 'walk', - jump = require 'jump', - actionLeft = false, - actionRight = false, - actionUp = false, - actionDown = false, - actionA = false, - actionB = false, - }, - } - sprite = { - bola = require 'stand', - } + load = require 'load/initialize' + load.initialize() end function love.keypressed(key, scancode) - keypressed = function(character, metaSprites, sprite, key, scancode) - if scancode == button.quit then + keypressed = function(character, metaSprites, sprite, controller, key, scancode) + if scancode == playerController.quit then love.event.quit() end - if scancode == button.a then + if scancode == controller.a then character.actionA = true character.actionDown = false character.actionUp = false sprite = require 'jump' end - if scancode == button.left then + if scancode == controller.left then character.actionLeft = true end - if scancode == button.right then + if scancode == controller.right then character.actionRight = true end - if scancode == button.up and character.jump.isJumping == false then + if scancode == controller.up and character.jump.isJumping == false then character.actionUp = true end - if scancode == button.down and character.jump.isJumping == false then + if scancode == controller.down and character.jump.isJumping == false then character.actionDown = true end end - keypressed(character.bola, metaSprites.bola, sprite.bola, key, scancode) + keypressed(character.bola, metaSprites.bola, sprite.bola, playerController.player1, key, scancode) end function love.keyreleased(key, scancode) - keyreleased = function(character, key, scancode) - if scancode == button.a then + keyreleased = function(character, key, controller, scancode) + if scancode == controller.a then character.actionA = false end - if scancode == button.left then + if scancode == controller.left then character.actionLeft = false end - if scancode == button.right then + if scancode == controller.right then character.actionRight = false end - if scancode == button.up then + if scancode == controller.up then character.actionUp = false end - if scancode == button.down then + if scancode == controller.down then character.actionDown = false end - if scancode == button.b then + if scancode == controller.b then character.actionB = false end - if scancode == button.a then + if scancode == controller.a then character.actionA = false if character.jump.velocity ~= 0 then @@ -141,7 +69,7 @@ function love.keyreleased(key, scancode) end end end - keyreleased(character.bola, key, scancode) + keyreleased(character.bola, key, playerController.player1, scancode) end function love.update(dt) @@ -225,9 +153,9 @@ function love.update(dt) character.jump.isJumping = false character.actionA = false - if love.keyboard.isScancodeDown(button.up) then + if love.keyboard.isScancodeDown(playerController.player1.up) then character.actionUp = true - elseif love.keyboard.isScancodeDown(button.down) then + elseif love.keyboard.isScancodeDown(playerController.player1.down) then character.actionDown = true end end |