Hi,
I'm working on the texture tile system for a small GDI+ game
and I'm wondering what approach should I take for the sub that
draws all the texture elements on the map - loop through
entire array of textures or call each texture element using a
recursion? I tried both ways and I can't see a difference,
it looks that both methods are performing with same speed,
here's my code:
I'm working on the texture tile system for a small GDI+ game
and I'm wondering what approach should I take for the sub that
draws all the texture elements on the map - loop through
entire array of textures or call each texture element using a
recursion? I tried both ways and I can't see a difference,
it looks that both methods are performing with same speed,
here's my code:
- Loop approach:
Public Sub TileTexCells(e As System.Windows.Forms.PaintEventArgs)
For i = 0 To UBound(TexCells)
e.Graphics.DrawImage(TexCells(i).bmpFace, TexCells(i).ptrLocation)
Next
End Sub
- Recursive approach:
'class declaration:
Public Class TexCell
Public bmpFace As New Bitmap(128, 128, Imaging.PixelFormat.Format32bppPArgb)
Public intSubscript As Integer
Public ptrLocation As Point
Public Sub TileTexcells(ByVal e As System.Windows.Forms.PaintEventArgs)
e.Graphics.DrawImage(bmpFace, ptrLocation)
If intSubscript < UBound(TexCells) Then _
TexCells(intSubscript + 1).TileTexcells(e)
End Sub
End Class
'usage:
Public Sub On_Paint(ByVal e As System.Windows.Forms.PaintEventArgs)
TexCells(0).TileTexcells(e)
End Sub