|
-
Dec 21st, 2001, 07:02 PM
#1
Thread Starter
Hyperactive Member
Walls, Collisions, Mazes... ?
Umm... I need help.. alot of help.
I wanted to make a simple maze thing, were the user can move through a maze, but not going through the walls...
How can I make this, and How can I make the walls.
This thing is frying my brain, I need help
~$uper-$tar
If you have any tutorials or know of any that learn to make a 2d maze or something that can help... and that it is easy to learn from with out the complex ways... thanks
-
Dec 22nd, 2001, 12:26 PM
#2
Lively Member
Hi
How I would make a maze is by storing the maze in an array.
X columns
0 1 2 3 4 5 6 7 8 9 or however long the maze is
1
y 2
3
c 4
o 5
l 6
u 7
m8
n 9
Then filling the array with either 1's or 0's. A zero in the certain spot would mean you can walk there, and a 1 could be a wall
so the array could look like this, NOTE that a wall should be placed around the border, so you can't just walk off into nowhere, and using a 2 for the start, so you can place the person in a maze, and a 3 for the end
X columns
0 1 2 3 4 5 6 7 8 9 or however long the maze is
1 1 1 1 1 1 1 1 1 1
y 2 1 2 0 0 0 1 0 1 1
3 1 0 1 1 0 1 0 0 1
c 4 1 0 0 0 0 1 1 0 1
o 5 1 0 1 1 1 0 0 0 1
l 6 1 0 0 0 0 0 1 1 1
u 7 1 0 1 1 1 1 0 3 1
m8 1 0 0 0 0 0 0 1 1
n 9 1 1 1 1 1 1 1 1 1
Then you move through the maze by just adjusting the array +1 or -1 to move left and right in the x column, or +1, -1 in the y column to move up or down.
Hope this helps
-
Dec 22nd, 2001, 01:20 PM
#3
Thread Starter
Hyperactive Member
Hrmm...
I have no clure how to do that... could I ask for a small design so I can understand it more clearer?
~$uper-$tar
-
Dec 22nd, 2001, 03:28 PM
#4
hey,
i also need this info for an rpg. any concrete examples would be useful, i know how to do it theoretically, but i need the code! just something to get me started. thanks!
victor
btw, i know that there is a tutorial at http://markbutler.8m.com where it shows how to create a maze, but it is randomly created. how can i define a map without having it be random? thanks.
-
Dec 22nd, 2001, 08:51 PM
#5
Thread Starter
Hyperactive Member
Its very good...
Only bad part is, they picture is slow compared to where the guy is. Though very easy to understand.
Thanks 
~$uper-$tar
-
Dec 23rd, 2001, 06:38 PM
#6
that was a great maze tutorial! thanks, it really helped. i have one quick ? though.
in the timer1 where you are actually drawing out the graphics there is the following loops
For x = 1 To 10
For y = 1 To 10
If MazeArray(x, y) = 0 Then ' draw white box
color = RGB(255, 255, 255)
ElseIf MazeArray(x, y) = 1 Then ' draw black box
color = RGB(0, 0, 0)
ElseIf MazeArray(x, y) = 2 Then ' draw red box
color = RGB(200, 0, 0)
ElseIf MazeArray(x, y) = 3 Then ' draw blue box
color = RGB(0, 0, 200)
End If
Line (x * BOX_WIDTH, y * BOX_HEIGHT)-(x * BOX_WIDTH + BOX_WIDTH, y * BOX_HEIGHT + BOX_HEIGHT), color, BF
Next
Next
Specifically i have a question about this line:
Line (x * BOX_WIDTH, y * BOX_HEIGHT)-(x * BOX_WIDTH + BOX_WIDTH, y * BOX_HEIGHT + BOX_HEIGHT), color, BF
what is it that you are doing? what is BF and why are you multiplying the x coordinates with the width and height? thanks!
also, if i know want to use pictures (tiles) instead of blocks of colour, i have heard that i have to use something called BitBLT. what is this and is there a good tutorial?
-
Dec 23rd, 2001, 08:31 PM
#7
Lively Member
Hi
The line:
Line (x * BOX_WIDTH, y * BOX_HEIGHT)-(x * BOX_WIDTH + BOX_WIDTH, y * BOX_HEIGHT + BOX_HEIGHT), color, BF
this is used for drawing the colored boxes you see, BF means
B = Make a Box,
F = Fill box with the color
You could omit the F, and then the box would just be drawn and not filled with the color.
Line(x1, y1)-(x2, y2), color, (Box and or fill)
x1 = x * BOX_WIDTH
x2 = (x * BOX_WIDTH) + BOX_WIDTH
y1 = y * BOX_HEIGHT
y2 = (y * BOX_HEIGHT) + BOX_HEIGHT
okay I'll show you an example then I think you'll see why those lines are like that
we want to draw a box for MazeArray(0,0) so the very first one
so:
x1 = (0) * BOX_WIDTH = 0
x2 = ((0) * BOX_WIDTH) + BOX_WIDTH = BOX_WIDTH
y1 = (0) * BOX_HEIGHT = 0
y2 = ((0) * BOX_HEIGHT) + BOX_HEIGHT = BOX_HEIGHT
so after this first step
we have a box in the cordinates 0-BOX-WIDTH, and then 0-BOX_HEIGHT
so now if we wanted to draw the next box in the MazeArray
which would be MazeArray(0,1)
x1 = (0) * BOX_WIDTH = 0
x2 = ((0) * BOX_WIDTH) + BOX_WIDTH = BOX_WIDTH
y1 = (1) * BOX_HEIGHT = BOX_HEIGHT
y2 = ((1) * BOX_HEIGHT) + BOX_HEIGHT = BOX_HEIGHT * 2
so in effect the box is directly below the first box
if instead you used the equation
x1 = x
x2 = x + BOX_WIDTH
y1 = y
y2 = y + BOX_HEIGHT
we would only be moving 1 pixel over every time we drew a new box, so we need to move over the box's width or height everytime
we draw another box
I hope that helps
as for BitBlt, I've never used it before, I learned DirectDraw instead,
BitBlt is a way to take the images you've drawn and be able to display them into your project. Its sorta of like the Line command cept that you aren't confined to lines, but instead you use images
but www.planet-source-code.com should have something on BitBlt for a tutorial
-
Dec 24th, 2001, 08:02 AM
#8
Great, thanks. i understand it now. i found a bitBLT/tile based game tutorial on this website in case anyone else is interested as well:
http://fox.acky.net/vb/english/codin...ial/index.html
merry christmas
-
Dec 24th, 2001, 11:24 AM
#9
Thread Starter
Hyperactive Member
Pictures instead of Boxes?
How would you change the Box to a image?
~$uper-$tar
-
Dec 24th, 2001, 05:10 PM
#10
Thread Starter
Hyperactive Member
Maybe what I mean is...
How could you make the white boxs to a picture...
How could you make the black boxs to a picture...
How could you make the guy to a picture...
~$uper-$tar
-
Dec 24th, 2001, 06:38 PM
#11
the way i understood it is that you have to work with more complicated code using certain API calls (?, is that what you call it?). go to that tutorial website mentioned previously and look through all the posts. i don't think you can just replace the balls by typing in the path of a picture...
-
Dec 24th, 2001, 06:46 PM
#12
Thread Starter
Hyperactive Member
yeah
thats what i thought after tying other ways... i thought maybe I could try the path of the picture...
Btw, Merry Christmas 
~$uper-$tar
-
Dec 24th, 2001, 06:50 PM
#13
merry christmas!
i found a few good tutorials on the net, go to www.planet-source-code.com and search for tutorials under visual basic.
-
Dec 24th, 2001, 07:02 PM
#14
Thread Starter
Hyperactive Member
Links and Tutorials
-
Dec 24th, 2001, 07:05 PM
#15
Good Ol' Platypus
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Dec 24th, 2001, 07:08 PM
#16
Thread Starter
Hyperactive Member
I am always intrested
LoL, i will master this in... a day or too lol. So far I got like 50 pages on this stuff 
~$uper-$tar
-
Dec 25th, 2001, 08:13 AM
#17
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|