wowgit add -A!
This commit is contained in:
parent
1156564fa2
commit
747a7b7b58
3 changed files with 44 additions and 25 deletions
33
entity.lua
33
entity.lua
|
|
@ -4,6 +4,7 @@ function Entity:initialize(t)
|
|||
self.x, self.y = t.x, t.y
|
||||
self.spriteSize = {w = t.sprite:getWidth(), h = t.sprite:getHeight()}
|
||||
self.size = {w = self.spriteSize.w / 16, h = self.spriteSize.h / 16}
|
||||
self.cellShape = t.cellShape or self:cellShapeFromBox(self.size)
|
||||
self.color = Color:new(t.color)
|
||||
self.collision = t.collision --"none", "moveable", "unmoveable"
|
||||
self.sprite = t.sprite
|
||||
|
|
@ -32,18 +33,36 @@ end
|
|||
function Entity:getOccupiedCells(coords)
|
||||
--we have this offset so we can project what a movement would do
|
||||
local offset = coords or {x = 0, y = 0}
|
||||
local box = self:getGridBox()
|
||||
local cells = {}
|
||||
local pos = self:getGridPos()
|
||||
|
||||
for i = box.x + offset.x, box.x + box.w - 1 + offset.x do
|
||||
for j = box.y + offset.y, box.y + box.h - 1 + offset.y do
|
||||
table.insert(cells, {x = i, y = j})
|
||||
end
|
||||
for _, cell in ipairs(self:getCellShape()) do
|
||||
local adjustedCell = {}
|
||||
|
||||
adjustedCell.x = pos.x + cell.x - 1 + offset.x
|
||||
adjustedCell.y = pos.y + cell.y - 1 + offset.y
|
||||
table.insert(cells, adjustedCell)
|
||||
end
|
||||
|
||||
return cells
|
||||
end
|
||||
|
||||
function Entity:cellShapeFromBox(box)
|
||||
local cells = {}
|
||||
for i = 1, box.w do
|
||||
for j = 1, box.h do
|
||||
table.insert(cells, {x = i, y = j})
|
||||
io.write(" boop: " .. i .. ", " .. j)
|
||||
end
|
||||
end
|
||||
io.write("\n")
|
||||
return cells
|
||||
end
|
||||
|
||||
function Entity:getCellShape()
|
||||
return self.cellShape
|
||||
end
|
||||
|
||||
function Entity:getDrawBox()
|
||||
local drawPos = self:getDrawPos()
|
||||
return {x = drawPos.x, y = drawPos.y, w = self.spriteSize.w * drawScale, h = self.spriteSize.h * drawScale}
|
||||
|
|
@ -80,14 +99,14 @@ function Entity:draw()
|
|||
end
|
||||
|
||||
function Entity:canMove()
|
||||
if self.collision == "moveable" then
|
||||
if self:getCollision() == "moveable" then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function Entity:canPassOver()
|
||||
if self.collision == "none" then
|
||||
if self:getCollision() == "none" then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
|
|
|
|||
2
main.lua
2
main.lua
|
|
@ -5,12 +5,12 @@ class = require "libs/middleclass"
|
|||
Timer = require "libs/hump/timer"
|
||||
sfxr = require "libs/sfxrlua/sfxr"
|
||||
json = require "libs/json4lua/json/json"
|
||||
require "_debug_helpers"
|
||||
require "_helpers"
|
||||
require "input"
|
||||
require "color"
|
||||
require "room"
|
||||
require "shaders"
|
||||
require "_debug_helpers"
|
||||
|
||||
function love.load()
|
||||
_initDefaults()
|
||||
|
|
|
|||
36
room.lua
36
room.lua
|
|
@ -33,15 +33,15 @@ function Room:initialize(t)
|
|||
-- self.activeColors[color] = true
|
||||
-- end
|
||||
|
||||
for i=1, 30 do
|
||||
local x, y = randomPosition()
|
||||
local door = Door:new(x, y, self.colorsPlayerHas)
|
||||
table.insert(self.doors, door)
|
||||
-- for i=1, 30 do
|
||||
-- local x, y = randomPosition()
|
||||
-- local door = Door:new(x, y, self.colorsPlayerHas)
|
||||
-- table.insert(self.doors, door)
|
||||
|
||||
for color, active in pairs(self.activeColors) do
|
||||
self.collideables[color]["w: " .. x .. ", " .. y] = door
|
||||
end
|
||||
end
|
||||
-- for color, active in pairs(self.activeColors) do
|
||||
-- self.collideables[color]["w: " .. x .. ", " .. y] = door
|
||||
-- end
|
||||
-- end
|
||||
|
||||
for i=0, 5 do
|
||||
local x, y = randomPosition()
|
||||
|
|
@ -50,25 +50,25 @@ function Room:initialize(t)
|
|||
end
|
||||
end
|
||||
|
||||
for i = 0, 5 do
|
||||
local x, y = randomPosition()
|
||||
print(x, y)
|
||||
local c = randomColor()
|
||||
table.insert(self.switches[c], Switch:new(x, y, c))
|
||||
end
|
||||
-- for i = 0, 5 do
|
||||
-- local x, y = randomPosition()
|
||||
-- print(x, y)
|
||||
-- local c = randomColor()
|
||||
-- table.insert(self.switches[c], Switch:new(x, y, c))
|
||||
-- end
|
||||
|
||||
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, "house/processed/", "toilet") end
|
||||
if active then self.collideables[color]["n: " .. x .. ", " .. y] = Ass:new(x, y, color, "tech/processed/", "mac_smaller") end
|
||||
self.collideables[color]["n: " .. x .. ", " .. y]:getOccupiedCells()
|
||||
|
||||
local x, y = 7, 7
|
||||
if active then self.collideables[color]["n: " .. x .. ", " .. y] = Ass:new(x, y, color, "food/processed/", "beer_mug") end
|
||||
-- local x, y = 7, 7
|
||||
-- if active then self.collideables[color]["n: " .. x .. ", " .. y] = Ass:new(x, y, color, "food/processed/", "beer_mug") end
|
||||
|
||||
self.collideables[color]["fpp"] = Artifact:new(6, 6, color)
|
||||
-- self.collideables[color]["fpp"] = Artifact:new(6, 6, color)
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue