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)
function Artifact:initialize(x, y, color)
print(artifactSprite:getWidth(), artifactSprite:getHeight())
Entity.initialize(self, {
x = x,
y = y,
sizeX = artifactSprite:getWidth() / 16,
sizeY = artifactSprite:getHeight() / 16,
color = color,
collision = "unmoveable", --player can't push other player
collision = "unmoveable",
sprite = artifactSprite
})
end

View file

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

View file

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

View file

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

View file

@ -66,8 +66,10 @@ 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()
@ -79,12 +81,15 @@ function Room:movePlayer(key)
end
function Room:switchPlayer(colorToActivate)
for color, active in pairs(self.activeColors) do
if color == colorToActivate then
self:setActiveColor(color, true)
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(color, false)
self:setActiveColor(c, false)
end
end
end