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)
|
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
|
||||||
|
|
@ -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()
|
||||||
|
|
||||||
|
|
|
||||||
2
main.lua
2
main.lua
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
|
|
|
||||||
17
room.lua
17
room.lua
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue