128 lines
No EOL
2.6 KiB
Lua
128 lines
No EOL
2.6 KiB
Lua
Room = class("Room")
|
|
|
|
require "player"
|
|
require "box"
|
|
require "wall"
|
|
require "artifact"
|
|
require "npc"
|
|
require "art"
|
|
require "assorted"
|
|
|
|
function Room:initialize(t)
|
|
self.exits = t.exits
|
|
self.name = t.name
|
|
self.player = {}
|
|
self.collideables = {
|
|
red = {},
|
|
green = {},
|
|
blue = {}
|
|
}
|
|
|
|
self.activeColors = {
|
|
red = false, green = false, blue = false
|
|
}
|
|
|
|
for color, coords in pairs(t.player) do
|
|
self.player[color] = Player:new(coords.x, coords.y, color)
|
|
self.activeColors[color] = true
|
|
end
|
|
|
|
for i=0, 5 do
|
|
local c = randomColor()
|
|
local x, y = math.random(1, gridWidth), math.random(1, gridHeight)
|
|
self.collideables[c]["b: " .. x .. ", " .. y] = Box:new(x, y, c)
|
|
end
|
|
|
|
|
|
for i=0, 5 do
|
|
local x, y = math.random(1, gridWidth), math.random(1, gridHeight)
|
|
for color, active in pairs(self.activeColors) do
|
|
self.collideables[color]["w: " .. x .. ", " .. y] = Wall:new(x, y, color)
|
|
end
|
|
end
|
|
|
|
-- for color, active in pairs(self.activeColors) do
|
|
-- local x, y = 6, 3
|
|
-- if active then self.collideables[color]["n: " .. x .. ", " .. y] = Ass:new(x, y, color, "animals/processed/", "me_rach") end
|
|
|
|
-- local x, y = 1, 1
|
|
-- if active then self.collideables[color]["n: " .. x .. ", " .. y] = Ass:new(x, y, color, "tech/processed/", "mac_smaller") end
|
|
|
|
-- local x, y = 7, 7
|
|
-- if active then self.collideables[color]["n: " .. x .. ", " .. y] = Ass:new(x, y, color, "tech/processed/", "cd") end
|
|
|
|
-- end
|
|
|
|
-- self.collideables["green"]["fpp"] = Artifact:new(6, 6, "green")
|
|
|
|
end
|
|
|
|
|
|
function Room:update(dt)
|
|
for color, player in pairs(self.player) do
|
|
player:update(dt)
|
|
end
|
|
end
|
|
|
|
function Room:draw()
|
|
for color, player in pairs(self.player) do
|
|
if self.activeColors[color] then
|
|
player:draw()
|
|
end
|
|
end
|
|
for color, entityArray in pairs(self.collideables) do
|
|
for _, entity in pairs(entityArray) do
|
|
entity:draw()
|
|
end
|
|
end
|
|
end
|
|
|
|
function Room:movePlayer(key)
|
|
|
|
end
|
|
|
|
function Room:switchPlayerColor(color)
|
|
print(color)
|
|
for c, active in pairs(self.activeColors) do
|
|
if color == "white" then
|
|
self:setActiveColor(c, true)
|
|
elseif c == color then
|
|
self:setActiveColor(c, true)
|
|
else
|
|
self:setActiveColor(c, false)
|
|
end
|
|
end
|
|
end
|
|
|
|
function Room:setActiveColor(color, bool)
|
|
self.activeColors[color] = bool
|
|
end
|
|
|
|
function Room:getAdjacentEntities(entities, pos, axis, direction)
|
|
|
|
end
|
|
|
|
function Room:checkAndPull(entities, pos, axis, direction)
|
|
|
|
end
|
|
|
|
function Room:tryPlayerMove(entities, pos, axis, direction)
|
|
|
|
end
|
|
|
|
function Room:tick()
|
|
for color, entityArray in pairs(self.collideables) do
|
|
for _, entity in pairs(entityArray) do
|
|
entity:tick()
|
|
end
|
|
end
|
|
self:nextRoomCheck()
|
|
end
|
|
|
|
function Room:nextRoomCheck()
|
|
|
|
end
|
|
|
|
function nextRoom()
|
|
|
|
end |