-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
111 lines (56 loc) · 1.43 KB
/
Copy pathmain.lua
File metadata and controls
111 lines (56 loc) · 1.43 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
--[[
Solitaire
Phineas Asmelash
]]
require 'src/Dependencies'
math.randomseed(os.time())
gameBoard = GameBoard()
local gameWon = false
function love.load()
love.window.setTitle('Solitaire')
love.window.setMode(SCREEN_WIDTH, SCREEN_HEIGHT)
love.mouse.buttonsPressed = {}
love.mouse.buttonReleased = {}
gameBoard = GameBoard()
end
function love.keypressed(key)
if key == 'escape' then
love.event.quit()
elseif key == "r" then
gameWon = false
love.load()
end
end
function love.mousepressed(x, y, button)
love.mouse.buttonsPressed[button] = true
end
function love.mousereleased(x, y, button)
love.mouse.buttonsReleased[button] = true
end
function love.mouse.wasButtonPressed(button)
return love.mouse.buttonsPressed[button]
end
function love.mouse.wasButtonReleased(button)
return love.mouse.buttonsReleased[button]
end
function love.update(dt)
if not gameWon then
gameBoard:update(dt)
love.mouse.buttonsPressed = {}
love.mouse.buttonsReleased = {}
-- win condition check
local winCounter = 0
for _, pile in pairs(gameBoard.suits) do
winCounter = winCounter + #pile
if winCounter == 52 then
gameWon = true
end
end
end
end
function love.draw()
gameBoard:draw()
if gameWon then
love.graphics.draw(you_win, 100, 0, 0, 0.75, 0.75)
end
end