summaryrefslogtreecommitdiff
path: root/main.lua
blob: 10dcbb588c9037d55acd578297b9e2123835ff8a (plain)
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
-- Import.
Game = require "game"

-- LÖVE2D Callbacks.
function love.load()
	-- Initialization
	love.graphics.setBackgroundColor(2,2,5)
	love.graphics.setDefaultFilter("nearest", "nearest")
	love.graphics.setLineStyle("rough")
	math.randomseed(os.time())
	print("Initializing...")
	Game.load()
	-- Game
	local ambient = love.audio.newSource("assets/ambient.ogg", "static")
	ambient:setLooping(true)
	ambient:setVolume(0.9)
	ambient:play()
	local tutorial = Game.setMessage():setText("", "Click to move, interact with an object or close a message."):setUse(function () Game.setMessage():setText("THE VISITOR", "Game made for Fermi Paradox Jam") end)
	local r = {
		Game.insertRoom(36):setStyle("start"):discover(),
		Game.insertRoom():setOutside(1),
		Game.insertRoom():setOutside(2),
		Game.insertRoom():setOutside(3),
		Game.insertRoom():setOutside(4),
		Game.insertRoom():setOutside(5),
		Game.insertRoom():setOutside(6),
		Game.insertRoom():setOutside(7),
		Game.insertRoom(57):setStyle("finish"),
	}
	-- Doors
	local d = {
		Game.insertDoor(r[1]):setUse(function (self) 
			if self.animation == "closed" then 
				r[2]:discover(true)
				self:changeAnimation("opening")
				Game.setMessage():setText("Me:", "I'm still a little bit confused after waking up. This console may have some useful information.")
			end
		end),
		Game.insertDoor(r[2]):setUse(function (self)
			if self.animation == "closed" then
				r[3]:discover(true)
				self:changeAnimation("opening")
				Game.setMessage():setText("Me:", "What the actual..."):setUse(function ()
					Game.setMessage():setText("Me:", "This does not look normal. The view from next room's window is a totally different view compared to this room's view.")
				end)
			end
			if self.animation == "locked" then
				Game.setMessage():setText("Me:", "This door seems locked.")
			end
		end):changeAnimation("locked"),
		Game.insertDoor(r[3]):setUse(function (self)
			if self.animation == "closed" then
				r[4]:discover(true)
				self:changeAnimation("opening")
				Game.setMessage():setText("Me:", "Same thing.")
			end
		end),
		Game.insertDoor(r[4]):setUse(function (self)
			if self.animation == "closed" then
				r[5]:discover(true)
				self:changeAnimation("opening")
				Game.setMessage():setText("Me:", "Well, this is different. This time it is a star.")
			end
		end),
		Game.insertDoor(r[5]):setUse(function (self)
			if self.animation == "closed" then
				Game.setMessage():setText("Me:", "Let's hope I will find anything in the next room. Something other than: window, door, console.")
				r[6]:discover(true)
				self:changeAnimation("opening")
			end
		end),
		Game.insertDoor(r[6]):setUse(function (self)
			if self.animation == "closed" then
				r[7]:discover(true)
				self:changeAnimation("opening")
			end
			if self.animation == "locked" then
				Game.setMessage():setText("Me:", "This door seems locked.")
			end
		end),
		Game.insertDoor(r[7]):setUse(function (self)
			if self.animation == "closed" then
				r[8]:discover(true)
				self:changeAnimation("opening")
			end
			if self.animation == "locked" then
				Game.setMessage():setText("Me:", "This door seems locked.")
			end
		end),
		Game.insertDoor(r[8]):setUse(function (self)
			if self.animation == "closed" then
				r[9]:discover(true)
				self:changeAnimation("opening")
				Game.setMessage():setText("Me:", "This room is different.")
			end
			if self.animation == "locked" then
				Game.setMessage():setText("Me:", "This door seems locked.")
			end
		end),
	}
	-- 1:
	Game.insertProp():setPosition(3,12):setDimensions(9,16):setStyle("fridge"):setUse(function () Game.setMessage():setText("Me:", "It's the cryocapsule I have just left."):show() end):changeAnimation("open")
	Game.insertProp():setPosition(14,12):setDimensions(9,16):setStyle("fridge"):setUse(function () Game.setMessage():setText("Me:", "This one is closed and I can't see if it is empty or not."):show() end):changeAnimation("closed")
	-- 2:
	Game.insertProp():setPosition(r[2]:randomX(20),19):setDimensions(7,9):setStyle("console"):changeAnimation("working"):setUse(function (self)
		Game.setMessage():setText("Console:", "Planet: 00AE30F63CC50BEC\nLife found: false\n(...)"):show():setUse(function ()
			Game.setMessage():setText("Me:", "There is plenty of information about this planet in the console. Nothing feels really useful but it seems there is also an unlock button for the door."):setUse(function ()
				if d[2].animation == "locked" then d[2]:changeAnimation("closed") end
			end)
		end)
	end)
	-- 3:
	Game.insertProp():setPosition(r[3]:randomX(7),19):setDimensions(7,9):setStyle("console"):changeAnimation("working"):setUse(function (self)
		Game.setMessage():setText("Console:", "Planet: 0054500436450A2D\nLife found: false\n(...)"):show():setUse(function ()
			Game.setMessage():setText("Console:", "(...)\nIt is worth mentioning that this planet may develop life in future. Probe has decided to leave Watcher-Child here for further observation.\n(...)"):setUse(function ()
				Game.setMessage():setText("Me:", "Interesting. While I have no knowledge of this facility I recall being told what are the Probes. I think they were some kind of self-replicating entities.")
			end)
		end)
	end)
	-- 4:
	Game.insertProp():setPosition(r[4]:randomX(7),19):setDimensions(7,9):setStyle("console"):changeAnimation("working"):setUse(function (self)
		Game.setMessage():setText("Console:", "Planet: 000021B533252BAB\nLife found: true, bacteria-like\n(...)"):show():setUse(function ()
			Game.setMessage():setText("Me:", "Wait... Could it be that behind every window there is planet described in the console?\nIt seems impossible but..."):setUse(function ()
				Game.setMessage():setText("Console:", "(...)\nPlanet's atmosphere has been destroyed due to increasing activity of system's star. Watcher has decided to go into lower activity state.\n(...)"):setUse(function ()
					Game.setMessage():setText("Console:", "(...)\nNo further sings of life on planet. Watcher has decided to leave planet due to star activity. Moving away from the star.\n(...)")
				end)
			end)
		end)
	end)
	-- 5:
	Game.insertProp():setPosition(r[5]:randomX(7),19):setDimensions(7,9):setStyle("console"):changeAnimation("working"):setUse(function (self)
		Game.setMessage():setText("Console:", "Star: B94DC4A0\nPlanets: none\nLeaving Watcher-Child for observation."):show():setUse(function ()
			Game.setMessage():setText("Me:", "This one is somehow disappointing..."):setUse(function ()
				Game.setMessage():setText("Me:", "...")
			end)
		end)
	end)
	-- 6:
	Game.insertProp():setPosition(r[6]:randomX(7),19):setDimensions(7,9):setStyle("console"):changeAnimation("working"):setUse(function (self)
		Game.setMessage():setText("Console:", "Data unaccessible.\n\nMemory storage damaged."):show():setUse(function ()
			Game.setMessage():setText("Me:", "And this is somehow interesting.\nYet it doesn't seem like I could do anything with it. I haven't got access to any proper tools from here.")
		end)
	end)
	--- 7:
	Game.insertProp():setPosition(r[7]:randomX(7),19):setDimensions(7,9):setStyle("console"):changeAnimation("working"):setUse(function (self)
		Game.setMessage():setText("Console:", "Planet: 00A687B4D7EA9567\nLife found: true, intelligent\n(...)"):show():setUse(function ()
			Game.setMessage():setText("Console:", "(...)\nProbe can't decide on normal conditions. Probe has sent data to Home.\n(...)"):setUse(function ()
				Game.setMessage():setText("Console:", "(...)\nWaiting for responce...\nWaiting for responce...\n(...)"):setUse(function ()
					Game.setMessage():setText("Console:", "(...)Home Personality has been woken up but is unresponsible. Possible personality damage. Attempting repairs...\n"):setUse(function ()
						Game.setMessage():setText("Me:", "And... Wait, that's it? Where is the rest of the log files?")
					end)
				end)
			end)
		end)
	end)
	-- 8:
	Game.insertProp():setPosition(r[8]:randomX(7),19):setDimensions(7,9):setStyle("console"):changeAnimation("working"):setUse(function (self)
		Game.setMessage():setText("Console:", "Planet: 00B4CDDA64E73009\nLife found: true, bacteria-like(...)"):show():setUse(function ()
			Game.setMessage():setText("Console:", "(...)\nHigh radiation level in atmosphere. Radiation is natural due to planet natural resources.\n(...)"):setUse(function ()
				Game.setMessage():setText("Console:", "(...)\nThere are no signs of evolution. Only one species with no reproduction abilities. There is also no sign of death among them."):setUse(function ()
					Game.setMessage():setText("Me:", "Immortaility, huh? Quite impressing but along with all other things listed in the log... It will just be there untill star will burn out.")
				end)
			end)
		end)
	end)
	-- 9:
	Game.insertProp():setPosition(r[9].x+22,19):setDimensions(7,9):setStyle("console"):changeAnimation("working"):setUse(function (self)
		if Game.decision then return end
		Game.setMessage():setText("Console:", "Case: intelligent life on 00A687B4D7EA9567\n(...)"):show():setUse(function ()
			Game.setMessage():setText("Me:", "Wait..."):setUse(function ()
				Game.setMessage():setText("Me:", "This would mean that I am the Personality..."):setUse(function ()
					Game.setMessage():setText("Console:", "(...)\nAfter several repairs performed on brain memory sectors Personality could be started. Its purpose is to determine whenever listed case of life can be classified as intelligent lifeform.\n(...)"):setUse(function ()
						Game.setMessage():setText("Console:", "(...)\nLife-like mass found on planet is changing its chemical properties in mostly random ways. It does not show any signs of communication with Probe.\n(...)"):setUse(function ()
							Game.setMessage():setText("Console:", "(...)\nThose chemical patterns could be translated to 7-dimensional space with various objects that seem to perform actions. It is not sure if it is not overinterpretation of simple patterns.\n(...)"):setUse(function ()
								Game.setMessage():setText("Console:", "(...)\nThese \"objects\" don't hold their shape for long time, but they seem not to disappear without certain few conditions.\n(...)"):setUse(function ()
									Game.setMessage():setText("Me:", "And there is more... Raport is about 1,200 pages long, not mentioning raw data..."):setUse(function ()
										Game.setMessage():setText("", "With given description select whenever it is intelligent life or not.")
										Game.decision = true
									end)
								end)
							end)
						end)
					end)
				end)
			end)
		end)
	end)
	Game.fincryo = Game.insertProp():setPosition(r[9].x+38,12):setDimensions(9,16):setStyle("fridge"):changeAnimation("closed"):setUse(function (self)
		if self.animation == "open" then
			Game.setMessage():setText("", "Click again to enter cryocapsule and quit the game."):show():setUse(function ()
				Game.rooms = {}
				Game.player.y = -50
				Game.setMessage():setText("", "After you enter non-existent cryocapsule in the non-existent space your virtually managed personality is put to standby mode.\nYour memories keep leaking out of the data storage as semi-AI can't perform proper repairs.\nGoodnight, Visitor."):show():setUse(function ()
					love.event.quit()
				end)
			end)
		else
			Game.setMessage():setText("Me:", "It is closed."):show()
		end
	end)
	Game.insertProp():setPosition(r[9].x+31,20):setDimensions(2,8):setStyle("wand"):changeAnimation("yes"):setUse(function (self)
		if Game.decision then
			Game.setMessage():setText("", "Yes."):show():setUse(function (self)
				Game.fincryo:changeAnimation("open") end)
		else
			Game.setMessage():setText("", "Use console first."):show()
		end
	end)
	Game.insertProp():setPosition(r[9].x+34,20):setDimensions(2,8):setStyle("wand"):changeAnimation("no"):setUse(function (self)
		if Game.decision then
			Game.setMessage():setText("", "No."):show():setUse(function (self)
				Game.fincryo:changeAnimation("open") end)
		else
			Game.setMessage():setText("", "Use console first."):show()
		end
	end)
end
function love.update(dt)
	Game.delay = Game.delay - dt
	if Game.delay < 0 then
		Game.delay = Game.delay + Game.initial
		for _,room in pairs(Game.rooms) do room:update() end
		for _,prop in pairs(Game.props) do prop:update() end
		local player, message = Game.getPlayer(), Game.getMessage()
		if player then player:update() end
		if message then message:update() end
	end
end
function love.draw()
	local scale = Game.getScale()
	local offset_x, offset_y = Game.getOffsets()
	love.graphics.translate(offset_x, offset_y)
	for _,room in pairs(Game.rooms) do
		room:draw(scale, offset_x, offset_y)
	end
	for _,prop in pairs(Game.props) do
		prop:draw(scale)
	end
	if Game.getPlayer() then
		Game.getPlayer():draw(scale)
	end
	if Game.getMessage() then
		Game.getMessage():draw(scale)
	end
end
function love.quit()
	print("Quiting...")
end
function love.mousepressed(x, y, button, istouch)
	local x, y = Game.getMousePosition(x, y)
	if button == 1 then
		if Game.getMessage() and Game.getMessage():isVisible() then
			print("Message is active; using...")
			Game.getMessage():click()
		elseif Game.getPlayer() then
			Game.getPlayer():setTarget(x, y, Game.testPosition(x, y))
			print("No message active, setting target for player...")
		end
	end
end
function love.keypressed(key)
	if key == "escape" then
		love.event.quit()
	end
end