Two unassociated questions

BlitzMax Forums/BlitzMax Beginners Area/Two unassociated questions

jasonmiceli(Posted 2007) [#1]
Hi all - I have two completely disparate questions:

1. I want to create a minigame of sorts - the basics of the minigame are there's a blob on the screen... then you're given a series of smaller blobs to place onto the larger blob. Victory is determined by what percentage of the larger blob is "covered" by the smaller blobs... thusly, how can I determine how many pixels are still showing through? Or more basically, how can I determine if the bottom blob is completely covered or not??

2. What's the best way to simply swap two items in a list? I know how to ADD to the beginning or end of a list, and how to delete an item, but there doesn't seem to be a command to MOVE an item to beginning / end - at least none that I could find. I hate the documentation in BlitzMax - Blitz3D documentation was SOOO much better... so I'm sorry if this is an obvious question / answer...


Thx all! GAME ON!!


rdodson41(Posted 2007) [#2]
2. If you want to move it, remove it and then add it back where you want it. You can use ListAddFirst or ListAddLast or use the member methods InsertBefore and InsertAfter to add it back where you want.


tonyg(Posted 2007) [#3]
1) An array of pixels matching the blob which are turned 'off' when covered and a count of the remainder kept.
2) Move a link to the top/bottom is removelist then listaddlast/listaddfirst. To swap two items you might want to look at InsertAfterLink and InsertBeforeLink and then remove again. Alternatively look at the list.sort method in linkedlist.bmx which might be used.


jasonmiceli(Posted 2007) [#4]
Tonyg - to do what you suggest for #1 I presume I somehow need to convert the image to pixels, read those pixels into an array, and then I should be able to compare pixel to pixel "collision" in order to turn on/off items in the array as needed?


jasonmiceli(Posted 2007) [#5]
On #2, by removing and then readding, how do you maintain all the meta-data contained within the items type fields? Must store them in temporary variables until you can add the new one to the end of the list?


tonyg(Posted 2007) [#6]
1) Yep, there might be an easier way if the blobs are not random.
2) Just add the same object to the list (first, last, insert whatever) and then remove the original. These are just pointers to the object that go on the list not the object themselves.


jasonmiceli(Posted 2007) [#7]
Ahhh - gotcha on #2 - perfect! The rain has gone ;)


On #1, let's suppose the blobs are not random but rectangles (drawrect) - how does that change / simplify things??...


tonyg(Posted 2007) [#8]
It's then a simple case of matching the draw handle with the big blob array and setting those pixels as overlapped. If the blobs were 'curly' then you'd need to check each pixel for being turned on.
<edit> Just read that back and it's as clear as mud.
If you're working on a pixel level you can check a rect overlap with a for/next loop starting from the draw position of the rect. If you're looking at something like Tetris you don't need to work at a pixel level either.
For non-rect you'd need to check each pixel from one array to the other array.