;-------------------------------------------------------- ; DrawAllSprites Example ;--------------------------------------------------------- ; ========================================================= ; First Create an Image with a random circle pattern on it. ; ========================================================= Circle_Image=CreateBallImage(95) ; ========================================================= ; Create 25 sprites,and randomly position them around the screen ; ======================================================== For ThisSprite=1 To 25 ;Create a sprite ThisSprite=NewSprite(Rnd(GetScreenWidth()),_ Rnd(GetScreenHeight()),_ Circle_Image) ; Set sprite to automatically center it's image handle ; around the sprites axis. AutoCenterSpriteHandle ThisSprite,true Next ; Tell PB to limit speed of the program to 30 Frames (updates) ; per second or bellow SetFPS 30 ;----------------------------- ; Start of update loop ;----------------------------- Do ; Clear the Screen to Black 0 = rgb(0,0,0) Cls RGB(0,0,0) ; Tell PB to render All the Sprites now. DrawAllSprites ; Display a message in GREEN Ink RGB(0,255,0) Print "======================" Print "Rendering All Sprites" Print "======================" ; Display the screen and loop back to the DO statement to ; continue the loop Sync Loop ; ========================================================= ; This Function creates shaded ball image ; ========================================================= Function CreateBallImage(Size) ThisImage=NewImage(size,size) RenderPhongImage ThisIMage,size/2,size/2,RGB(128+Rnd(127),128+Rnd(127),128+Rnd(127)),200,255.0/(size/2) EndFunction ThisImage |