-
map loader/maker
SORRY for a LONG question :>
So i'm trying to make a map loader/maker for my game, i have the idea but im struggling to find out how to "load" the map..
I use pictureboxes as tiles..
its a 10x8 grid, pictureboxes are named as "tiles"(t1,t2,t3,t4,t5,t6,t7)
ATM in FORM_LOAD this happens..
Code:
Dim one As Image = My.Resources._1
Dim two As Image = My.Resources._2
t1.Image = one
t2.Image = one
t3.Image = one
t4.Image = one
t5.Image = one
t6.Image = one
t7.Image = one
t8.Image = one
t9.Image = one
t10.Image = one
t11.Image = one
t12.Image = two
t13.Image = two
t14.Image = two
t15.Image = two
t16.Image = two
t17.Image = two
t18.Image = two
t19.Image = two
t20.Image = one
t21.Image = one
.....
the "one" is supposed to be a wall, "two" is supposed to be grass.
so the map format in the map "maker" .. would be like this
Code:
1-1-1-1-1-1-1-1-1-1
1-2-2-2-2-2-2-2-2-1
1-2-2-2-2-2-2-2-2-1
1-2-2-2-2-2-2-2-2-1
1-2-2-2-2-2-2-2-2-1
1-2-2-2-2-2-2-2-2-1
1-2-2-2-2-2-2-2-2-1
1-1-1-1-1-1-1-1-1-1
if you get the idea... that would be a map with walls surrounding and grass in middle..
now I'm trying to load the map (in the code up)
by doing somewhat like this:
Code:
Dim maploc As String = "C:\--\--\--\mapformat.txt"
Dim map As String
Dim binReader As New System.IO.StreamReader(System.IO.File.OpenRead(maploc))
map = binReader.ReadLine
binReader.Close()
Dim maparray As Array = map.Split("-")
Dim one As Image = My.Resources._1
Dim two As Image = My.Resources._2
t1.Image = maparray(1)
t2.Image = maparray(2)
t3.Image = maparray(3)
t4.Image = maparray(4)
but obviously that doesn't work because f.x. maparray(1) is "1"
how should i do this ?
EDIT: i found a way to do this but that would be retarded...
Code:
If maparray(0) = "1" Then
t1.Image = one
Else
t1.Image = two
End If