I have finally found out what is going on here. This is very interesting; I've never heard of anything like this before.
I've isolated the problem in the code below.
sync on
sync rate 60
load image "image", 1, 1
load bitmap "bitmap", 1
get image 2, 0, 0, 100, 100
set current bitmap 0
imagenumber=2
walls=4
for a=2 to walls
sprite a, rnd(800), rnd(600), imagenumber
set sprite diffuse a, 255, 0, 0
next a
do
cls
for a=2 to walls
sprite a, sprite x(a), sprite y(a), sprite image(a)
next a
sprite 1, 400, 300, 1
sync
loop
"Image" should be a 100X100 image, and the bitmap should be at least that size. The set sprite diffuse command is used here so you can tell the difference between sprite number one and the "test sprites".
When you run the program like this, things should work fine. Sprite number one should be visible. No matter how high "walls" is set, nothing odd will befall sprite 1.
Then set variable "imagenumber" to 2. When you run the program again, sprite number one will constantly vanish and reappear briefly. In fact, if "walls" is set to anything above 2, you probably won't see sprite 1 at all.
It seems that all along my problem was coming from making sprites out of images which I had cut from bitmaps.
If anyone knows the technicalities behind this phenomenom, or how to remedy it, please tell me.
Note : You should find that "Sprite exist(1)" will return 1 and "Sprite hidden(1)" will return 0, even when sprite 1 seems to have disappeared.