From 72533c0efb9d5659cd2c1fb0e9f067696d759812 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 26 Feb 2017 05:04:34 +0100 Subject: Initial commit, after jam --- main.lua | 265 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 265 insertions(+) create mode 100644 main.lua (limited to 'main.lua') diff --git a/main.lua b/main.lua new file mode 100644 index 0000000..10dcbb5 --- /dev/null +++ b/main.lua @@ -0,0 +1,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 \ No newline at end of file -- cgit v1.1