chroma_solstice/room.lua

128 lines
2.6 KiB
Lua
Raw Normal View History

2015-03-11 20:11:29 -04:00
Room = class("Room")
2015-03-11 21:41:02 -04:00
2015-03-11 21:08:15 -04:00
require "player"
2015-03-12 03:04:09 -04:00
require "box"
require "wall"
2015-03-12 05:13:04 -04:00
require "artifact"
2015-03-14 05:36:02 -04:00
require "npc"
require "art"
require "assorted"
2015-03-11 20:11:29 -04:00
2015-03-11 21:08:15 -04:00
function Room:initialize(t)
self.exits = t.exits
self.name = t.name
self.player = {}
2015-03-12 03:04:09 -04:00
self.collideables = {
red = {},
green = {},
blue = {}
}
self.activeColors = {
red = false, green = false, blue = false
}
2015-03-11 21:08:15 -04:00
2015-03-11 21:41:02 -04:00
for color, coords in pairs(t.player) do
2015-03-11 21:08:15 -04:00
self.player[color] = Player:new(coords.x, coords.y, color)
2015-03-12 03:04:09 -04:00
self.activeColors[color] = true
end
2015-03-14 05:36:02 -04:00
for i=0, 5 do
2015-03-12 03:04:09 -04:00
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)
2015-03-11 21:08:15 -04:00
end
2015-03-11 20:11:29 -04:00
2015-03-11 21:41:02 -04:00
2015-03-14 05:36:02 -04:00
for i=0, 5 do
2015-03-12 03:04:09 -04:00
local x, y = math.random(1, gridWidth), math.random(1, gridHeight)
2015-03-14 05:36:02 -04:00
for color, active in pairs(self.activeColors) do
self.collideables[color]["w: " .. x .. ", " .. y] = Wall:new(x, y, color)
end
2015-03-12 03:04:09 -04:00
end
2015-03-12 05:13:04 -04:00
2015-03-14 05:36:02 -04:00
-- 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")
2015-03-12 05:13:04 -04:00
2015-03-11 20:11:29 -04:00
end
2015-03-11 21:41:02 -04:00
function Room:update(dt)
for color, player in pairs(self.player) do
player:update(dt)
end
2015-03-11 20:11:29 -04:00
end
2015-03-11 21:41:02 -04:00
function Room:draw()
for color, player in pairs(self.player) do
2015-03-14 06:18:04 -04:00
if self.activeColors[color] then
player:draw()
end
2015-03-11 21:41:02 -04:00
end
2015-03-12 03:04:09 -04:00
for color, entityArray in pairs(self.collideables) do
for _, entity in pairs(entityArray) do
entity:draw()
end
end
end
function Room:movePlayer(key)
end
2015-03-14 06:18:04 -04:00
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)
2015-03-12 03:04:09 -04:00
else
2015-03-14 06:18:04 -04:00
self:setActiveColor(c, false)
2015-03-12 03:04:09 -04:00
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)
2015-03-11 21:08:15 -04:00
end
function Room:tick()
2015-03-12 03:04:09 -04:00
for color, entityArray in pairs(self.collideables) do
for _, entity in pairs(entityArray) do
entity:tick()
end
end
2015-03-11 21:08:15 -04:00
self:nextRoomCheck()
end
function Room:nextRoomCheck()
end
function nextRoom()
2015-03-12 03:04:09 -04:00
2015-03-11 20:11:29 -04:00
end