Can someone compile this for me, please? Debug off. Thanks!
Can someone compile this for me, please? Debug off. Thanks!
; ***********
; SPRITE TEST
; ***********
Gosub set_up
Gosub man_loop; MAIN LOOP
End
; ***********
; SUBROUTINES
; ***********
; 1 SET UP
set_up:
Gosub set_data
Gosub set_hardware
Gosub set_sprites
Return
; 1.1 Data
set_data:
Gosub set_constants
Gosub set_variables
Gosub set_lists
Declare spr_speed()
Return
; 1.1.1 CONSTANTS
set_constants:
#scr_width .l=1024
#scr_height .l= 768
#scr_depth .l= 32
#scr_freq .l= 60
#scr_hor_centre.l=#scr_width /2; SCREEN HORIZONTAL CENTRE
#scr_ver_centre.l=#scr_height/2
red .l=RGB(255, 0, 0)
green .l=RGB( 0,255, 0)
blue .l=RGB( 0, 0,255)
white .l=RGB(255,255,255)
purple .l=RGB(255, 0,255)
#ball .l= 1
#square .l= 2
#triangle .l= 3
#max_sprites .l=1000
#spd_spawn .l= 500; SPEED SPAWN
#spr_size .l= 32; SPRITE SIZE
#second .l=1000
Return
; 1.1.2 VARIABLES
set_variables:
ths_image .l; THIS IMAGE
num_sprites.l
lst_spawn .l; LAST SPAWN
num_frames .l
lst_second .l
fps .l
Return
; 1.1.3 LISTS and ARRAYS
set_lists:
Structure spr_info; SPRITE INFO
id .l
hor_position.l
ver_position.l
hor_speed .l
ver_speed .l
EndStructure
NewList spr.spr_info(); SPRITE
Dim image.l(3)
Return
; 1.2 HARDWARE
set_hardware:
LoadFont(#PB_Any,"fixedsys",16); The ID isn't needed!
InitSprite()
InitKeyboard()
SetRefreshRate(#scr_freq)
OpenScreen(#scr_width,#scr_height,#scr_depth,"Sprite test")
Return
; 1.3 IMAGES
set_sprites:
For ths_image=#ball To #triangle
image(ths_image)=CreateSprite(#PB_Any,32,32)
StartDrawing(SpriteOutput(image(ths_image)))
Select ths_image
Case #ball
Circle(15,15,15,red)
Case #square
Box(0,0,32,32,green)
Case #triangle
LineXY(15, 0, 0,31,purple)
LineXY( 0,31,31,31,purple)
LineXY(31,31,15, 0,purple)
FillArea(15,2,purple,purple)
EndSelect
StopDrawing()
Next ths_image
Return
; 2 MAIN LOOP
man_loop:
lst_second=ElapsedMilliseconds()
Repeat
ClearScreen(0,0,0)
Gosub spn_sprites; SPAWN SPRITES
Gosub drw_sprites; DRAW SPRITES
Gosub clc_fps ; CALCULATE FPS
Gosub prt_panel ; PRINT PANEL
FlipBuffers()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
Return
; 2.1 SPAWN SPRITES
spn_sprites:
If num_sprites<#max_sprites
If ElapsedMilliseconds()-lst_spawn>=#spd_spawn
lst_spawn=ElapsedMilliseconds()
num_sprites+1
LastElement(spr())
AddElement(spr())
spr()\id=CopySprite(image(Random(2)+1),#PB_Any)
spr()\hor_position=#scr_hor_centre
spr()\ver_position=#scr_ver_centre
spr()\hor_speed=spr_speed()
spr()\ver_speed=spr_speed()
EndIf
EndIf
Return
; 2.2 DRAW SPRITES
drw_sprites:
ForEach spr()
spr()\hor_position+spr()\hor_speed
spr()\ver_position+spr()\ver_speed
DisplayTransparentSprite(spr()\id,spr()\hor_position,spr()\ver_position)
If spr()\hor_position<0 Or spr()\hor_position> #scr_width-#spr_size
spr()\hor_speed=-spr()\hor_speed
EndIf
If spr()\ver_position<0 Or spr()\ver_position>#scr_height-#spr_size
spr()\ver_speed=-spr()\ver_speed
EndIf
Next
Return
; 2.3 CALCULATE FPS
clc_fps:
num_frames+1
If ElapsedMilliseconds()-lst_second>=#second
fps=num_frames
num_frames=0
lst_second+#second
EndIf
Return
; 2.4 PRINT PANEL
prt_panel:
StartDrawing(ScreenOutput())
DrawingMode(1)
DrawingFont(FontID())
FrontColor(255,255,255)
Locate(0, 0)
DrawText("SCREEN WIDTH :"+RSet(Str( #scr_width),5))
Locate(0,12)
DrawText("SCREEN HEIGHT:"+RSet(Str(#scr_height),5))
Locate(0,24)
DrawText("SCREEN DEPTH :"+RSet(Str( #scr_depth),5))
Locate(0,36)
DrawText("N. OF SPRITES:"+RSet(Str(num_sprites),5))
Locate(0,48)
DrawText("PROGRAM FPS :"+RSet(Str( fps),5))
StopDrawing()
Return
; *********
; FUNCTIONS
; *********
Procedure.l spr_speed()
result.l
result=Random(5)+1
If Random(1)
result=-result
EndIf
ProcedureReturn result
EndProcedure
; SPRITE TEST
; ***********
Gosub set_up
Gosub man_loop; MAIN LOOP
End
; ***********
; SUBROUTINES
; ***********
; 1 SET UP
set_up:
Gosub set_data
Gosub set_hardware
Gosub set_sprites
Return
; 1.1 Data
set_data:
Gosub set_constants
Gosub set_variables
Gosub set_lists
Declare spr_speed()
Return
; 1.1.1 CONSTANTS
set_constants:
#scr_width .l=1024
#scr_height .l= 768
#scr_depth .l= 32
#scr_freq .l= 60
#scr_hor_centre.l=#scr_width /2; SCREEN HORIZONTAL CENTRE
#scr_ver_centre.l=#scr_height/2
red .l=RGB(255, 0, 0)
green .l=RGB( 0,255, 0)
blue .l=RGB( 0, 0,255)
white .l=RGB(255,255,255)
purple .l=RGB(255, 0,255)
#ball .l= 1
#square .l= 2
#triangle .l= 3
#max_sprites .l=1000
#spd_spawn .l= 500; SPEED SPAWN
#spr_size .l= 32; SPRITE SIZE
#second .l=1000
Return
; 1.1.2 VARIABLES
set_variables:
ths_image .l; THIS IMAGE
num_sprites.l
lst_spawn .l; LAST SPAWN
num_frames .l
lst_second .l
fps .l
Return
; 1.1.3 LISTS and ARRAYS
set_lists:
Structure spr_info; SPRITE INFO
id .l
hor_position.l
ver_position.l
hor_speed .l
ver_speed .l
EndStructure
NewList spr.spr_info(); SPRITE
Dim image.l(3)
Return
; 1.2 HARDWARE
set_hardware:
LoadFont(#PB_Any,"fixedsys",16); The ID isn't needed!
InitSprite()
InitKeyboard()
SetRefreshRate(#scr_freq)
OpenScreen(#scr_width,#scr_height,#scr_depth,"Sprite test")
Return
; 1.3 IMAGES
set_sprites:
For ths_image=#ball To #triangle
image(ths_image)=CreateSprite(#PB_Any,32,32)
StartDrawing(SpriteOutput(image(ths_image)))
Select ths_image
Case #ball
Circle(15,15,15,red)
Case #square
Box(0,0,32,32,green)
Case #triangle
LineXY(15, 0, 0,31,purple)
LineXY( 0,31,31,31,purple)
LineXY(31,31,15, 0,purple)
FillArea(15,2,purple,purple)
EndSelect
StopDrawing()
Next ths_image
Return
; 2 MAIN LOOP
man_loop:
lst_second=ElapsedMilliseconds()
Repeat
ClearScreen(0,0,0)
Gosub spn_sprites; SPAWN SPRITES
Gosub drw_sprites; DRAW SPRITES
Gosub clc_fps ; CALCULATE FPS
Gosub prt_panel ; PRINT PANEL
FlipBuffers()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
Return
; 2.1 SPAWN SPRITES
spn_sprites:
If num_sprites<#max_sprites
If ElapsedMilliseconds()-lst_spawn>=#spd_spawn
lst_spawn=ElapsedMilliseconds()
num_sprites+1
LastElement(spr())
AddElement(spr())
spr()\id=CopySprite(image(Random(2)+1),#PB_Any)
spr()\hor_position=#scr_hor_centre
spr()\ver_position=#scr_ver_centre
spr()\hor_speed=spr_speed()
spr()\ver_speed=spr_speed()
EndIf
EndIf
Return
; 2.2 DRAW SPRITES
drw_sprites:
ForEach spr()
spr()\hor_position+spr()\hor_speed
spr()\ver_position+spr()\ver_speed
DisplayTransparentSprite(spr()\id,spr()\hor_position,spr()\ver_position)
If spr()\hor_position<0 Or spr()\hor_position> #scr_width-#spr_size
spr()\hor_speed=-spr()\hor_speed
EndIf
If spr()\ver_position<0 Or spr()\ver_position>#scr_height-#spr_size
spr()\ver_speed=-spr()\ver_speed
EndIf
Next
Return
; 2.3 CALCULATE FPS
clc_fps:
num_frames+1
If ElapsedMilliseconds()-lst_second>=#second
fps=num_frames
num_frames=0
lst_second+#second
EndIf
Return
; 2.4 PRINT PANEL
prt_panel:
StartDrawing(ScreenOutput())
DrawingMode(1)
DrawingFont(FontID())
FrontColor(255,255,255)
Locate(0, 0)
DrawText("SCREEN WIDTH :"+RSet(Str( #scr_width),5))
Locate(0,12)
DrawText("SCREEN HEIGHT:"+RSet(Str(#scr_height),5))
Locate(0,24)
DrawText("SCREEN DEPTH :"+RSet(Str( #scr_depth),5))
Locate(0,36)
DrawText("N. OF SPRITES:"+RSet(Str(num_sprites),5))
Locate(0,48)
DrawText("PROGRAM FPS :"+RSet(Str( fps),5))
StopDrawing()
Return
; *********
; FUNCTIONS
; *********
Procedure.l spr_speed()
result.l
result=Random(5)+1
If Random(1)
result=-result
EndIf
ProcedureReturn result
EndProcedure
-
dracflamloc
- Addict

- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
Results:
1024x768x32
More than 350 sprites in screen
FPS: 60
my pc: XP2400,512 RAM, ATI RADEON 9200 (128MB)
1024x768x32
More than 350 sprites in screen
FPS: 60
my pc: XP2400,512 RAM, ATI RADEON 9200 (128MB)
PB 6.21 beta, PureVision User
fist make it bugfree and accoriding to 3.93 syntax
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
I assume you want to benchmark final compilation before buying. Seems reasonable.
Send me your email address and I'll reply with the exe.
Cleaned up code:
Send me your email address and I'll reply with the exe.
Cleaned up code:
Code: Select all
; ***********
; SPRITE TEST
; ***********
Gosub set_up
Gosub man_loop; MAIN LOOP
End
; ***********
; SUBROUTINES
; ***********
; 1 SET UP
set_up:
Gosub set_data; Actual constant declarations must be above actual use, so these too.
Gosub set_hardware
Gosub set_sprites
Return
; 1.1 Data
set_data:
Gosub set_constants
Gosub set_variables
Gosub set_lists
Declare spr_speed()
Return
; 1.1.1 CONSTANTS
set_constants:
#scr_width =1024
#scr_height = 768
#scr_depth = 32
#scr_freq = 60
#scr_hor_centre=#scr_width /2; SCREEN HORIZONTAL CENTRE
#scr_ver_centre=#scr_height/2
red =RGB(255, 0, 0)
green =RGB( 0,255, 0)
blue =RGB( 0, 0,255)
white =RGB(255,255,255)
purple =RGB(255, 0,255)
#ball = 1
#square = 2
#triangle = 3
#max_sprites =1000
#spd_spawn = 500; SPEED SPAWN
#spr_size = 32; SPRITE SIZE
#second =1000
Return
; 1.1.2 VARIABLES
set_variables:
ths_image .l; THIS IMAGE
num_sprites.l
lst_spawn .l; LAST SPAWN
num_frames .l
lst_second .l
fps .l
Return
; 1.1.3 LISTS and ARRAYS
set_lists:
Structure spr_info; SPRITE INFO
id .l
hor_position.l
ver_position.l
hor_speed .l
ver_speed .l
EndStructure
NewList spr.spr_info(); SPRITE
Dim image.l(3)
Return
; 1.2 HARDWARE
set_hardware:
LoadFont(#PB_Any,"fixedsys",16); The ID isn't needed!
InitSprite()
InitKeyboard()
SetRefreshRate(#scr_freq)
OpenScreen(#scr_width,#scr_height,#scr_depth,"Sprite test")
Return
; 1.3 IMAGES
set_sprites:
For ths_image=#ball To #triangle
image(ths_image)=CreateSprite(#PB_Any,32,32)
StartDrawing(SpriteOutput(image(ths_image)))
Select ths_image
Case #ball
Circle(15,15,15,red)
Case #square
Box(0,0,32,32,green)
Case #triangle
LineXY(15, 0, 0,31,purple)
LineXY( 0,31,31,31,purple)
LineXY(31,31,15, 0,purple)
FillArea(15,2,purple,purple)
EndSelect
StopDrawing()
Next ths_image
Return
; 2 MAIN LOOP
man_loop:
lst_second=ElapsedMilliseconds()
Repeat
ClearScreen(0,0,0)
Gosub spn_sprites; SPAWN SPRITES
Gosub drw_sprites; DRAW SPRITES
Gosub clc_fps ; CALCULATE FPS
Gosub prt_panel ; PRINT PANEL
FlipBuffers(0)
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
Return
; 2.1 SPAWN SPRITES
spn_sprites:
If num_sprites<#max_sprites
If ElapsedMilliseconds()-lst_spawn>=#spd_spawn
lst_spawn=ElapsedMilliseconds()
num_sprites+1
LastElement(spr())
AddElement(spr())
spr()\id=CopySprite(image(Random(2)+1),#PB_Any)
spr()\hor_position=#scr_hor_centre
spr()\ver_position=#scr_ver_centre
spr()\hor_speed=spr_speed()
spr()\ver_speed=spr_speed()
EndIf
EndIf
Return
; 2.2 DRAW SPRITES
drw_sprites:
ForEach spr()
spr()\hor_position+spr()\hor_speed
spr()\ver_position+spr()\ver_speed
DisplayTransparentSprite(spr()\id,spr()\hor_position,spr()\ver_position)
If spr()\hor_position<0 Or spr()\hor_position> #scr_width-#spr_size
spr()\hor_speed=-spr()\hor_speed
EndIf
If spr()\ver_position<0 Or spr()\ver_position>#scr_height-#spr_size
spr()\ver_speed=-spr()\ver_speed
EndIf
Next
Return
; 2.3 CALCULATE FPS
clc_fps:
num_frames+1
If ElapsedMilliseconds()-lst_second>=#second
fps=num_frames
num_frames=0
lst_second+#second
EndIf
Return
; 2.4 PRINT PANEL
prt_panel:
StartDrawing(ScreenOutput())
DrawingMode(1)
DrawingFont(FontID())
FrontColor(255,255,255)
Locate(0, 0)
DrawText("SCREEN WIDTH :"+RSet(Str( #scr_width),5))
Locate(0,12)
DrawText("SCREEN HEIGHT:"+RSet(Str(#scr_height),5))
Locate(0,24)
DrawText("SCREEN DEPTH :"+RSet(Str( #scr_depth),5))
Locate(0,36)
DrawText("N. OF SPRITES:"+RSet(Str(num_sprites),5))
Locate(0,48)
DrawText("PROGRAM FPS :"+RSet(Str( fps),5))
StopDrawing()
Return
; *********
; FUNCTIONS
; *********
Procedure.l spr_speed()
result.l
result=Random(5)+1
If Random(1)
result=-result
EndIf
ProcedureReturn result
EndProcedure
; ExecutableFormat=
; DisableDebugger
; EOF
Last edited by GedB on Tue Mar 08, 2005 5:25 pm, edited 1 time in total.
dracflamloc - Because the demo version does not compile with debug off and I need to know if there is a real speed-up when it is turned off. The idea was for someone to send the executable back to me, though... I guess I wasn't very clear.
zikitrake - Thanks for the info; I was expecting to get more sprites on that kind of card, though...
blueznl - It is bug-free as of 3.92. I confess I haven't downloaded the new version.
dagcrack - Yes! I f***ed up good by not enabling code and not disabling emoticons! I am kind of new in this forum. Sorry.
Gedb - Yes, that was the idea. I also thought that my address could be right-clicked from my nick or something, but I see that's not the case. Thanks for your offer and for cleaning up the code (it would be nice and tidy if I had turned code on in the post!) Also, the final Locate() should be (0,48) if it wasn't for the smilie! Could you please fix that? Thanks again. My address is:
fmcpma@hotmail.com
thefool - Will do!
zikitrake - Thanks for the info; I was expecting to get more sprites on that kind of card, though...
blueznl - It is bug-free as of 3.92. I confess I haven't downloaded the new version.
dagcrack - Yes! I f***ed up good by not enabling code and not disabling emoticons! I am kind of new in this forum. Sorry.
Gedb - Yes, that was the idea. I also thought that my address could be right-clicked from my nick or something, but I see that's not the case. Thanks for your offer and for cleaning up the code (it would be nice and tidy if I had turned code on in the post!) Also, the final Locate() should be (0,48) if it wasn't for the smilie! Could you please fix that? Thanks again. My address is:
fmcpma@hotmail.com
thefool - Will do!
fmcpma wrote: zikitrake - Thanks for the info; I was expecting to get more sprites on that kind of card, though...
I stopped the program when it arrived at 320 FPS. now I have waited for the 1000 sprites and the result stays: 60FPS.
PB 6.21 beta, PureVision User
sprite test
Hi - using the latest version of the program at 1280 x
1024 and flipbuffer(0) I got speeds of:
100 sprites - 245 fps
500 sprites - 146 fps
1000 sprites - 105 fps
Using not as many sprites, say 20, is there an easy way to check for collisions between all of them?
Or do you have to check (1,2-20),(2,3-20),,,(19,20)?
Thought a collision result might give the two sprite numbers that collided.
Thanks for any help>
Bill Nee
'
1024 and flipbuffer(0) I got speeds of:
100 sprites - 245 fps
500 sprites - 146 fps
1000 sprites - 105 fps
Using not as many sprites, say 20, is there an easy way to check for collisions between all of them?
Or do you have to check (1,2-20),(2,3-20),,,(19,20)?
Thought a collision result might give the two sprite numbers that collided.
Thanks for any help>
Bill Nee
'



