Hello.
Take a look at visits and tiles in the following:
And try changing the number of rows from 100 to 1000 to 10000.
Goodbye.
Take a look at visits and tiles in the following:
Strict Global List_bricks : TList = CreateList() Global visits Global tiles Type TBrick Field Col Field Row Field r Field g Field b Field x Field y ' ---------------------------------------------------------------------------------------------- Function Create:TBrick (X,y) Local b:TBrick = New TBrick b.Col = x b.Row = y b.r = Rand (100,255) b.g = Rand (100,255) b.b = Rand (100,255) ListAddLast List_bricks, b Return b End Function ' ---------------------------------------------------------------------------------------------- Function Compute_one_row_Scrolling (Row, ScrollY) visits:+1 For Local b:TBrick = EachIn List_bricks tiles:+1 If b.Row = Row Then b.x = b.Col * 32 b.y = ScrollY End If Next End Function ' ---------------------------------------------------------------------------------------------- Function Draw_one_row (Row) visits:+1 For Local b:TBrick = EachIn List_bricks tiles:+1 If b.Row = Row Then SetColor b.r, b.g, b.b DrawRect b.x, b.y, 32,32 End If Next End Function ' ---------------------------------------------------------------------------------------------- Function MySort:Int(o1:Object, o2:Object) Local diff% = TBrick(o1).Row - TBrick(o2).Row If diff = 0 Then diff = TBrick(o1).Col - TBrick(o2).Col EndIf Return diff End Function ' ---------------------------------------------------------------------------------------------- Function Sort_the_list () SortList(List_bricks,True,MySort) End Function ' ---------------------------------------------------------------------------------------------- End Type ' create some tiles for this example (i use an editor for my game) ' if you increase max_row, the scrolling is slow, coz the for-next loop into the ' Compute_one_row_Scrolling(). Local Max_row = 100 For Local y=0 To Max_Row For Local x=0 To 31 TBrick.Create (x, y) Next Next ' sort them by y and x (not usefull here, but the game editor don't sort them...) TBrick.Sort_the_list() ' go Graphics 1024,768 Local t Local ScrollY = 0 Local Row = 0 Local TimeScroll = MilliSecs() While Not KeyDown(KEy_ESCAPE) ' compute scrolling If TimeScroll + 1 < MilliSecs() Then ' NOTE CHANGE TO 1 MILLISEC HERE TO GIVE FASTEST TRY If ScrollY < 31 Then ScrollY = SCrollY + 1 Else ScrollY = 0 If Row < Max_row + 25 Then Row = Row + 1 Else Row = 0 End If End If t = MilliSecs() Local Decal = -32 For Local r = row To (row-24) Step - 1 TBrick.Compute_one_row_Scrolling(r,ScrollY + Decal) Decal = Decal + 32 Next t = MilliSecs() - t TimeScroll = MilliSecs() End If ' draw Cls For Local r = row To (row-24) Step - 1 TBrick.Draw_one_row(r) Next DrawText "time=" + String(t), 0,0 DrawText "row=" + String(row), 0,30 DrawText "Visits=" + String(visits),0,48 DrawText "Tiles=" + String(tiles),0,64 Flip visits = 0 tiles = 0 Wend
And try changing the number of rows from 100 to 1000 to 10000.
Goodbye.