80 lines
No EOL
1.5 KiB
Lua
80 lines
No EOL
1.5 KiB
Lua
class = require "libs/middleclass"
|
|
Timer = require "libs/hump/timer"
|
|
require "input"
|
|
require "color"
|
|
require "room"
|
|
require "player"
|
|
require "debug_helpers"
|
|
|
|
function love.load()
|
|
_initDefaults()
|
|
_initGridVars()
|
|
|
|
loadSprites()
|
|
|
|
inputTimer = Timer.new()
|
|
|
|
currentRoom = Room:new{
|
|
player = {
|
|
red = {x = 3, y = 5},
|
|
green = {x = 4, y = 3},
|
|
blue = {x = 3, y = 10}
|
|
}
|
|
}
|
|
end
|
|
|
|
function love.update(dt)
|
|
Input:handler()
|
|
|
|
currentRoom:update()
|
|
end
|
|
|
|
function love.draw()
|
|
love.graphics.setBlendMode("screen")
|
|
currentRoom:draw()
|
|
end
|
|
|
|
function love.keypressed(key)
|
|
if Input.isPlayerMove(key) then
|
|
currentRoom:movePlayer(key)
|
|
elseif Input.isPlayerSwitch(key) then
|
|
local c = Input.playerColor(key)
|
|
currentRoom:switchPlayer(c)
|
|
end
|
|
end
|
|
|
|
function _initDefaults()
|
|
--set filter
|
|
love.graphics.setDefaultFilter("linear", "nearest")
|
|
|
|
--set global width / height variables
|
|
width = love.graphics.getWidth()
|
|
height = love.graphics.getHeight()
|
|
if width > height then
|
|
width = height
|
|
else
|
|
height = width
|
|
end
|
|
|
|
--set randomseed
|
|
math.randomseed(os.time())
|
|
end
|
|
|
|
function _initGridVars()
|
|
gridWidth, gridHeight = 11, 11
|
|
drawScale = width / gridWidth / 16
|
|
end
|
|
|
|
function createCanvases()
|
|
|
|
end
|
|
|
|
function loadSprites()
|
|
playerSprite = love.graphics.newImage("art/player.png")
|
|
wallSprite = love.graphics.newImage("art/static_wall.png")
|
|
boxSprite = {
|
|
red = love.graphics.newImage("art/wall_r.png"),
|
|
green = love.graphics.newImage("art/wall_g.png"),
|
|
blue = love.graphics.newImage("art/wall_b.png")
|
|
}
|
|
end |