Public Structure tilesystem
Public camerax, cameray As Integer
Public startx, starty As Integer
Public tilearray As Char()()
Public offsetx, offsety As Integer
End Structure
Public Structure bimage
Public imagearray As Bitmap()
Public numframes As Integer
Public speed As Integer
Public posx, posy As Integer
End Structure
Dim graphicobject As Graphics
Dim aimage As Bitmap
Dim mimages As ArrayList = New ArrayList
Dim count As Integer = 1
Dim lrectangle As New Rectangle(0, 0, 33, 33)
Dim partimage As Bitmap
Dim bitmapimage As bimage = New bimage
Dim state As Boolean = 0
Dim avar As Integer = 1
Dim color As System.Drawing.Color = color.Black
Dim bcolor As System.Drawing.Color = bcolor.Blue
Dim atilesystem As New tilesystem
Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.DoubleClick
graphicobject = Me.CreateGraphics
aimage = Image.FromFile("c:\\dart\dmannoborders.bmp")
While (avar < 1000)
lrectangle.X() += 1
If (lrectangle.X() > 640) Then
lrectangle.X() = 33
End If
partimage = aimage.Clone(New Rectangle(count * 33, 0, 33, 33), Drawing.Imaging.PixelFormat.DontCare)
'ERROR ON THIS LINE imagearray is the problem
bitmapimage.imagearray(bitmapimage.numframes) = partimage
bitmapimage.numframes += 1
partimage.MakeTransparent(color)
graphicobject.Clear(bcolor)
graphicobject.DrawImage(partimage, lrectangle)
tileengine(atilesystem, 640, 480)
'Sleep(1)
count += 1
If (count > 8) Then
count = 1
End If
avar += 1
End While
End Sub
Public Function tileengine(ByRef atilesystem As tilesystem, ByVal resx As Integer, ByVal resy As Integer)
Dim x As Integer = resx / 32
Dim y As Integer = resy / 32
Dim count As Integer = 0
Dim count2 As Integer = 0
Dim offsetx, offsety As Integer
Dim index As Integer = 0
atilesystem.startx = resx / 2
atilesystem.starty = resy / 2
atilesystem.camerax = atilesystem.startx
atilesystem.cameray = atilesystem.starty
atilesystem.offsetx = atilesystem.camerax Mod 32
atilesystem.offsety = atilesystem.cameray Mod 32
For count = 0 To y Step 1
For count2 = 0 To x Step 1
index = Val(atilesystem.tilearray(count2)(count))
'index into image array to get that tile
graphicobject.DrawImage(bitmapimage.imagearray(index), lrectangle)
Next
Next
End Function