rewritten
This commit is contained in:
parent
3ae6c416e5
commit
286871ca21
5 changed files with 15 additions and 15 deletions
|
|
@ -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
|
||||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
2
main.lua
2
main.lua
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
17
room.lua
17
room.lua
|
|
@ -66,7 +66,9 @@ end
|
|||
|
||||
function Room:draw()
|
||||
for color, player in pairs(self.player) do
|
||||
player:draw()
|
||||
if self.activeColors[color] then
|
||||
player:draw()
|
||||
end
|
||||
end
|
||||
for color, entityArray in pairs(self.collideables) do
|
||||
for _, entity in pairs(entityArray) do
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue