Hi,
How about
// Project: Test1
// Created: 2014-11-28 by Janbo
// set window properties
SetWindowTitle( "Test1" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate(0,0)
SourceImage as integer[2]
SourceImage[0]=CreateImageColor(255,0,0,255)
SourceImage[1]=CreateImageColor(0,255,0,255)
SourceImage[2]=CreateImageColor(0,0,255,255)
SourceSpriteID=createsprite(0)
setspritesize(SourceSpriteID,32,32)
type TileData
Solid
ImageID
SomethingElse
endtype
TileSize=32
Tile as TileData[500,500]
for x=1 to Tile.length-1
for y=1 to Tile[0].length-1
if random(1,2)=1
Tile[x,y].Solid=1
Tile[x,y].ImageID=SourceImage[random(0,2)]
endif
next y
next x
ViewZoom#=0.5
ViewSpeed#=5
do
print("Sprites: "+str(GetManagedSpriteDrawCalls()))
print("Draws: "+str(Counter))
Print("Frames: "+str(ScreenFPS(),2))
if GetRawKeyState(87) then ViewPosY#=ViewPosY#-ViewSpeed#
if GetRawKeyState(83) then ViewPosY#=ViewPosY#+ViewSpeed#
if GetRawKeyState(65) then ViewPosX#=ViewPosX#-ViewSpeed#
if GetRawKeyState(68) then ViewPosX#=ViewPosX#+ViewSpeed#
setviewzoom(ViewZoom#)
SetViewOffset(ViewPosX#,ViewPosY#)
ViewLeft=trunc(ScreenToWorldX(GetScreenBoundsLeft())/TileSize)
ViewTop=trunc(ScreenToWorldY(GetScreenBoundsTop())/TileSize)
ViewRight=trunc(ScreenToWorldX(GetScreenBoundsRight())/TileSize)
ViewBottom=trunc(ScreenToWorldY(GetScreenBoundsBottom())/TileSize)
if ViewLeft<1 then ViewLeft=1
if ViewTop<1 then ViewTop=1
if ViewLeft>Tile.length-1 then ViewLeft=Tile.length-1
if ViewTop>Tile[0].length-1 then ViewTop=Tile[0].length-1
if ViewRight<1 then ViewRight=1
if ViewBottomClamp<1 then ViewBottomClamp=1
if ViewRight>Tile.length-1 then ViewRight=Tile.length-1
if ViewBottom>Tile[0].length-1 then ViewBottom=Tile[0].length-1
Counter=0
for TileX=ViewLeft to ViewRight
for TileY=ViewTop to ViewBottom
if Tile[TileX,TileY].Solid<>0
setspriteposition(SourceSpriteID,TileX*TileSize,TileY*TileSize)
setspriteimage(SourceSpriteID,Tile[TileX,TileY].ImageID)
drawsprite(SourceSpriteID)
Counter=Counter+1
endif
next TileY
next TileX
Sync()
loop
Im pretty sure this fit's your requirements.
Made the code for you in a vew minutes..
What I did is.. I
draw the same sprite at the desired position, but only within the borders.
You will notice the frame boost if you zoom in or get out of the map.
And just ask, if you have anny questions.