Hi there!
I am toying around with game programming in VB.net, and was having performance issues with a sort of map generator I created. The procedure reads lines from map.txt, and depending on the number it reads, draws different images on the screen from tiles from a picturebox. When I run it, however, I get only about 6-7 FPS. Is there something wrong with my code? Should I be using a different method to achieve what I want? Thanks in advance!
I am toying around with game programming in VB.net, and was having performance issues with a sort of map generator I created. The procedure reads lines from map.txt, and depending on the number it reads, draws different images on the screen from tiles from a picturebox. When I run it, however, I get only about 6-7 FPS. Is there something wrong with my code? Should I be using a different method to achieve what I want? Thanks in advance!
Private Sub DrawMap()
objSR = New StreamReader("C:\map.txt")
For x = 0 To 15
For y = 0 To 15
source = New Rectangle(0, 0, 32, 32)
destination = New Rectangle(x * 32, y * 32, 32, 32)
G.DrawImage(images, destination, source, GraphicsUnit.Pixel)
read = objSR.ReadLine
If read = "1" Then
source = New Rectangle(96, 128, 32, 32)
destination = New Rectangle(x * 32, y * 32, 32, 32)
G.DrawImage(images, destination, source, GraphicsUnit.Pixel)
ElseIf read = "2" Then
source = New Rectangle(96, 96, 32, 32)
destination = New Rectangle(x * 32, y * 32, 32, 32)
G.DrawImage(images, destination, source, GraphicsUnit.Pixel)
End If
If grid = True Then G.DrawRectangle(Pens.Black, x * 32, y * 32, 32, 32)
Next
Next
objSR.Close()
End Sub