Shooting Snowballs
Blitz3D Forums/Blitz3D Beginners Area/Shooting Snowballs
| ||
I'm making a game where you throw snowballs at the enemy. Its not done yet so some things (like the Types) are not really important right now. Any way I've set up some code to fire a snowball every time the left mouse button is pressed. When I fire about 6-8 snowballs it comes up with the error "Illegal memory address" Can some one tell me what i'm doing wrong?! Code: Last edited 2012 |
| ||
First - put debug mode on - that should help you with finding where the error is. I would guess however it is because you are exceeding the bounds of the array "bullet". Notice that when the mouse is pressed you increment the bullet's index "t" but you never do anything to prevent it going outside the maximum size of the array (25 in this case). |
| ||
I've updated your code a bit. I would suggest changing from using an array for bullets to using types. It's much easier to manage in my opinion. Read through this as I've commented all the lines I added or changed. (I also had to comment out the media as I did not have it) You can of course put each process into it's own function to greatly simplify the code. I've also added the ability to count each bullet and delete it when it gets too far off the screen. |
| ||
Edit: Any suggestions on reloading? Last edited 2012 |
| ||
I'll just make a new post. |