wowgit add -A!

This commit is contained in:
0x81c 2015-03-15 16:25:00 -04:00
parent 1156564fa2
commit 747a7b7b58
3 changed files with 44 additions and 25 deletions

View file

@ -4,6 +4,7 @@ function Entity:initialize(t)
self.x, self.y = t.x, t.y self.x, self.y = t.x, t.y
self.spriteSize = {w = t.sprite:getWidth(), h = t.sprite:getHeight()} self.spriteSize = {w = t.sprite:getWidth(), h = t.sprite:getHeight()}
self.size = {w = self.spriteSize.w / 16, h = self.spriteSize.h / 16} 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.color = Color:new(t.color)
self.collision = t.collision --"none", "moveable", "unmoveable" self.collision = t.collision --"none", "moveable", "unmoveable"
self.sprite = t.sprite self.sprite = t.sprite
@ -32,18 +33,36 @@ end
function Entity:getOccupiedCells(coords) function Entity:getOccupiedCells(coords)
--we have this offset so we can project what a movement would do --we have this offset so we can project what a movement would do
local offset = coords or {x = 0, y = 0} local offset = coords or {x = 0, y = 0}
local box = self:getGridBox()
local cells = {} local cells = {}
local pos = self:getGridPos()
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
for i = box.x + offset.x, box.x + box.w - 1 + offset.x do return cells
for j = box.y + offset.y, box.y + box.h - 1 + offset.y do 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}) table.insert(cells, {x = i, y = j})
io.write(" boop: " .. i .. ", " .. j)
end end
end end
io.write("\n")
return cells return cells
end end
function Entity:getCellShape()
return self.cellShape
end
function Entity:getDrawBox() function Entity:getDrawBox()
local drawPos = self:getDrawPos() local drawPos = self:getDrawPos()
return {x = drawPos.x, y = drawPos.y, w = self.spriteSize.w * drawScale, h = self.spriteSize.h * drawScale} 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 end
function Entity:canMove() function Entity:canMove()
if self.collision == "moveable" then if self:getCollision() == "moveable" then
return true return true
end end
return false return false
end end
function Entity:canPassOver() function Entity:canPassOver()
if self.collision == "none" then if self:getCollision() == "none" then
return true return true
end end
return false return false

View file

@ -5,12 +5,12 @@ class = require "libs/middleclass"
Timer = require "libs/hump/timer" Timer = require "libs/hump/timer"
sfxr = require "libs/sfxrlua/sfxr" sfxr = require "libs/sfxrlua/sfxr"
json = require "libs/json4lua/json/json" json = require "libs/json4lua/json/json"
require "_debug_helpers"
require "_helpers" require "_helpers"
require "input" require "input"
require "color" require "color"
require "room" require "room"
require "shaders" require "shaders"
require "_debug_helpers"
function love.load() function love.load()
_initDefaults() _initDefaults()

View file

@ -33,15 +33,15 @@ function Room:initialize(t)
-- self.activeColors[color] = true -- self.activeColors[color] = true
-- end -- end
for i=1, 30 do -- for i=1, 30 do
local x, y = randomPosition() -- local x, y = randomPosition()
local door = Door:new(x, y, self.colorsPlayerHas) -- local door = Door:new(x, y, self.colorsPlayerHas)
table.insert(self.doors, door) -- table.insert(self.doors, door)
for color, active in pairs(self.activeColors) do -- for color, active in pairs(self.activeColors) do
self.collideables[color]["w: " .. x .. ", " .. y] = door -- self.collideables[color]["w: " .. x .. ", " .. y] = door
end -- end
end -- end
for i=0, 5 do for i=0, 5 do
local x, y = randomPosition() local x, y = randomPosition()
@ -50,25 +50,25 @@ function Room:initialize(t)
end end
end end
for i = 0, 5 do -- for i = 0, 5 do
local x, y = randomPosition() -- local x, y = randomPosition()
print(x, y) -- print(x, y)
local c = randomColor() -- local c = randomColor()
table.insert(self.switches[c], Switch:new(x, y, c)) -- table.insert(self.switches[c], Switch:new(x, y, c))
end -- end
for color, active in pairs(self.activeColors) do for color, active in pairs(self.activeColors) do
local x, y = 6, 3 local x, y = 6, 3
-- if active then self.collideables[color]["n: " .. x .. ", " .. y] = Ass:new(x, y, color, "animals/processed/", "me_rach") end -- if active then self.collideables[color]["n: " .. x .. ", " .. y] = Ass:new(x, y, color, "animals/processed/", "me_rach") end
local x, y = 1, 1 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() self.collideables[color]["n: " .. x .. ", " .. y]:getOccupiedCells()
local x, y = 7, 7 -- local x, y = 7, 7
if active then self.collideables[color]["n: " .. x .. ", " .. y] = Ass:new(x, y, color, "food/processed/", "beer_mug") end -- 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 end