testing for array existence
BlitzPlus Forums/BlitzPlus Beginners Area/testing for array existence
| ||
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 |
| ||
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. |
| ||
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 |
| ||
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. |
| ||
If you only want to check if there are any bricks left, you could try this: If First Brick = null then EndGame() |
| ||
thanks everyone I used Gfks plan and everything is A OK now. |