PDA

Click to See Complete Forum and Search --> : Map Editor Using BitBlt


SteveCRM
Jun 9th, 2000, 02:27 AM
Im making an online game. Its coming along very well so far. But for later versions of the game I would like to be able to make more maps. I want to know how to make a map editor that uses BitBlt. All I need is two things, walkable areas and nonwalkable areas. Any help will be a big help.

Fox
Jun 9th, 2000, 04:20 AM
Try to save the tile indexes in a 2D array. Then in the tiles you can store information like collidable and picture and stuff... like this:


'Types
Type tTile
Picture as Long
Collidable as Boolean
End Type

'Tiles
Global TileCount as Long
Gloabl Tile() as tTile

'Map
Global Map(100,100) as Long

SteveCRM
Jun 10th, 2000, 03:03 AM
Okay, so my map would be 100 * 100? And collidable objects are called collidable? If I wanted my map bigger then I could just replace the 100s? Thanks fox.

Fox
Jun 10th, 2000, 03:38 AM
Jup, or resize it at runtime:


dim Map() as tTile
dim Width as Long
dim Height as Long

'Code
Width = 300
Height = 200
Redim Map(Width, Height)

SteveCRM
Jun 10th, 2000, 04:10 AM
Cool Thanks Fox!

kedaman
Jun 10th, 2000, 07:27 AM
you could use ubound(map,1) and ubound(map,2) and create a property height and width, but maybe it's a slower way to retrieve the vars, maybe Fox's right it's better to use as much vars as possible if you want performance.

But Redim Preserve Map(Width, Height) won't erase all the data after rediming

Fox
Jun 10th, 2000, 10:01 AM
Nope, you can't resize more than 1-dimensional arrays while holding the data ;)

Fox
Jun 10th, 2000, 10:01 AM
oh man, it's 5 0'clock am now.. I really should go sleepin'... c'ya!

kedaman
Jun 10th, 2000, 03:34 PM
youre up early then fox, or do you sleep online?

yeah I forgot, you can just preserve the later argument :p

Fox
Jun 10th, 2000, 05:37 PM
I'm always online... and I was up till 5.00am ;)

kedaman
Jun 10th, 2000, 05:59 PM
Me too, but i went offline 4am and tested vb6, but it was german!

SteveCRM
Jun 10th, 2000, 10:45 PM
Im traveling right now so I can't try out the code yet :( When I get back later today I'll tell you how it went.

Just want to make sure. So in my map, I would just have to call something collidable and then it will work? After I tell my program what to do when it sees something collidable of course.

Fox
Jun 11th, 2000, 02:17 AM
In my tile array every tile can have several values, collidable for example. Of course you later have to check if the tile collides and if not don't move the player or whatever, I just showed you the structure...

SteveCRM
Jun 11th, 2000, 04:49 AM
Thats what I thought. But can I tell what side is colliding with something else? So if my guys hits a wall from the front I can tell? So i can stop him from going forward?

SteveCRM
Jun 11th, 2000, 05:35 AM
error...I put this in a module...and i get an error on this line...
Gloabl Tile() as tTile

kedaman
Jun 11th, 2000, 05:54 AM
It's a typo: Global

You need to do a property for the movement, when you change the position, your property should check for walls in that direction and refuse to move if there is

SteveCRM
Jun 11th, 2000, 06:50 AM
What do you mean properties kedaman? How do I do this? Ambiguous Name Detected, "tTile". I get an error in a module and declarations of a form.

(oh duh! I wasn't looking at the code when I copied it. Sorry)

kedaman
Jun 11th, 2000, 07:55 AM
I'm not sure what youre doing so i can't suit it for your needs but i can give an example:

Private Type pos2d
x As Integer
y As Integer
End Type

Private Pguypos As pos2d
Dim Velocity As pos2d

Private Property Get guypos() As pos2d
guypos = Pguypos
End Property
Private Property Let guypos(newval As pos2d)
If Not map(newval.x, newval.y).Collidable Then
Pguypos = newval
End If
End Property

Sub moveguy()
guypos = posadd(guypos, Velocity)
End Sub

Private Function posadd(arg1 As pos2d, arg2 As pos2d) As pos2d
posadd.x = arg1.x + arg2.x
posadd.y = arg1.y + arg2.y
End Function