-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
83 lines (56 loc) · 2.09 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
require("utils")
require("mainManu")
require("gameLoop")
require("gameOver")
local moonshine = require ("moonshine")
local crtEffect
function love.load()
love.window.setTitle('Tetris')
love.window.setMode((WIDTH + addSizeX) * GRIDSIZE, (HEIGHT + addSizeY) * GRIDSIZE)
love.keyboard.setKeyRepeat(true, 0)
spriteSheet = love.graphics.newImage('sources/NES - Tetris - Block Tiles.png')
spriteSheet:setFilter('nearest', 'nearest')
sources = {
background = love.audio.newSource('sources/OriginalTetristheme.wav', 'stream'),
destruction = love.audio.newSource('sources/destroyLine.wav', 'static'),
lineFall = love.audio.newSource('sources/lock.mp3', 'static'),
}
sources.background:setLooping(true)
sources.background:play()
handCursor = love.mouse.getSystemCursor("hand")
mainFontNormal = love.graphics.newFont("sources/joystix monospace.otf", GRIDSIZE * 3)
mainFontNormal:setFilter('nearest', 'nearest')
love.graphics.setFont(mainFontNormal)
Screen.selectScreen = function (state)
Screen.currScreen = state
Screen.Screens[Screen.currScreen].load()
isHand = false
end
Screen.Screens = {}
table.insert(Screen.Screens,mainMenuScreen)
table.insert(Screen.Screens,gameLoopScreen)
table.insert(Screen.Screens,gameOverScreen)
Screen.selectScreen(1)
crtEffect = moonshine(moonshine.effects.crt)
crtEffect.crt.feather = 0.05
end
function love.update()
isHand = false
Screen.Screens[Screen.currScreen].update()
if isHand then love.mouse.setCursor(handCursor)
else love.mouse.setCursor() end
end
function love.draw()
crtEffect(function ()
Screen.Screens[Screen.currScreen].draw()
love.graphics.setColor(0.5,0.5,0.8,0.2)
love.graphics.rectangle('fill',0,0,love.graphics.getWidth(),love.graphics.getHeight())
love.graphics.setColor(1,1,1,1)
end)
end
function love.keypressed(key, scancode, isrepeat)
if key == "escape" then
love.event.quit()
end
Screen.Screens[Screen.currScreen].events(key, scancode, isrepeat)
end