-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.lua
48 lines (42 loc) · 1.29 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require('src/grid')
require('src/block')
require('src/states')
require('src/input')
local Sound = require('src/sound')
mouseGridPos = {0, 0}
function love.load()
math.randomseed(1)
Sound.load()
for i, color in pairs(colors) do
crashBlocks[color] = {}
end
nextPair = newPair()
state = tryNew
end
function love.update(dt)
if arg[#arg] == "-debug" then require("mobdebug").start() end
local x, y = love.mouse.getPosition()
mouseGridPos = {math.floor(x / gridInfo.tileWidth),
math.floor(y / gridInfo.tileHeight)}
if mouseGridPos[1] < 1 or mouseGridPos[1] >= gridInfo.w then
mouseGridPos[1] = "n/a"
end
if mouseGridPos[2] < 1 or mouseGridPos[2] >= gridInfo.h then
mouseGridPos[2] = "n/a"
end
state(dt)
end
function love.draw()
if currentPair then
local firstX, firstY, secondX, secondY = getGridCoords(currentPair)
drawBlock(firstX, firstY, currentPair.first)
drawBlock(secondX, secondY, currentPair.second)
end
for x, ys in pairs(grid) do
for y, blockInfo in pairs(ys) do
drawBlock(x, y, blockInfo)
end
end
love.graphics.setColor(255, 255, 255, 255)
love.graphics.print(string.format("(%s, %s)", mouseGridPos[1], mouseGridPos[2]), 0, 0)
end