The tests revealed an interesting point:
SetErrorMode(2)
SetWindowTitle( "TestSprite" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 0, 1 )
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
LoadImage(1, "platf_2.png")
// goto variant_2
//////////////////////////////////////////////////////// create 400 sprite
variant_1:
tin_x=20
tin_y=20
dim fd [tin_x,tin_y]
for x=1 to tin_x
for y=1 to tin_y
fd [x,y] = CreateSprite(1)
// setspritescale(fd [x,y],1,1)
next
next
do
for x=1 to tin_x
for y=1 to tin_y
SetSpritePosition(fd [x,y],x*64,y*64)
// drawsprite (fd [x,y])
// SetSpritePosition(fd [x,y],-2000,-2000)
next
next
Print( "FPS: "+str(ScreenFPS()) + " Sprites: "+str(GetManagedSpriteCount())+" Drawcalls: "+str(GetManagedSpriteDrawCalls()) )
Sync()
if ( GetRawKeyState(27) ) then exit
loop
end
//////////////////////////////////////////////////////////// create 1 sprite
variant_2:
etno=CreateSprite(1)
SetSpritevisible(etno,1)
tin_x=20
tin_y=20
do
for x=1 to tin_x
for y=1 to tin_y
SetSpritePosition(etno,x*64,y*64)
drawsprite (etno)
SetSpritePosition(etno,-2000,-2000)
next
next
Print( "FPS: "+str(ScreenFPS()) + " Sprites: "+str(GetManagedSpriteCount())+" Drawcalls: "+str(GetManagedSpriteDrawCalls()) )
Sync()
if ( GetRawKeyState(27) ) then exit
loop
end
In both cases, the result is the same, and FPS is the same - then what is the point of creating 400 sprites and complicating the level creation code?
It is much easier to use the "Drawsprite" command - with it, you do not need to create separate sprites for each element of the level, and then delete them, as well as other troubles of building and displaying the level on the screen.
It turns out the "Drawsprite" team does not harm the FPS.
Explain to me if I'm wrong.