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

Switch to numeric-indexed colors. #32

Closed airstruck closed 7 years ago

airstruck commented 7 years ago

This change switches from string-indexed colors for numeric-indexed.

{ r = 0, g = 0, b = 0 }
-- becomes
{ 0, 0, 0 }

ROT.Color is now used statically, as in rot.js, instead of needing to be instantiated (it can still be instantiated, but there's no reason to do that). Fixed some functions that were variadic in rot.js to also be variadic here, instead of taking a table-of-tables as a second argument.

Also converted the relevant Jasmine tests for Busted, and fixed things up so all tests pass. This was the main motivation for the change; I wanted to use something as close as possible to the existing tests. This change should also improve performance in some parts (no more pairs, shared cache) and makes colors slightly more convenient to define.

Kept colon instead of dot notation for symmetry with ROT.RNG, but could be changed to dot notation to reinforce the idea that it's static. That would also make it suitable as a prototype for color objects, since almost every function takes a color as its first parameter. Might be something to consider, anyway.

paulofmandown commented 7 years ago

This got merged as d834bf6c2409e1d2be81394c34cb4625488b1ab0