id_
This commit is contained in:
parent
b19f58726c
commit
01d272981e
133 changed files with 822 additions and 66 deletions
64
main.lua
64
main.lua
|
|
@ -1,9 +1,9 @@
|
|||
love.graphics.setDefaultFilter("linear", "nearest")
|
||||
|
||||
local utf8 = require("utf8")
|
||||
class = require "libs/middleclass"
|
||||
Timer = require "libs/hump/timer"
|
||||
sfxr = require "libs/sfxrlua/sfxr"
|
||||
json = require "libs/json4lua/json/json"
|
||||
require "_debug_helpers"
|
||||
require "_helpers"
|
||||
require "input"
|
||||
|
|
@ -11,37 +11,42 @@ require "color"
|
|||
require "room"
|
||||
require "shaders"
|
||||
require "sprite_manager"
|
||||
require "level_editor/editor"
|
||||
|
||||
function love.load()
|
||||
_initDefaults()
|
||||
_initGridVars()
|
||||
_initSounds()
|
||||
_initGlobalColors()
|
||||
_initLevelEditor()
|
||||
processSprites()
|
||||
|
||||
gameCanvas = love.graphics.newCanvas()
|
||||
sideBarCanvas = love.graphics.newCanvas(sideBarBox.w, sideBarBox.h)
|
||||
finalCanvas = love.graphics.newCanvas()
|
||||
|
||||
|
||||
inputTimer = Timer.new()
|
||||
|
||||
currentRoom = Room:new{
|
||||
player = {
|
||||
x = 5, y = 5, activeColors = {"red", "green", "blue"}
|
||||
}
|
||||
name = "test"
|
||||
}
|
||||
|
||||
response = ""
|
||||
end
|
||||
|
||||
function love.update(dt)
|
||||
Input:handler(dt)
|
||||
currentRoom:update(dt)
|
||||
|
||||
if love.keyboard.isDown("w") then worldSha = worldSha + 1 end
|
||||
if love.keyboard.isDown("s") then worldSha = worldSha - 1 end
|
||||
-- if love.keyboard.isDown("w") then worldSha = worldSha + 1 end
|
||||
-- if love.keyboard.isDown("s") then worldSha = worldSha - 1 end
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
gameCanvas:clear()
|
||||
finalCanvas:clear()
|
||||
sideBarCanvas:clear()
|
||||
|
||||
love.graphics.setCanvas(gameCanvas)
|
||||
love.graphics.setBlendMode("screen")
|
||||
|
|
@ -67,9 +72,14 @@ function love.draw()
|
|||
love.graphics.draw(gameCanvas, 0, 0)
|
||||
love.graphics.setCanvas()
|
||||
|
||||
love.graphics.setCanvas(sideBarCanvas)
|
||||
editorDraw()
|
||||
love.graphics.setCanvas()
|
||||
|
||||
love.graphics.setBlendMode("alpha")
|
||||
love.graphics.setColor(255, 255, 255, 255)
|
||||
love.graphics.draw(finalCanvas, 0, 0)
|
||||
love.graphics.draw(sideBarCanvas, sideBarBox.x, sideBarBox.y)
|
||||
love.graphics.print("Current FPS: "..tostring(love.timer.getFPS( )), 10, 10)
|
||||
|
||||
end
|
||||
|
|
@ -81,12 +91,39 @@ function love.keypressed(key)
|
|||
local c = Input.playerColor(key)
|
||||
currentRoom:switchPlayerColor(c)
|
||||
end
|
||||
if key == "w" then
|
||||
worldSha = worldSha + 1
|
||||
|
||||
-- if key == "w" then
|
||||
-- worldSha = worldSha + 1
|
||||
-- end
|
||||
-- if key == "s" then
|
||||
-- worldSha = worldSha - 1
|
||||
-- end
|
||||
|
||||
if key == "return" then
|
||||
response = ""
|
||||
editorCompleteResponse()
|
||||
elseif key == "backspace" then
|
||||
local byteoffset = utf8.offset(response, -1)
|
||||
|
||||
if byteoffset then
|
||||
-- remove the last UTF-8 character.
|
||||
-- string.sub operates on bytes rather than UTF-8 characters, so we couldn't do string.sub(response, 1, -2).
|
||||
response = string.sub(response, 1, byteoffset - 1)
|
||||
editorTextHandler(response)
|
||||
end
|
||||
end
|
||||
if key == "s" then
|
||||
worldSha = worldSha - 1
|
||||
end
|
||||
|
||||
function love.mousepressed(x, y, button)
|
||||
if button == "r" then
|
||||
currentRoom:attemptDelete(x, y)
|
||||
end
|
||||
editorMouseHandler(x, y, button)
|
||||
end
|
||||
|
||||
function love.textinput(t)
|
||||
response = response .. t
|
||||
editorTextHandler(response)
|
||||
end
|
||||
|
||||
function _initDefaults()
|
||||
|
|
@ -105,6 +142,13 @@ function _initDefaults()
|
|||
|
||||
--set randomseed
|
||||
math.randomseed(os.time())
|
||||
|
||||
--font
|
||||
font = love.graphics.newFont("font/LCD_Solid.ttf", 16)
|
||||
love.graphics.setFont(font)
|
||||
|
||||
--sidebar
|
||||
sideBarBox = {x = width, y = 0, w = love.graphics.getWidth() - width, h = height}
|
||||
end
|
||||
|
||||
function _initGridVars()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue