rewritten

This commit is contained in:
0x81c 2015-03-14 06:18:04 -04:00
parent 3ae6c416e5
commit 286871ca21
5 changed files with 15 additions and 15 deletions

View file

@ -3,14 +3,11 @@ require "entity"
Artifact = class("Artifact", Entity) Artifact = class("Artifact", Entity)
function Artifact:initialize(x, y, color) function Artifact:initialize(x, y, color)
print(artifactSprite:getWidth(), artifactSprite:getHeight())
Entity.initialize(self, { Entity.initialize(self, {
x = x, x = x,
y = y, y = y,
sizeX = artifactSprite:getWidth() / 16,
sizeY = artifactSprite:getHeight() / 16,
color = color, color = color,
collision = "unmoveable", --player can't push other player collision = "unmoveable",
sprite = artifactSprite sprite = artifactSprite
}) })
end end

View file

@ -1,8 +1,8 @@
Input = {} Input = {}
Input.playermovekeys = { up = "up", down = "down", left = "left", right = "right" } Input.playermovekeys = { up = "up", down = "down", left = "left", right = "right" }
Input.playerswitchkeys = { ["1"] = "1", ["2"] = "2", ["3"] = "3" } Input.playerswitchkeys = { ["1"] = "1", ["2"] = "2", ["3"] = "3", ["4"] = "4" }
Input.colorfromkey = {"red", "green", "blue"} Input.colorfromkey = {"red", "green", "blue", "white"}
function Input:handler() function Input:handler()

View file

@ -77,7 +77,7 @@ function love.keypressed(key)
currentRoom:movePlayer(key) currentRoom:movePlayer(key)
elseif Input.isPlayerSwitch(key) then elseif Input.isPlayerSwitch(key) then
local c = Input.playerColor(key) local c = Input.playerColor(key)
currentRoom:switchPlayer(c) currentRoom:switchPlayerColor(c)
end end
if key == "w" then if key == "w" then
worldSha = worldSha + 1 worldSha = worldSha + 1

View file

@ -3,7 +3,6 @@ require "entity"
Player = class("Player", Entity) Player = class("Player", Entity)
function Player:initialize(x, y, color) function Player:initialize(x, y, color)
Entity.initialize(self, { Entity.initialize(self, {
x = x, x = x,
y = y, y = y,
@ -13,7 +12,6 @@ function Player:initialize(x, y, color)
collision = "none", --player can't push other player collision = "none", --player can't push other player
sprite = playerSprite sprite = playerSprite
}) })
end end
function Player:update() function Player:update()

View file

@ -66,7 +66,9 @@ end
function Room:draw() function Room:draw()
for color, player in pairs(self.player) do for color, player in pairs(self.player) do
player:draw() if self.activeColors[color] then
player:draw()
end
end end
for color, entityArray in pairs(self.collideables) do for color, entityArray in pairs(self.collideables) do
for _, entity in pairs(entityArray) do for _, entity in pairs(entityArray) do
@ -79,12 +81,15 @@ function Room:movePlayer(key)
end end
function Room:switchPlayer(colorToActivate) function Room:switchPlayerColor(color)
for color, active in pairs(self.activeColors) do print(color)
if color == colorToActivate then for c, active in pairs(self.activeColors) do
self:setActiveColor(color, true) if color == "white" then
self:setActiveColor(c, true)
elseif c == color then
self:setActiveColor(c, true)
else else
self:setActiveColor(color, false) self:setActiveColor(c, false)
end end
end end
end end