Hi Everyone!
Below is a very simple side scrolling application that displays a star field, places a sprite on that star field and then scrolls the star field. At some points while the application is running the sprite disappears leaving only the star field visible. After a brief period of time the sprite may reappear.
Rem Project: Dark Basic Pro Project
Rem Created: Friday, February 18, 2011
Rem ***** Main Source File *****
set display mode 800, 600, 32
sync on
sync rate 30
backdrop off
set image colorkey 255, 0, 255
shipX = 100
shipY = 200
load image "media\fighter64.bmp", 1
sprite 1, shipX, shipY, 1
set sprite 1, 0, 1
createStarField(1000)
do
cls 0
showStarField()
ch$ = inkey$()
if ch$ = "z" then inc shipY
if ch$ = "x" then dec shipY
sprite 1, shipX, shipY, 1
sync
loop
end
Rem ***** Included Source File *****
type Star
x as integer
y as integer
speed as integer
brightness as integer
endtype
function createStarField(maxStars as integer)
global dim stars(maxStars) as Star
for i = 1 to maxStars
stars(i).x = rnd(screen width())
stars(i).y = rnd(screen height())
stars(i).speed = rnd(5) + 1
stars(i).brightness = 50 * stars(i).speed
next
endfunction
function showStarField()
for i = 1 to array count(stars(0))
dec stars(i).x, stars(i).speed
if stars(i).x < 0
stars(i).x = screen width()
stars(i).y = rnd(screen height())
stars(i).brightness = 50 * stars(i).speed
endif
ink rgb(stars(i).brightness, stars(i).brightness, stars(i).brightness), 0
dot stars(i).x, stars(i).y
next
endfunction
The application exhibits this behaviour when compiled and run on Windows 7 64-bit. I haven't seen the problem when running it on Windows XP Pro but it does run incredibly slowly. On Windows 7 it runs at a good speed.
Does anyone have any suggestions?
Thanks!