Skip to main content
gamedev.net
🔒 Locked

Blitz Basic array declaration order

Started by cheeky torcher Oct 11, 2006 at 7:58 AM 0 replies 900+ views
Original Post
cheeky torcher
cheeky torcher
I have got a weird problem with Blitz Basic arrays. I'm using BB 2D. I have an array that I use to remember where all the moveable or destroyable obstacles are in the game. Because of another error I was tracking down, I chose to print every array element over it's corresponding tile on the game board. I noticed that after my enemies moved, the array was getting some values that should not have been there. (I use 0,1 & 2 for now). I was seeing 3,10 & 11 as well. After much commenting out, I tracked the problem down to when the enemy used the sight routines. There is no code in these routines that even read from the obstacles array - very odd! However, and I don't know why I thought this - because I'm not that clever. I noticed that in my array declarations, the obstacles array comes after the check_vis array (used in the sight routines). See below, Dim terrain(50,50) Dim visibility(50,50) Dim player_sight(4,50,50) Dim main_map_display(50,50) Dim check_vis(50,50) Dim obstacles(50,50) Dim obstacles_hitpoints(50,50) so I changed the order to this, Dim obstacles(50,50) Dim obstacles_hitpoints(50,50) Dim terrain(50,50) Dim visibility(50,50) Dim player_sight(4,50,50) Dim main_map_display(50,50) Dim check_vis(50,50) and it wasn't a problem anymore. What's going on though? Is it a memory thing? I'm worried something else will break now, or it's probably dodgy code and I need to start looking for that. Any thoughts or ideas are most welcome!
cheeky torcher
cheeky torcher
Well, after some head scratching, I am not convinced by some code that another coder had written.

It is too big and unwieldy, doesn't really do the job I want it to do and I'm not convinced of it's stability.

I figure I will write the function exactly the way I want it, then start trawling back through my code if this doesn't fix the memory access errors.

Or upgrade to the next Blitz version - plus I think.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.