You could also use memory banks if you want:
Graphics 800,600,32,2
Type Test
Field w%,h%
Field arr2D% ; this holds our "array"
End Type
Local t.Test = New Test
t\w = 20
t\h = 15
t\arr2D = CreateBank(t\w * t\h * 4) ; create bank, the "array"
; fill it with random data
For y = 0 To t\h - 1
For x = 0 To t\w - 1
offset = (x + y * t\w) * 4
PokeInt t\arr2D, offset, Rand(255)
Next
Next
Repeat
Cls
; draw our data as tilemap
For y = 0 To t\h - 1
For x = 0 To t\w - 1
offset = (x + y * t\w) * 4
c = PeekInt(t\arr2D, offset)
Color c,c,c
Rect x*16, y*16, 16,16
Next
Next
; FPS, of course!
Color 255,255,255
Text 350,10,FPS()
Flip
Until KeyDown(1)
; Delete stuff
FreeBank t\arr2D
Delete t
End
Global FPS_i, FPS_temp, FPS_time
Function FPS()
ctime = MilliSecs()
FPS_temp = FPS_temp + 1
If ctime - FPS_time > 500 Then
FPS_i = FPS_temp * 2
FPS_temp = 0
FPS_time = ctime
EndIf
Return FPS_i
End Function
|