-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
198 lines (179 loc) · 5.21 KB
/
Copy pathmain.lua
File metadata and controls
198 lines (179 loc) · 5.21 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
World = require("world")
Map = require("map")
Llama = require("actors.llama")
Scientist = require("actors.scientist")
Console = require("actors.console")
Vent = require("actors.vent")
Laser = require("actors.laser")
Engi = require("actors.engi")
time = 0
speed = 200
local world, map
llama_count = 0
llamas = {}
end_sprites = {}
function load_llama_sprites ()
local llama_sprites = {}
for i = 0, 5 do
llama_sprites[i] = "llama/lhama_" .. i .. ".png"
end
return llama_sprites
end
function load_wall_tileset ()
return { "LAB/wall/tile065.png",
"LAB/wall/tile066.png",
"LAB/wall/tile068.png",
"LAB/wall/tile069.png" }
end
function clone_llama()
llama_count = llama_count + 1
if llama_count < 4 then
pew:play()
end
local llama = Llama { x = love.math.random(love.graphics.getWidth() * 0.7),
y = 200,
sprites = load_llama_sprites() }
llama:set_collision_cb(clone_llama)
table.insert(llamas, llama)
world:add_actor(llama)
if llama_count == 4 then
pewpew:play()
gamestate = "over"
end
end
gamestate = "title"
music = {}
function love.load()
music = love.audio.newSource("Decoration/lab2.wav", "stream")
music:setLooping(true)
musicegg = love.audio.newSource("Decoration/easteregg.wav", "stream")
pewpew = love.audio.newSource("Decoration/pewpew.wav", "stream")
pew = love.audio.newSource("Decoration/porta.ogg", "stream")
world = World { width = love.graphics.getWidth(),
height = love.graphics.getHeight(),
ground = 430 }
map = Map { width = world:get_width(),
height = world:get_height(),
wall_tileset = load_wall_tileset(),
ground_tileset = { "LAB/wall/tile101.png" },
ground = 350 }
local llama = Llama { x = love.math.random(love.graphics.getWidth() * 0.7),
y = 200,
sprites = load_llama_sprites() }
for i = 0, 5 do
end_sprites[i] = love.graphics.newImage("Decoration/clone_" .. i .. ".png")
end
llama:set_collision_cb(clone_llama)
table.insert(llamas, llama)
world:set_map(map)
world:add_actor(llama)
end
con = 0
pontos = 0
ven = 0
timerCon = 0
timerVent = 0
decor = 0
endtick = 0
endcontrol = 0
cien = 0
cienTimer = 0
level = 0
function love.update(dt)
if gamestate == "title" then
if love.keyboard.isDown("space") then
gamestate = "play"
end
if love.keyboard.isDown("q") then
gamestate = "easteregg"
end
elseif gamestate == "over" then
endtick = endtick + dt/dt
music:stop()
if endtick > 8 then
if endcontrol == 5 then
endcontrol = 0
end
endcontrol = (endcontrol + 1) % 6
endtick = 0
end
if love.keyboard.isDown("space") then
gamestate = "title"
love.event.quit( "restart" )
end
elseif gamestate == "easteregg" then
musicegg:play()
if love.keyboard.isDown("w") then
musicegg:stop()
gamestate = "title"
end
else
music:play()
con = dt + con
cien = cien + dt
level = level + dt
cienTimer = love.math.random(1,10)
print(timerCon)
ven = dt + ven
decor = math.random(1,3)
pontos = pontos + dt/dt
local prob_sci = love.math.random(1,1000)
if cienTimer < cien then
cien = 0
local sci = Scientist { x = 900,
y = 400,
sprites = "Scientist-Comp/Animations.png" }
world:add_actor(sci)
end
if love.math.random(1,6) < con then
con = 0
if decor == 1 then
local cons = Console { x = 900,
y = 400,
sprites = "industrial/console/console-active.png" }
world:add_actor(cons)
end
if decor == 2 then
local laser = Laser { x = 900,
y = 400,
sprites = "industrial/laser/laser-turn-off.png" }
world:add_actor(laser)
end
if decor == 3 then
local cons = Console { x = 900,
y = 400,
sprites = "industrial/console/console-active.png" }
world:add_actor(cons)
end
end
if math.random(1,2) < ven then
ven = 0
local vent = Vent { x = 900,
y = 400,
sprites = "industrial/vent/vent.png" }
world:add_actor(vent)
end
world:update(dt)
if love.keyboard.isDown("space") then
for _, llama in pairs(llamas) do
llama:jump()
end
end
end
end
function love.draw()
if gamestate == "title" then
telaini = love.graphics.newImage("Decoration/TELA.png")
love.graphics.draw(telaini, 0, 0)
love.graphics.print("Aperte espaço para começar o jogo!", 285, 290 )
elseif gamestate == "over" then
love.graphics.draw(end_sprites[endcontrol], 0,0)
love.graphics.print("Game Over! Aperte espaço para ir ao menu inicial.", 285, 290 )
elseif gamestate == "easteregg" then
local easteregg = love.graphics.newImage("Decoration/easteregg.png")
love.graphics.draw(easteregg, 0, 0)
else
world:draw()
love.graphics.print("Pontuação: " .. pontos, 550, 10, 0, 2 )
end
end