-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
104 lines (87 loc) · 2.76 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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
-- External Libraries
Utf8 = require("utf8")
-- Config
Config = require "config"
-- Local Libraries
Utils = require "lib/utilities"
SceneManager = require "lib/sceneManager"
QuipManager = require "lib/quipManager"
Game = require "lib/game"
MiniMaxMove = require "lib/miniMaxMove"
RandomMove = require "lib/randomMove"
-- @refactor change to autoloading
-- Entities
Supreme = require "entities/supreme"
Quiper = require "entities/quiper"
UserNameForm = require "entities/userNameForm"
TictactoeBoard = require "entities/tictactoeBoard"
ScoreBoard = require "entities/scoreBoard"
DebugMenu = require "entities/debugMenu"
KillScreen = require "entities/killScreen"
WinnerMessage = require "entities/winnerMessage"
DebugNotation = require "entities/debugNotation"
Dialogue = require "entities/dialogue"
WagerDialogue = require "entities/wagerDialogue"
Radar = require "entities/radar"
SatNet = require "entities/satNet"
GameMenu = require "entities/gameMenu"
EndingStatus = require "entities/endingStatus"
math.randomseed( os.time() )
love.window.setTitle( "Supreme TicTacToe" )
function love.load()
love.window.setMode( Config.screenSize[1], Config.screenSize[2] )
love.keyboard.setKeyRepeat(true)
Game.load(Config.debug)
QuipManager.load()
SceneManager.load(Config.startScene)
end
function love.update()
-- print(debug.getinfo(2).name)
Game.update()
SceneManager.update()
end
function love.draw()
SceneManager.draw()
end
function love.conf(t)
t.console = true
end
function love.textinput(text)
SceneManager.textinput(text)
end
function love.keypressed(key)
SceneManager.keypressed(key)
end
function love.mousepressed(x, y, button, istouch)
SceneManager.mousepressed(x, y, button, istouch)
end
function love.graphics.roundrect(mode, x, y, width, height, xround, yround)
local points = {}
local precision = (xround + yround) * .1
local tI, hP = table.insert, .5*math.pi
if xround > width*.5 then xround = width*.5 end
if yround > height*.5 then yround = height*.5 end
local X1, Y1, X2, Y2 = x + xround, y + yround, x + width - xround, y + height - yround
local sin, cos = math.sin, math.cos
for i = 0, precision do
local a = (i/precision-1)*hP
tI(points, X2 + xround*cos(a))
tI(points, Y1 + yround*sin(a))
end
for i = 0, precision do
local a = (i/precision)*hP
tI(points, X2 + xround*cos(a))
tI(points, Y2 + yround*sin(a))
end
for i = 0, precision do
local a = (i/precision+1)*hP
tI(points, X1 + xround*cos(a))
tI(points, Y2 + yround*sin(a))
end
for i = 0, precision do
local a = (i/precision+2)*hP
tI(points, X1 + xround*cos(a))
tI(points, Y1 + yround*sin(a))
end
love.graphics.polygon(mode, points)
end