Hi,
I do my first steps with the demo of Purebasic to find out if it
fits my requirements. I tried to play around with a game idea.
So I need a counter which runs in the background.
The filenames for the digits are count0-count9.bmp in the \images folder.
Procedure initCounter()
CreateSprite(20,18,22,0)
CreateSprite(21,18,22,0)
CreateSprite(22,18,22,0)
CreateSprite(23,18,22,0)
For i = 0 To 9
filename.s = "images\count" + Str(i) + ".bmp"
LoadSprite(i,filename,0)
Next
EndProcedure
That works fine. now I have the Counter Procedure
Procedure SetCounter()
timecount = 1440
While timecount > 0
counter.s = Str(timecount)
;counter.s = LSet(counter,3,"0")
count1 = Val(Mid(counter,1,1))
count2 = Val(Mid(counter,2,1))
count3 = Val(Mid(counter,3,1))
count4 = Val(Mid(counter,4,1))
CopySprite(count1,20,0)
CopySprite(count2,21,0)
CopySprite(count3,22,0)
CopySprite(count4,23,0)
DisplaySprite(20,510,550)
DisplaySprite(21,530,550)
DisplaySprite(22,550,550)
DisplaySprite(23,570,550)
timecount = timecount - 1
Delay(50)
Wend
EndProcedure
The procedure counts down from 1440 and splits
each digit of the number. so I have the sprite number
from my initCounter() and copy it to my created sprites
for each digit (20,21,22,23)
From the main part of the "game" (not yet really one
I call
initCounter;
tc_thread = CreateThread(@SetCounter(),0)
The thread is for counting in the background of the later game.
Thats the point. After Compiling the debugger says
at the line
DisplaySprite(23,570,550) in SetCounter()
"#Sprite Object not initialized"
Are The objects global or how do I make them global?
Thanks for your comments, maybe I totally wrong with it
but its my first try on game-programming
Martin Strojek
[url]mailto:martin@solutionworks.de[/url]
