-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
91 lines (81 loc) · 1.88 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
package.path = package.path .. ";../?.lua"
isFullscreen = true
love.window.setFullscreen(isFullscreen)
screenWidth, screenHeight = love.graphics.getDimensions()
require "world"
world:load()
require "welcomescreen"
require "obj/Player"
require "ui"
require "sound"
require "lib/deep"
screen = require "lib/shack"
gameStart = false
local red = {1, 0, 0}
local green = {0, 1, 0}
local blue = {0, 0, 3}
function love.keypressed(key)
if key == "escape" then
love.event.quit()
end
end
function love.load()
sound:load()
p1Sprite = love.graphics.newImage("res/sprite.png")
p2Sprite = love.graphics.newImage("res/sprite3.png")
loadWelcomeScreen()
world:load()
end
function startGame()
local joys = love.joystick.getJoysticks()
player1 = Player("1", p1Sprite, red, joys[1], {x = 200, y = 400})
player2 = Player("2", p2Sprite, blue, joys[2], {x = 1000, y = 400})
gameStart = true
end
function love.update(dt)
if not gameStart then
updateWelcomeScreen(dt)
else
screen:update(dt)
world:update(dt)
if player1.update then
player1:update(dt)
end
if player2.update then
player2:update(dt)
end
if player1.getStats and player2.getStats then
ui:update(player1:getStats(), player2:getStats(), dt)
end
end
end
function love.draw()
if not gameStart then
drawWelcomeScreen()
else
screen:apply()
player1:draw()
player2:draw()
deep:draw()
ui:draw()
player1:drawPartSys()
player2:drawPartSys()
world:draw()
end
end
function love.joystickpressed(joystick, button)
if not gameStart then
startGame()
else
player1:joystickpressed(joystick, button)
player2:joystickpressed(joystick, button)
end
end
function resetGame()
gameStart = false
local joys = love.joystick.getJoysticks()
player1 = Player("1", p1Sprite, red, joys[1], {x = 200, y = 400})
player2 = Player("2", p2Sprite, blue, joys[2], {x = 1000, y = 400})
Player.allTotems = {}
loadWelcomeScreen()
end