ID:152413
 
What do you think would be the most efficient way to implement a dot matrix display in BYOND?


For those of you who don't know, a dot matrix display is something such as this:

o•oo•o••••o•••o•oooo
o•o•oo•oo•oo•oo•oooo
o••ooo•oo•oo•oo•oooo
o•o•oo•oo•oo•oo•oooo
o•oo•o••••o•••o••••o


Which would be (in DM),

var/list/koil = list(\
list(0,1,0,0,1,0,1,1,1,1,0,1,1,1,0,1,0,0,0,0),\
list(0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0),\
list(0,1,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0),\
list(0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0),\
list(0,1,0,0,1,0,1,1,1,1,0,1,1,1,0,1,1,1,1,0))
I'm assuming you want to be able to display arbitrary text on it, like a ticker display or something? If so, Gughunter has a library that might help (http://developer.byond.com/hub/Gughunter/Marqueelibrary).
In response to Crispy
Not really.

I had wanted to use it to make a game with precise pixelized movement.

I've done it before, where I made a 9x6 map that I could place pixels on, and I had functions that would tell me if a pixel was on or off, and what color it was, but I would get "Maximum number of RSC entries exceeded" after I played a small test game for too long.
So if you're trying to do precise pixel movement, are you trying to tell whether each pixel is transparent or not within the actual icon? O_o

-Exophus
In response to Exophus
In my past implementation of this, I checked for collision like this:

mob
Move(loc)
..() // assuming I had all the visual movement set up
for(var/obj/pxl/P in src.pixels)
if(pxlOn(P.pxlX+((dir == 4) ? (1) : (dir == 8) ? (-1) : (0), P.pxlY+((dir == 1) ? (1) : (dir == 2) ? (-1) : (0)))
collision()
In response to Koil
Well no wonder you were running into limits if you were doing it like that. =)

Doing per-pixel collision isn't the best way to go about it in BYOND, in my opinion. Stick to tile-based density if you can; or define dense areas using rectangles or circles or whatever suits your game best, and then test for collisions mathematically.
In response to Koil
Koil wrote:
Not really.

I had wanted to use it to make a game with precise pixelized movement.

I've done it before, where I made a 9x6 map that I could place pixels on, and I had functions that would tell me if a pixel was on or off, and what color it was, but I would get "Maximum number of RSC entries exceeded" after I played a small test game for too long.

you'd probably be better off using a separate DM program to extract all of the data for the icons in your game. by data i mean the information about which pixels are on or off. then you can hardcode that data into your game which does make it a hassle to add new icons, but its much faster than using lots of icon operations at run time.

also, there are better ways to store strings of bits than using 33 lists per icon. you can encode each row of the icon in a 32-bit integer and use bitwise operators to extract each bit as needed, so you'd only need one list with 32 numbers in it per icon.
In response to OneFishDown
yeah but that leaves the 33rd piece