testing for array existence

BlitzPlus Forums/BlitzPlus Beginners Area/testing for array existence

bryan970(Posted 2006) [#1]
Hi probably a dumb question but I just started using the product a couple weeks ago. and I was playing around with a breakout type game. Anyway I created my bricks as an array and I was wondering if there is a quick way to test if there are any bricks left.
something if bricks.items = o then
;level complete
else
updatearrayofbricks()
endif


Beaker(Posted 2006) [#2]
Are you storing the bricks in an array? You could just keep a count of how many bricks are left.

Consider using Types instead. Then you will have a quick way to test.


bryan970(Posted 2006) [#3]
good idea
I do have a bricks type
but it is just field x,y and frame I didn't thinking about adding a count to it but that would work.

thanks alot


GfK(Posted 2006) [#4]
You don't need to add a Count field. There are two ways you can do it.

1. Count each brick as you set them up.
2. Set them up first, then iterate through them all with For/Each to count them.

After that its just a matter of doing BrickCount = BrickCount - 1 each time you remove a brick.


b32(Posted 2006) [#5]
If you only want to check if there are any bricks left, you could try this:
If First Brick = null then EndGame()


bryan970(Posted 2006) [#6]
thanks everyone I used Gfks plan and everything is A OK now.