EDN Admin
Well-known member
Heres the deal - Im fiddling around with trying to make a sort of map/world. Im using 16 x 16 pictureboxes named PictureBox1, PictureBox2, etc.
The issue is that when I put the images into all the pictureboxes, I have to have a line for each picturebox (so say I have 100 boxes, I have 100 lines).
The only difference in each line is the picturebox number, the rest is identical. Im basically telling it to set that pictureboxs image based on the number that a variable Ive created has stored.
Ive got a game idea, and Im just trying to figure out how to do the map. I want it to work like the old school RPG games like Dragon Warrior, or the more recent Dwarf Fortress. Im still not sure if I want to use graphics or letters. At this point, Im
just trying to figure out how I can create the main screen where the user moves around. This is what Ive come up with, as it works with what I know. Im pretty new to this, although Ive messed around with VB6 a lot.
Heres my code so you can see exactly what I mean:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Dim tile(30) <span style="color:Blue; As <span style="color:Blue; Integer
<span style="color:Blue; Dim tilelocation(3) <span style="color:Blue; As <span style="color:Blue; String
<span style="color:Blue; Dim x <span style="color:Blue; As <span style="color:Blue; Integer
x = 0
<span style="color:Blue; Do <span style="color:Blue; While x <> 30
x = x + 1
tile(x) = Int((3 * Rnd()) + 1)
<span style="color:Blue; Loop
tilelocation(1) = <span style="color:#A31515; "C:UsersJayDesktopMy Projectgrass.png"
tilelocation(2) = <span style="color:#A31515; "C:UsersJayDesktopMy Projecttree.png"
tilelocation(3) = <span style="color:#A31515; "C:UsersJayDesktopMy Projectwater.png"
PictureBox1.ImageLocation = tilelocation(tile(1))
PictureBox2.ImageLocation = tilelocation(tile(2))
PictureBox3.ImageLocation = tilelocation(tile(3))
PictureBox4.ImageLocation = tilelocation(tile(4))
PictureBox5.ImageLocation = tilelocation(tile(5))
PictureBox6.ImageLocation = tilelocation(tile(6))
PictureBox7.ImageLocation = tilelocation(tile(7))
PictureBox8.ImageLocation = tilelocation(tile(8))
PictureBox9.ImageLocation = tilelocation(tile(9))
PictureBox10.ImageLocation = tilelocation(tile(10))
PictureBox11.ImageLocation = tilelocation(tile(11))
PictureBox12.ImageLocation = tilelocation(tile(12))
PictureBox13.ImageLocation = tilelocation(tile(13))
PictureBox14.ImageLocation = tilelocation(tile(14))
PictureBox15.ImageLocation = tilelocation(tile(15))
PictureBox16.ImageLocation = tilelocation(tile(16))
PictureBox17.ImageLocation = tilelocation(tile(17))
PictureBox18.ImageLocation = tilelocation(tile(18))
PictureBox19.ImageLocation = tilelocation(tile(19))
PictureBox20.ImageLocation = tilelocation(tile(20))
PictureBox21.ImageLocation = tilelocation(tile(21))
PictureBox22.ImageLocation = tilelocation(tile(22))
PictureBox23.ImageLocation = tilelocation(tile(23))
PictureBox24.ImageLocation = tilelocation(tile(24))
PictureBox25.ImageLocation = tilelocation(tile(25))
PictureBox26.ImageLocation = tilelocation(tile(26))
PictureBox27.ImageLocation = tilelocation(tile(27))
PictureBox28.ImageLocation = tilelocation(tile(28))
PictureBox29.ImageLocation = tilelocation(tile(29))
PictureBox30.ImageLocation = tilelocation(tile(30))
[/code]
So at this point its just randomizing a map and displaying it in 30 little boxes. Its just annoying to have to do 30 lines when all the code is the same except for a single number in the picturebox control name.
View the full article
The issue is that when I put the images into all the pictureboxes, I have to have a line for each picturebox (so say I have 100 boxes, I have 100 lines).
The only difference in each line is the picturebox number, the rest is identical. Im basically telling it to set that pictureboxs image based on the number that a variable Ive created has stored.
Ive got a game idea, and Im just trying to figure out how to do the map. I want it to work like the old school RPG games like Dragon Warrior, or the more recent Dwarf Fortress. Im still not sure if I want to use graphics or letters. At this point, Im
just trying to figure out how I can create the main screen where the user moves around. This is what Ive come up with, as it works with what I know. Im pretty new to this, although Ive messed around with VB6 a lot.
Heres my code so you can see exactly what I mean:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Dim tile(30) <span style="color:Blue; As <span style="color:Blue; Integer
<span style="color:Blue; Dim tilelocation(3) <span style="color:Blue; As <span style="color:Blue; String
<span style="color:Blue; Dim x <span style="color:Blue; As <span style="color:Blue; Integer
x = 0
<span style="color:Blue; Do <span style="color:Blue; While x <> 30
x = x + 1
tile(x) = Int((3 * Rnd()) + 1)
<span style="color:Blue; Loop
tilelocation(1) = <span style="color:#A31515; "C:UsersJayDesktopMy Projectgrass.png"
tilelocation(2) = <span style="color:#A31515; "C:UsersJayDesktopMy Projecttree.png"
tilelocation(3) = <span style="color:#A31515; "C:UsersJayDesktopMy Projectwater.png"
PictureBox1.ImageLocation = tilelocation(tile(1))
PictureBox2.ImageLocation = tilelocation(tile(2))
PictureBox3.ImageLocation = tilelocation(tile(3))
PictureBox4.ImageLocation = tilelocation(tile(4))
PictureBox5.ImageLocation = tilelocation(tile(5))
PictureBox6.ImageLocation = tilelocation(tile(6))
PictureBox7.ImageLocation = tilelocation(tile(7))
PictureBox8.ImageLocation = tilelocation(tile(8))
PictureBox9.ImageLocation = tilelocation(tile(9))
PictureBox10.ImageLocation = tilelocation(tile(10))
PictureBox11.ImageLocation = tilelocation(tile(11))
PictureBox12.ImageLocation = tilelocation(tile(12))
PictureBox13.ImageLocation = tilelocation(tile(13))
PictureBox14.ImageLocation = tilelocation(tile(14))
PictureBox15.ImageLocation = tilelocation(tile(15))
PictureBox16.ImageLocation = tilelocation(tile(16))
PictureBox17.ImageLocation = tilelocation(tile(17))
PictureBox18.ImageLocation = tilelocation(tile(18))
PictureBox19.ImageLocation = tilelocation(tile(19))
PictureBox20.ImageLocation = tilelocation(tile(20))
PictureBox21.ImageLocation = tilelocation(tile(21))
PictureBox22.ImageLocation = tilelocation(tile(22))
PictureBox23.ImageLocation = tilelocation(tile(23))
PictureBox24.ImageLocation = tilelocation(tile(24))
PictureBox25.ImageLocation = tilelocation(tile(25))
PictureBox26.ImageLocation = tilelocation(tile(26))
PictureBox27.ImageLocation = tilelocation(tile(27))
PictureBox28.ImageLocation = tilelocation(tile(28))
PictureBox29.ImageLocation = tilelocation(tile(29))
PictureBox30.ImageLocation = tilelocation(tile(30))
[/code]
So at this point its just randomizing a map and displaying it in 30 little boxes. Its just annoying to have to do 30 lines when all the code is the same except for a single number in the picturebox control name.
View the full article