memory access violation

Blitz3D Forums/Blitz3D Programming/memory access violation

Rook Zimbabwe(Posted 2004) [#1]
Taking advice I changed my game pieces into sprites... The game works much faster (but still slow) and after about 12 - 17 moves I get a MEMORY ACCESS VIOLATION on renderworld.

I think it is because I am not cleaning the sprites off the screen correctly. Maybe.

What happens is the game tells you what color piece you get to put in a square. You put it. If you make 3 in a row L-R or U-D then you get points.

That is all I am trying to do for now. I have to understand what I did wrong before I get too fancy.

HELP!!! :]
-RZ


TomToad(Posted 2004) [#2]
The parameter in the Rand() comand is the highest possible value the Rand function will return. You add 1 to Rand(9) giving you numbers in the range of 2 - 10 and you are using the result to access an array that has been dimentioned with elements 0 - 9. Replace the 9 with 8 in your Rand statements should fix your problem.


TomToad(Posted 2004) [#3]
Oops, actually you should replace Rand(9)+1 with Rand(0,9) By replacing 8 with 9 like in my example will give you numbers in the range of 2-9 (unless of course that's what you want). Using Rand(0,9) will give you a number from 0 to 9.