paulofmandown / rotLove

Roguelike Toolkit in Love. A Love2D/lua port of rot.js
http://paulofmandown.github.io/rotLove/
Other
258 stars 25 forks source link

add Grid and PointSet collection types #56

Closed airstruck closed 7 years ago

airstruck commented 7 years ago

With 30log gone, we can add some special-purpose collection types for improved performance and ease-of-use.

In this PR, PointSet and Grid are used in several places, making automated tests (and presumably application code) run a good bit faster, and simplifying calling code. There are other places they can be used as well.

If anyone has suggestions about the API for these two classes, as far as method names and so on, please let me know.

A quick before and after example:

-- before
for k,_ in pairs(litCells) do
    local parts=k:split(',')
    local x=tonumber(parts[1])
    local y=tonumber(parts[2])
    lightingCallback(x, y, litCells[k])
end
-- after
for _, x, y, value in litCells:each() do
    lightingCallback(x, y, value)
end

Sort of related, but not really: Line and Point were made internal to Bresenham, since nothing else was using them. Can be moved back out with other custom types later if needed.


Unrelated, but included anyway, are some changes to Brogue to make it behave more like the other dungeon generators with respect to doors and rooms.