Original Post
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!