Post by tonyg on Apr 18, 2005 22:07:32 GMT
This is my first attempt at a very simple tilemap.
It only has the 1 layer, uses the same image for each tile, looks awful and only scrolls per tile.
It runs at about 75FPS (non-debug) although the getstat$ 'time per frame' always seems to be 0.
Initially, I removed all objects from the map array each loop and got about 66FPS.
The same effect in native B3D (2D code) takes 0ms for the loop and the 300*300 array is fully populated in 1 ms.
I understand the differences between single surface and 'normal' but I'm still slightly worried about starting with 75FPS just for the tilemap display. I was hoping for 3-5 layers and animated tiles which could drastically increase the number of objects.
There was some discussion on the Mappy forums about using Nsprite Pro. The general consensus was 2d in 3d singlesurface engines struggle with large numbers of objects so are poor with tilemaps.
Has anybody got any advice?
It only has the 1 layer, uses the same image for each tile, looks awful and only scrolls per tile.
It runs at about 75FPS (non-debug) although the getstat$ 'time per frame' always seems to be 0.
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
SeedRnd=MilliSecs()
Include "../sprite candy.bb"
cam1%=CreateCamera()
hud1%=HUD_Create(cam1)
resource1%=HUD_LoadImageResource("../media/image1.png",4+256)
baselayer1%=HUD_CreateLayer(hud1,resource1,0)
objectlayer1%=HUD_CreateLayer(hud1,resource1,1)
toplayer1%=HUD_CreateLayer(hud1,resource1,2)
Dim map(300,300)
Global cur_x, cur_y,x,y
While Not KeyHit(1)
Cls
x1=0 : y1=0
start_tile=MilliSecs()
check_keys
For x = cur_x To cur_x+19
For y = cur_y To cur_y+14
remove_objects()
map(x,y)=HUD_CreateImage(baselayer1,x1*32,y1*32,0,0,32,32,"","",0)
y1=y1+1
Next
y1=0
x1=x1+1
Next
end_tile=MilliSecs()
HUD_Update : RenderWorld
Text 0,10,"Loop time : " + (end_tile-start_tile)
Text 0,20,"x : " + x + " y: " + y
stat$=Left$(HUD_GetStats$(),67)
stat1$=Mid$(HUD_GetStats$(),67)
Text 0,30,stat$
Text 0,40,stat1$
Flip 0
Wend
End
Function check_keys()
If KeyHit(200)
If cur_y > 0 cur_y=cur_y-1
End If
If KeyHit(208)
If cur_y+14 < 298 cur_y=cur_y+1
EndIf
If KeyHit(205)
If cur_x+19 < 298 cur_x=cur_x+1
EndIf
If KeyHit(203)
If cur_x > 0 cur_x=cur_x-1
EndIf
End Function
Function remove_objects()
If x+20 < 300
If HUD_ObjectExists(map(x+20,y)) HUD_RemoveObject(map(x+20,y))
EndIf
If x-20 > -1
If HUD_ObjectExists(map(x-20,y)) HUD_RemoveObject(map(x-20,y))
EndIf
If y+15 < 300
If HUD_ObjectExists(map(x,y+15)) HUD_RemoveObject(map(x,y+15))
EndIf
If y-15 > -1
If HUD_ObjectExists(map(x,y-15)) HUD_RemoveObject(map(x,y-15))
EndIf
If HUD_ObjectExists(map(x,y)) HUD_RemoveObject(map(x,y))
End Function
Initially, I removed all objects from the map array each loop and got about 66FPS.
The same effect in native B3D (2D code) takes 0ms for the loop and the 300*300 array is fully populated in 1 ms.
I understand the differences between single surface and 'normal' but I'm still slightly worried about starting with 75FPS just for the tilemap display. I was hoping for 3-5 layers and animated tiles which could drastically increase the number of objects.
There was some discussion on the Mappy forums about using Nsprite Pro. The general consensus was 2d in 3d singlesurface engines struggle with large numbers of objects so are poor with tilemaps.
Has anybody got any advice?