Game Development Reference
In-Depth Information
love.graphics.print("You have solved the puzzle",
size + 10, _H/2)
end
end
function love.mousepressed(mx, my, button)
for k, v in pairs(boxes) do
theBox = mx > v.X * size and my > v.Y * size and
mx < v.X * size + size and my < v.Y * size + size
-- Check if the point where the mouse was clicked is inside
-- and v is the current box it is inside
if theBox then
if mouse=="l" then
-- If the left mouse button is clicked, set or unset the grid
if v.Curr == 0 or c.Curr == 2 then
v.Curr = 1
else
v.Curr = 0
end
elseif mouse == "r" then
-- If the right mouse button is clicked, mark or unset the grid
if v.Curr == 0 or v.Curr == 1 then
v.Curr = 2
else
v.Curr = 0
end
end
end
end
solved = true
for k,v in pairs(boxes) do
if v.Curr == 2 then v.Curr = 0 end
if v.Orig == v.Curr then
-- Do nothing, everything is fine
else
-- If the Orig is not equal to Curr, then the puzzle is
-- not solved
solved = false
break
end
end
end
function love.keypressed(key)
if key == "up" or key == "w" then
-- If the key is w or up arrow, increase the size of the board
if sqaures < 9 then
squares = squares + 1
make_board()
end
Search WWH ::




Custom Search