diff options
author | Aki <nthirtyone@gmail.com> | 2017-04-09 22:07:04 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-04-09 22:07:04 +0200 |
commit | 0dd01913fe0eefc7ba4bc0797877f40fdedf9315 (patch) | |
tree | 8d270eb07f589d2487b3ce66d4865e5a4718042a /main.lua | |
parent | 55b0cf1a22e4a7e41fe00aa693445d6c4bd0652d (diff) | |
parent | a03c1125f10fbbad253a0efc4727072fcbd55345 (diff) | |
download | roflnauts-0dd01913fe0eefc7ba4bc0797877f40fdedf9315.zip roflnauts-0dd01913fe0eefc7ba4bc0797877f40fdedf9315.tar.gz roflnauts-0dd01913fe0eefc7ba4bc0797877f40fdedf9315.tar.bz2 |
Merge branch 'com'
Diffstat (limited to 'main.lua')
-rw-r--r-- | main.lua | 79 |
1 files changed, 31 insertions, 48 deletions
@@ -1,10 +1,11 @@ --- "NOTNAUTS" --- WHOLE CODE HAS FLAG OF "need a cleanup" +--- Roflnauts 2 +-- TODO: Any lua source file in root directory that is not `main` (this file), `conf` should be moved to a proper directory. Its name should be changed to show what it contains. -- Pretend you didn't see this -- This is work for scene manager +-- TODO: Create SceneManager or similar class. Scene = nil -function changeScene(scene) +function changeScene (scene) if Scene ~= nil then Scene:delete() end @@ -12,58 +13,41 @@ function changeScene(scene) end -- Should be moved to scene/camera -function getScale() +-- TODO: move following functions to `Camera`. +function getScale () return math.max(1, math.floor(math.max(love.graphics.getWidth() / 320, love.graphics.getHeight() / 180))) end -function getRealScale() + +function getRealScale () return math.max(1, math.max(love.graphics.getWidth() / 320, love.graphics.getHeight() / 180)) end --- Should be moved to Sprite metaclass (non-existent yet) -function newImage(path) - local imagedata = love.image.newImageData(path) - local transparency = function(x, y, r, g, b, a) - if (r == 0 and g == 128 and b == 64) or - (r == 0 and g == 240 and b == 6) then - a = 0 - end - return r, g, b, a - end - imagedata:mapPixel(transparency) - local image = love.graphics.newImage(imagedata) - return image -end -- Require -require "world" -require "camera" -require "menu" -require "controller" -require "music" -require "settings" +require "iconsList" +require "not.World" +require "not.Camera" +require "not.Menu" +require "not.Controller" +require "not.Settings" -- Temporary debug debug = false -- LÖVE2D callbacks -function love.load() - -- Graphics +function love.load () love.graphics.setBackgroundColor(90, 90, 90) love.graphics.setDefaultFilter("nearest", "nearest") - -- Font + -- TODO: Move fonts somewhere else out of global scope. Font = love.graphics.newImageFont("assets/font-normal.png", " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.,:;-_/\\!@#$%^&*?=+~`|'\"()[]{}<>", -1) Bold = love.graphics.newImageFont("assets/font-big.png", " 0123456789AEFILNORSTUW", -2) Font:setLineHeight(9/16) - love.graphics.setFont(Font) - -- Modules + love.graphics.setFont(Font) Controller.load() Settings.load() - -- Scene Scene = Menu:new() end -function love.update(dt) - Scene:update(dt) -end -function love.draw() + +function love.draw () Scene:draw() if debug then local scale = getScale() @@ -74,21 +58,20 @@ function love.draw() love.graphics.print("Current FPS: "..tostring(love.timer.getFPS()), 10, 10+9*scale, 0, scale, scale) end end -function love.quit() - Settings.save() -end + +function love.update (dt) Scene:update(dt) end +function love.quit () Settings.save() end + -- Pass input to Controller -function love.gamepadaxis(joystick, axis, value) Controller.gamepadaxis(joystick, axis, value) end -function love.gamepadpressed(joystick, key) Controller.gamepadpressed(joystick, key) end -function love.gamepadreleased(joystick, key) Controller.gamepadreleased(joystick, key) end -function love.keypressed(key) Controller.keypressed(key) end -function love.keyreleased(key) Controller.keyreleased(key) end +function love.gamepadaxis (joystick, axis, value) Controller.gamepadaxis(joystick, axis, value) end +function love.gamepadpressed (joystick, key) Controller.gamepadpressed(joystick, key) end +function love.gamepadreleased (joystick, key) Controller.gamepadreleased(joystick, key) end +function love.keypressed (key) Controller.keypressed(key) end +function love.keyreleased (key) Controller.keyreleased(key) end -- Controller callbacks -function Controller.controlpressed(set, action, key) - -- pass to current Scene +function Controller.controlpressed (set, action, key) Scene:controlpressed(set, action, key) - -- globals if key == "escape" then love.event.quit() end @@ -96,7 +79,7 @@ function Controller.controlpressed(set, action, key) debug = not debug end end -function Controller.controlreleased(set, action, key) - -- pass to current Scene + +function Controller.controlreleased (set, action, key) Scene:controlreleased(set, action, key) end
\ No newline at end of file |