Update
This commit is contained in:
parent
a96f8e1aa3
commit
ada33393e5
16 changed files with 196 additions and 16 deletions
4
edge.lua
4
edge.lua
|
@ -62,8 +62,8 @@ local mt = {
|
|||
end
|
||||
}
|
||||
|
||||
function edge:set(room, dir, dst)
|
||||
local e = self:from{
|
||||
function edge.set(room, dir, dst)
|
||||
local e = edge:from{
|
||||
dir = dir,
|
||||
destination = dst,
|
||||
}
|
||||
|
|
1
main.lua
1
main.lua
|
@ -25,6 +25,7 @@ end
|
|||
|
||||
function set_room(r)
|
||||
current_room = rooms[r]
|
||||
assert(current_room)
|
||||
end
|
||||
|
||||
screen = {
|
||||
|
|
13
obj/door.lua
13
obj/door.lua
|
@ -27,7 +27,7 @@ function m:draw()
|
|||
end
|
||||
end
|
||||
|
||||
m.mousepressed = window.mousepressed(function (self)
|
||||
m.keyMode = window.mousepressed(function (self)
|
||||
if self.locked then
|
||||
local i = inventory.selected_item
|
||||
if i and i.code then
|
||||
|
@ -49,4 +49,15 @@ m.mousepressed = window.mousepressed(function (self)
|
|||
end
|
||||
end)
|
||||
|
||||
m.keypadMode = window.mousepressed(function (self)
|
||||
if self.locked then
|
||||
log:log("It's locked.")
|
||||
else
|
||||
log:format("You enter %s", self.destination)
|
||||
set_room(self.destination)
|
||||
end
|
||||
end)
|
||||
|
||||
m.mousepressed = m.keyMode
|
||||
|
||||
return m
|
||||
|
|
|
@ -13,14 +13,13 @@ local install = m.install
|
|||
function m:install(room, x, y)
|
||||
self.keypad = keypad:from{
|
||||
code = self.code,
|
||||
oncorrect = self.oncorrect,
|
||||
room = room
|
||||
}
|
||||
|
||||
install(self, room, x, y)
|
||||
end
|
||||
|
||||
m.mousepressed = window.mousepressed(function (self)
|
||||
set_room_raw(self.keypad)
|
||||
end)
|
||||
m.mousepressed = window.portal("keypad")
|
||||
|
||||
return m
|
||||
|
|
21
obj/note.lua
Normal file
21
obj/note.lua
Normal file
|
@ -0,0 +1,21 @@
|
|||
local entity = require("entity")
|
||||
local window = require("window")
|
||||
local note = require("room/note")
|
||||
|
||||
local m = entity:from{
|
||||
text = "sample text",
|
||||
}
|
||||
|
||||
local install = m.install
|
||||
function m:install(room, x, y)
|
||||
self.note = note:from{
|
||||
text = self.text,
|
||||
room = room
|
||||
}
|
||||
|
||||
install(self, room, x, y)
|
||||
end
|
||||
|
||||
m.mousepressed = window.portal('note')
|
||||
|
||||
return m
|
25
obj/sundial.lua
Normal file
25
obj/sundial.lua
Normal file
|
@ -0,0 +1,25 @@
|
|||
local entity = require("entity")
|
||||
local window = require("window")
|
||||
local sundial = require("room/sundial")
|
||||
|
||||
local m = entity:from{
|
||||
width = 60,
|
||||
height = 60,
|
||||
lines = {'fill', {30, 30, 60, 40, 60, 50, 30, 60, 0, 50, 0, 40}},
|
||||
}
|
||||
|
||||
local install = m.install
|
||||
function m:install(room, x, y)
|
||||
self.sundial = sundial:from{
|
||||
numbers = self.numbers,
|
||||
room = room,
|
||||
}
|
||||
|
||||
install(self, room, x, y)
|
||||
end
|
||||
|
||||
m.mousepressed = window.mousepressed(function (self)
|
||||
set_room_raw(self.sundial)
|
||||
end)
|
||||
|
||||
return m
|
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB |
10
room.lua
10
room.lua
|
@ -8,11 +8,11 @@ local entity = require('entity')
|
|||
-- - edges
|
||||
local room = entity:from{
|
||||
lines = {
|
||||
{'line', 0, 0, 120, 80},
|
||||
{'line', 320, 0, 200, 80},
|
||||
{'line', 0, 240, 120, 160},
|
||||
{'line', 320, 240, 200, 160},
|
||||
{'fill', 120, 80, 200, 80, 200, 160, 200, 80},
|
||||
{'fill', {80, 60, 240, 60, 240, 180, 80, 180}},
|
||||
{'line', {0, 0, 80, 60}},
|
||||
{'line', {320, 0, 240, 60}},
|
||||
{'line', {0, 240, 80, 180}},
|
||||
{'line', {320, 240, 240, 180}},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
9
room/alley.lua
Normal file
9
room/alley.lua
Normal file
|
@ -0,0 +1,9 @@
|
|||
local room = require("room")
|
||||
local edge = require("edge")
|
||||
|
||||
local m = room:new()
|
||||
|
||||
edge.set(m, 'down', "sundial_alley")
|
||||
--edge.set(m, 'left', "alley2")
|
||||
|
||||
return m
|
|
@ -5,9 +5,9 @@ local crowbar = require('item/crowbar')
|
|||
local r = room:new()
|
||||
|
||||
crowbar:install(r, 100, 160)
|
||||
edge:set(r, 'up', "default")
|
||||
edge:set(r, 'down', "default")
|
||||
edge:set(r, 'left', "default")
|
||||
edge:set(r, 'right', "doortest")
|
||||
edge.set(r, 'up', "default")
|
||||
edge.set(r, 'down', "sundial_alley")
|
||||
edge.set(r, 'left', "default")
|
||||
edge.set(r, 'right', "doortest")
|
||||
|
||||
return r
|
||||
|
|
|
@ -53,7 +53,7 @@ function m:from(t)
|
|||
function () kp:accept() end,
|
||||
sx + kd*2, br, ks, ks)
|
||||
|
||||
edge:set(kp, "down", kp.room)
|
||||
edge.set(kp, "down", kp.room)
|
||||
|
||||
register(kp)
|
||||
|
||||
|
|
22
room/note.lua
Normal file
22
room/note.lua
Normal file
|
@ -0,0 +1,22 @@
|
|||
local window = require("window")
|
||||
local room = require("room")
|
||||
local edge = require("edge")
|
||||
|
||||
local m = room:new()
|
||||
|
||||
local from = m.from
|
||||
function m:from(t)
|
||||
local n = from(self, t)
|
||||
|
||||
edge.set(n, 'down', n.room)
|
||||
|
||||
return n
|
||||
end
|
||||
|
||||
m.draw = window.draw(function (self)
|
||||
love.graphics.printf(self.text, 80, 40, 160)
|
||||
|
||||
self.edges[1]:draw()
|
||||
end)
|
||||
|
||||
return m
|
55
room/sundial.lua
Normal file
55
room/sundial.lua
Normal file
|
@ -0,0 +1,55 @@
|
|||
local window = require("window")
|
||||
local room = require("room")
|
||||
local edge = require("edge")
|
||||
|
||||
local clock_size = 60
|
||||
local arm_size = 55
|
||||
|
||||
local m = room:new()
|
||||
|
||||
local from = m.from
|
||||
function m:from(t)
|
||||
local sd = from(self, t)
|
||||
|
||||
sd.tick = 0
|
||||
sd.ni = 1
|
||||
|
||||
edge.set(sd, 'down', sd.room)
|
||||
|
||||
register(sd)
|
||||
|
||||
return sd
|
||||
end
|
||||
|
||||
m.draw = window.draw(function (self)
|
||||
love.graphics.circle('fill', 160, 120, clock_size, 12)
|
||||
|
||||
local s = math.pi * self.numbers[self.ni] / 6
|
||||
local x = 160 + arm_size * math.sin(s)
|
||||
local y = 120 - arm_size * math.cos(s)
|
||||
local n = 120 - arm_size
|
||||
|
||||
love.graphics.setColor(0, 0, 0)
|
||||
love.graphics.polygon('fill', 160, n, 160, 120, x, y)
|
||||
love.graphics.setColor(1, 1, 1)
|
||||
love.graphics.polygon('fill', 160, n, 160, 120, 140, n)
|
||||
love.graphics.setColor(0, 0, 0)
|
||||
love.graphics.polygon('line', 160, n, 160, 120, 140, n)
|
||||
love.graphics.setColor(1, 1, 1)
|
||||
|
||||
self.edges[1]:draw()
|
||||
end)
|
||||
|
||||
function m:update(dt)
|
||||
self.tick = self.tick + dt
|
||||
|
||||
if self.tick > 2 then
|
||||
self.tick = self.tick - 2
|
||||
self.ni = self.ni + 1
|
||||
if self.ni > #self.numbers then
|
||||
self.ni = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return m
|
29
room/sundial_alley.lua
Normal file
29
room/sundial_alley.lua
Normal file
|
@ -0,0 +1,29 @@
|
|||
local room = require("room")
|
||||
local edge = require("edge")
|
||||
local sundial = require("obj/sundial")
|
||||
local keypad = require("obj/keypad")
|
||||
local door = require("obj/door")
|
||||
|
||||
local m = room:new()
|
||||
|
||||
sundial:from{
|
||||
numbers = {3, 5, 8, 2, 7},
|
||||
}:install(m, 140, 160)
|
||||
|
||||
local d = door:from{
|
||||
destination = 'vivarium',
|
||||
}
|
||||
|
||||
d:install(m, 80, 60)
|
||||
d.mousepressed = d.keypadMode
|
||||
|
||||
keypad:from{
|
||||
code = 35827,
|
||||
oncorrect = function (self)
|
||||
d.locked = false
|
||||
end,
|
||||
}:install(m, 180, 100)
|
||||
|
||||
edge.set(m, 'up', "alley")
|
||||
|
||||
return m
|
|
@ -1,6 +1,8 @@
|
|||
local m = {
|
||||
['default'] = require('room/default'),
|
||||
['doortest'] = require('room/doortest'),
|
||||
['alley'] = require("room/alley"),
|
||||
['sundial_alley'] = require("room/sundial_alley"),
|
||||
}
|
||||
|
||||
return m
|
||||
|
|
|
@ -39,6 +39,12 @@ function w.propagate(tnames)
|
|||
end
|
||||
end
|
||||
|
||||
function w.portal(room)
|
||||
return w.mousepressed(function (self, x, y, button)
|
||||
set_room_raw(self[room])
|
||||
end)
|
||||
end
|
||||
|
||||
function w.draw_border(width, height)
|
||||
love.graphics.push('all')
|
||||
love.graphics.setLineWidth(5)
|
||||
|
|
Loading…
Add table
Reference in a new issue