3 | 3 |
local entity = require 'entity'
|
4 | 4 |
local tile = require 'tile'
|
5 | 5 |
local event = require 'event'
|
| 6 |
local menu = require 'menu'
|
6 | 7 |
local state = {}
|
7 | 8 |
|
8 | 9 |
local sprites = {}
|
|
13 | 14 |
|
14 | 15 |
function love.load()
|
15 | 16 |
state.t = 0
|
| 17 |
state.message = nil
|
16 | 18 |
state.board = board.Board:new()
|
17 | 19 |
state.char = entity.Entity:new(state.board, 3 * 24, 3 * 24, tile.getTile('character'))
|
18 | 20 |
|
|
25 | 27 |
state.board:set(8, 4, tile.getTile('water'))
|
26 | 28 |
state.board:set(8, 5, tile.getTile('water'))
|
27 | 29 |
state.board:setEntity(9, 6, tile.getTile('sign'))
|
| 30 |
|
| 31 |
state.canvas = love.graphics.newCanvas(
|
| 32 |
consts.boardWidth * consts.tileSize,
|
| 33 |
consts.boardHeight * consts.tileSize)
|
| 34 |
state.canvas:setFilter('nearest', 'nearest')
|
| 35 |
|
| 36 |
love.window.setMode(consts.tileSize * consts.boardWidth * 2,
|
| 37 |
consts.tileSize * consts.boardHeight * 2)
|
| 38 |
|
| 39 |
love.graphics.setNewFont('font.ttf', 16)
|
28 | 40 |
end
|
29 | 41 |
|
30 | 42 |
function love.update()
|
|
37 | 49 |
end
|
38 | 50 |
|
39 | 51 |
function love.keypressed(key)
|
40 | |
return event.keys.pressed[key] and
|
41 | |
event.keys.pressed[key](state)
|
| 52 |
if state.message then
|
| 53 |
state.message = nil
|
| 54 |
else
|
| 55 |
return event.keys.pressed[key] and
|
| 56 |
event.keys.pressed[key](state)
|
| 57 |
end
|
42 | 58 |
end
|
43 | 59 |
|
44 | 60 |
function love.keyreleased(key)
|
|
54 | 70 |
|
55 | 71 |
love.graphics.setColor(255, 255, 255)
|
56 | 72 |
|
| 73 |
love.graphics.setCanvas(state.canvas)
|
| 74 |
|
57 | 75 |
for x = 0, consts.boardWidth, 1 do
|
58 | 76 |
for y = 0, consts.boardHeight, 1 do
|
59 | 77 |
state.board:lookup(x, y):draw(x, y)
|
|
68 | 86 |
end
|
69 | 87 |
|
70 | 88 |
state.char:draw()
|
| 89 |
|
| 90 |
if state.message then
|
| 91 |
local w = consts.boardWidth * consts.tileSize
|
| 92 |
local h = consts.boardHeight * consts.tileSize / 2
|
| 93 |
love.graphics.rectangle('fill', 8, 8 + h, w - 16, h - 16)
|
| 94 |
love.graphics.setColor(0, 0, 0)
|
| 95 |
love.graphics.print(state.message, 12, h + 12)
|
| 96 |
end
|
| 97 |
|
| 98 |
love.graphics.setCanvas()
|
| 99 |
|
| 100 |
love.graphics.setColor(255, 255, 255)
|
| 101 |
love.graphics.rectangle('fill', 0, 0,
|
| 102 |
love.graphics.getWidth(),
|
| 103 |
love.graphics.getHeight())
|
| 104 |
|
| 105 |
love.graphics.draw(state.canvas, 0, 0, 0, 2, 2)
|
71 | 106 |
end
|