diff options
author | Jorge Lopez Seijas <jorginho@riseup.net> | 2016-12-15 20:37:56 +0100 |
---|---|---|
committer | Jorge Lopez Seijas <jorginho@riseup.net> | 2016-12-15 20:37:56 +0100 |
commit | c40d8c52960539cd14ba33e68810fbc6a16e7fd4 (patch) | |
tree | 3a9cd4adae74ad25e87345482cdd0971a59e72ab /src/gnu_and_bola_brawlers | |
parent | 9150595ca9f7380a2cd0f3333ac5d978e0cb63ef (diff) |
Keep the code KISS 2
Diffstat (limited to 'src/gnu_and_bola_brawlers')
-rw-r--r-- | src/gnu_and_bola_brawlers/draw/default.lua | 33 | ||||
-rw-r--r-- | src/gnu_and_bola_brawlers/draw/draw.lua | 33 | ||||
-rw-r--r-- | src/gnu_and_bola_brawlers/keypressed/default.lua (renamed from src/gnu_and_bola_brawlers/keypressed/trigger.lua) | 0 | ||||
-rw-r--r-- | src/gnu_and_bola_brawlers/keyreleased/default.lua (renamed from src/gnu_and_bola_brawlers/keyreleased/trigger.lua) | 0 | ||||
-rw-r--r-- | src/gnu_and_bola_brawlers/load/default.lua (renamed from src/gnu_and_bola_brawlers/load/initialize.lua) | 0 | ||||
-rw-r--r-- | src/gnu_and_bola_brawlers/main.lua | 34 |
6 files changed, 72 insertions, 28 deletions
diff --git a/src/gnu_and_bola_brawlers/draw/default.lua b/src/gnu_and_bola_brawlers/draw/default.lua new file mode 100644 index 0000000..a497604 --- /dev/null +++ b/src/gnu_and_bola_brawlers/draw/default.lua @@ -0,0 +1,33 @@ +local draw = {} + +--Get current time and update several parameters (time, fps print...) +draw.refresh = function() + local currentTime = love.timer.getTime() + if nextTime <= currentTime then + nextTime = currentTime + return + end + + love.timer.sleep(nextTime - currentTime) + + love.graphics.scale(windowProfile.scale.x, windowProfile.scale.y) + + love.graphics.print('FPS: ' .. love.timer.getFPS(), 0, 0) +end + +--Draw an object using base image and character data to position, scale, etc... +draw.object = function(images, character) + love.graphics.draw( + images[1], + images.quad, + character.position.x, + character.position.y, + character.orientation, + character.scale.x, + character.scale.y, + character.origin.x, + character.origin.y + ) +end + +return draw diff --git a/src/gnu_and_bola_brawlers/draw/draw.lua b/src/gnu_and_bola_brawlers/draw/draw.lua new file mode 100644 index 0000000..b2163ca --- /dev/null +++ b/src/gnu_and_bola_brawlers/draw/draw.lua @@ -0,0 +1,33 @@ +local draw = {} + +--Get current time and update several parameters (time, fps print...) +draw.refresh = function() + local currentTime = love.timer.getTime() + if nextTime <= currentTime then + nextTime = currentTime + return + end + + love.timer.sleep(nextTime - currentTime) + + love.graphics.scale(windowProfile.scale.x, windowProfile.scale.y) + + love.graphics.print('FPS: ' .. love.timer.getFPS(), 0, 0) +end + +--Draw an object using base image and character data in order to position, scale, etc... +draw.object = function(images, character) + love.graphics.draw( + images[1], + images.quad, + character.position.x, + character.position.y, + character.orientation, + character.scale.x, + character.scale.y, + character.origin.x, + character.origin.y + ) +end + +return draw diff --git a/src/gnu_and_bola_brawlers/keypressed/trigger.lua b/src/gnu_and_bola_brawlers/keypressed/default.lua index abba1cc..abba1cc 100644 --- a/src/gnu_and_bola_brawlers/keypressed/trigger.lua +++ b/src/gnu_and_bola_brawlers/keypressed/default.lua diff --git a/src/gnu_and_bola_brawlers/keyreleased/trigger.lua b/src/gnu_and_bola_brawlers/keyreleased/default.lua index 7295131..7295131 100644 --- a/src/gnu_and_bola_brawlers/keyreleased/trigger.lua +++ b/src/gnu_and_bola_brawlers/keyreleased/default.lua diff --git a/src/gnu_and_bola_brawlers/load/initialize.lua b/src/gnu_and_bola_brawlers/load/default.lua index bbf5c02..bbf5c02 100644 --- a/src/gnu_and_bola_brawlers/load/initialize.lua +++ b/src/gnu_and_bola_brawlers/load/default.lua diff --git a/src/gnu_and_bola_brawlers/main.lua b/src/gnu_and_bola_brawlers/main.lua index c0acbc3..af3952c 100644 --- a/src/gnu_and_bola_brawlers/main.lua +++ b/src/gnu_and_bola_brawlers/main.lua @@ -1,15 +1,15 @@ function love.load() - load = require 'load/initialize' + local load = require 'load/default' load.initialize() end function love.keypressed(key, scancode) - keypressed = require 'keypressed/trigger' + local keypressed = require 'keypressed/default' keypressed.trigger(character.bola, images.bola, metaSprite.bola, controller.player1, key, scancode) end function love.keyreleased(key, scancode) - keyreleased = require 'keyreleased/trigger' + local keyreleased = require 'keyreleased/default' keyreleased.trigger(character.bola, key, controller.player1, scancode) end @@ -120,29 +120,7 @@ function love.update(dt) end function love.draw() - local currentTime = love.timer.getTime() - if nextTime <= currentTime then - nextTime = currentTime - return - end - love.timer.sleep(nextTime - currentTime) - - love.graphics.scale(windowProfile.scale.x, windowProfile.scale.y) - - love.graphics.print('FPS: ' .. love.timer.getFPS(), 0, 0) - - draw = function(images, character) - love.graphics.draw( - images[1], - images.quad, - character.position.x, - character.position.y, - character.orientation, - character.scale.x, - character.scale.y, - character.origin.x, - character.origin.y - ) - end - draw(images.bola, character.bola) + local draw = require 'draw/default' + draw.refresh() + draw.object(images.bola, character.bola) end |