Mapper Issues
Moderator: MaxCoderz Staff
- thegamefreak0134
- Extreme Poster
- Posts: 455
- Joined: Mon 23 Jan, 2006 10:09 pm
- Location: In front of a Computer, coding
- Contact:
Mapper Issues
Ok, this should be a quickie. In VB.NET, I am developing a mapper. When the user clicks on a tile and then clicks on the map, I want that tile to go in the clicked-upon location. Simple right? I already know how to get the place they clicked, so picking the right tile is no prob. I do, however, need to know this.
I have the map currently set up as one image. I want to take the tile image (from a file, but can be loaded into a bitmap object if neccessary) and "draw" it onto the map image. Do I have to do this by pixel using a series of loops, or is there a drawing command to do this for me? I was going to do it like I always do with an array of pictureboxes, but VB.NET took that nice feature away and hid it, so I reckon there must be an easier way. Thanks for any help or suggestions!
-gamefreak
I have the map currently set up as one image. I want to take the tile image (from a file, but can be loaded into a bitmap object if neccessary) and "draw" it onto the map image. Do I have to do this by pixel using a series of loops, or is there a drawing command to do this for me? I was going to do it like I always do with an array of pictureboxes, but VB.NET took that nice feature away and hid it, so I reckon there must be an easier way. Thanks for any help or suggestions!
-gamefreak
I've made so many map editors in VB, it's ridiculous. They pretty much all share the same source code though.
Here's the source to its latest iteration: Bubble Bobble Map Editor. (sorry, it's VB5, not 7)
http://home.comcast.net/~alanweiss3/dwe ... ubmap2.zip
My approach is to make 4 picture boxes:
One picture box for the container of the tilemap
One picture box for the tilemap.
Scrollbars, they move the tilemap around inside the container.
One picture box for the tileset container
One picture box for the tileset
Map draws by copying tiles from the tileset to the tilemap.
The tileset container is just there to allow scrolling.
The user interface I made was inspired by RPG maker. You left click to draw, and right drag to pick up a bunch of tiles into the 'brush'. You can also use the tile palette to set the 'brush' to a single tile.
I also threw in some never-used stuff like the "Tile Replacer", which replaces all tiles with another, used when you change the tileset but need to update an old map.
To draw tiles, use either bitblt or PaintPicture. For VB7, try AllegNet, it's based on the famous Allegro C/C++ graphics/sound/etc library.
http://www.skorzec.com/allegnet/
Here's the source to its latest iteration: Bubble Bobble Map Editor. (sorry, it's VB5, not 7)
http://home.comcast.net/~alanweiss3/dwe ... ubmap2.zip
My approach is to make 4 picture boxes:
One picture box for the container of the tilemap
One picture box for the tilemap.
Scrollbars, they move the tilemap around inside the container.
One picture box for the tileset container
One picture box for the tileset
Map draws by copying tiles from the tileset to the tilemap.
The tileset container is just there to allow scrolling.
The user interface I made was inspired by RPG maker. You left click to draw, and right drag to pick up a bunch of tiles into the 'brush'. You can also use the tile palette to set the 'brush' to a single tile.
I also threw in some never-used stuff like the "Tile Replacer", which replaces all tiles with another, used when you change the tileset but need to update an old map.
To draw tiles, use either bitblt or PaintPicture. For VB7, try AllegNet, it's based on the famous Allegro C/C++ graphics/sound/etc library.
http://www.skorzec.com/allegnet/
You know your hexadecimal output routine is broken when it displays the character 'G'.
- benryves
- Maxcoderz Staff
- Posts: 3087
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
With VB7+, use GDI+ (the standard graphics system). Graphics.DrawImage will blit an image for you. To get a Graphics object for a picture box (let's say it's called MapEditBox) use CreateGraphics() - Graphics g = MapEditBox.CreateGraphics();, g.DrawImage(MyOtherPictureBox.Image, 0, 0);
I'm not sure what you mean by no picture box arrays, you can still use them (though not through the form designer)... (C# syntax, but you get the idea):
Might be a better idea to load the tile images into an ImageList control, then use a ListView control to display the tile 'picker'.
(Still not switched to VB8 [2005] yet?)
I'm not sure what you mean by no picture box arrays, you can still use them (though not through the form designer)... (C# syntax, but you get the idea):
Code: Select all
PictureBox[] PictureBoxArray = new PictureBox[3];
for (int i = 0; i < 3; ++i) {
PictureBoxArray[i] = new PictureBox();
this.Controls.Add(PictureBoxArray[i]);
}
(Still not switched to VB8 [2005] yet?)
- thegamefreak0134
- Extreme Poster
- Posts: 455
- Joined: Mon 23 Jan, 2006 10:09 pm
- Location: In front of a Computer, coding
- Contact:
- benryves
- Maxcoderz Staff
- Posts: 3087
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
Exactly. DrawImage has lots of different method signatures, allowing you to do everything from simply blitting one onto the other to scaling it as well to even clipping.
One thing I would warn you is that by default the graphics object will use high quality settings - so it will filter things when you scale them up and treat everything with a half pixel offset. I suggest setting g.PixelOffsetMode to PixelOffsetMode.Half and g.InterpolationMode to InterpolationMode.NearestNeighbor.
If you are using Graphics to draw to an Image or Bitmap rather than to a control, you don't use CreateGraphics. You use Graphics g = Graphics.FromImage(WhateverImageYouAreUsing);
One thing I would warn you is that by default the graphics object will use high quality settings - so it will filter things when you scale them up and treat everything with a half pixel offset. I suggest setting g.PixelOffsetMode to PixelOffsetMode.Half and g.InterpolationMode to InterpolationMode.NearestNeighbor.
If you are using Graphics to draw to an Image or Bitmap rather than to a control, you don't use CreateGraphics. You use Graphics g = Graphics.FromImage(WhateverImageYouAreUsing);
- thegamefreak0134
- Extreme Poster
- Posts: 455
- Joined: Mon 23 Jan, 2006 10:09 pm
- Location: In front of a Computer, coding
- Contact:
I'm making a mapper to design the levels (world map) for my pokemon re-make. (which is still alive and well btw, thanks to greyscale finally working in an APP. thanks to jim e.)
I got it to work (not excellent or anything, but it will be OK for my uses.) but still have one issue. It's so dang slow!
I have it reading all the pictures from file as it draws them. This basically just allows my saved maps to be smaller, but I may not really need to do this. Any other thoughts on how to speed it up?
-thegamefreak
I got it to work (not excellent or anything, but it will be OK for my uses.) but still have one issue. It's so dang slow!
I have it reading all the pictures from file as it draws them. This basically just allows my saved maps to be smaller, but I may not really need to do this. Any other thoughts on how to speed it up?
-thegamefreak
- thegamefreak0134
- Extreme Poster
- Posts: 455
- Joined: Mon 23 Jan, 2006 10:09 pm
- Location: In front of a Computer, coding
- Contact:
Because by building my own, I can have it export not only the map data, but the tile info, the actual tile data, ect. I can even go so far as to make it export the behavior codes for each tile type, so I edit it all in the program instead of trying to do it all by hand. That way to add a tile, I simply re-export the entire thing rather than trying to swim through my code. It's a very nice system, and goes so far as to ensure that I don't make silly typos more than once.
Anywho, I will attempt to buffer picture data somewhere, since that seems to be the only hold-up. Thanks again. First map is already on it's way. Woo!
-gamefreak
Anywho, I will attempt to buffer picture data somewhere, since that seems to be the only hold-up. Thanks again. First map is already on it's way. Woo!
-gamefreak
-
- Extreme Poster
- Posts: 340
- Joined: Fri 07 Jul, 2006 2:39 pm