   Tile map editor idea...
  I want to run this buy you guys before I try to code it, just to make sure that it will work as I'm hoping it will.What I'm thinking of doing is creating a bitmap the same size as the tile map with the same bit depth as the tile id's (32 in my case). Then I want to overwrite the image data pointer of the bitmap with the tile data pointer of the tile map. My thought is that in doing so, I could use Window's GDI geometric drawing function to write directly into the tile map. I have made some pixel-perfect geometric functions that plot tiles, but these are needlessly complicated and I am really reinventing the wheel by creating them.It seems like it should work, but I know that Windows sometimes adds extra pixels to the ends of the scanlines. I would guess that so long as the bitmap's top left coordinate is (0,0) and the width is a power of two, this shouldn't be an issue.Has this been tried before? I'm not too familiar with Windows' GDI and I want to prevent any hassles.   
  I've done a similar thing in the past, though I didn't try to get fancy with memory or tile IDs. In my game, each entire tileset corresponds to a unique color (and every tileset has 20 different tile shapes). Thus, I can load up a bitmap, iterate over each pixel, find the tileset with the corresponding color (or closest match), and insert an appropriate tile. I have a smoothing algorithm that helps me pick the right tile shape based on the local topography, so the maps look nice. It seems to work fairly well, though in practice it's not going to let me get away with not implementing a proper in-game editor. If nothing else, I also need to be able to place "scenery" (e.g. plants in the background) and "props" (e.g. statues the player can stand on) that don't adhere to the tile system.Edit: on rereading your idea, I'm not really doing anything like what you're suggesting. Whoops! However, my approach would allow you to use an exterior drawing program to make your maps, and seems safer than trying to co-opt a drawing library to a task it's not really designed for.   ;Quote:Original post by Derakon... and seems safer than trying to co-opt a drawing library to a task it's not really designed for.I don't think this will be an issue. Windows will treat the bitmap as any other bitmap. Each color would correspond to a specific tile id. My thinking is that the bitmap image data is nothing more than a 2D array of chars, shorts or longs and the tile map data is the same. It should work, in theory. The only thing that could cause problems is if Windows doesn't allocate the image data in the format I expect or adds padding to each row. For example, assume that a 64x64 tile map would map exactly to a 64x64 pixel bitmap since it is on a word boundary. What happens if the tile map is 63x63 tiles? Would the image data be exactly 63x63 pixels or would Windows add padding, making it 64x63 pixels?The reason I'm asking this before even trying to code it is that I am very inexperienced with Windows programming. I've tried simple things and have spend days trying to figure out why they don't work. MSDN is so convoluted and it is really only helpful if you know exactly what to look for. If you don't, you'll be searching for every possible arcane term you can think of. For days. Been there, done that.   ;  I'm not remotely experienced enough with the Windows API to know if there's any gotchas to your desired approach. I suppose my main question is, why do you want to use this approach? From my understanding of editors, all it is going to do for you is simplify the creation of the basic level structure. You could theoretically use it for drawing map details, but in practice I think you'll find that you'll need to implement a tile picker anyway, and then place each tile individually. For example, there will be little call for drawing a perfect circle of all the same tile type, but you are likely to want to be able to place a single instance of variant tile #6 at this specific point. In short, your idea is clever, but is it useful? How much does tying into the Windows drawing code gain you? (And also, if you ever plan on making your game cross-platform, this would be one more thing you'd have to change...)   ;  In the game I'm making, there is need to more than simple tile placement. Ellipses, lines, rectangles, etc., have use. The game is based in a garden with a top down view.This will not tie it to Windows and I do plan on making it cross-platform at some point in time. The same principles apply to bitmaps regardless of the OS. All bitmaps I've seen (and I've done my fair share of Mac programming as well) are is really nothing more than a structure containing the pointer to the image data and the length of the scanlines plus some incidentals. There isn't anything that would make this difficult to port.Since no one else want to reply, I guess I'll take a stab at it and see.   ;  So you want to store your tile data as a bitmap? It's possible, but you could ask yourself what benefits it would offer over just writing binary (or textual) data to a file. The file is not meant to be used as a bitmap anyway, and you'll likely have to store other level data as well.Personally, when it comes to level data, I tend to prefer a textual format these days, especially early on, as it's a lot easier to modify and check by hand. Storing the data as an executable script is even easier. Either way, I can always swap it for a binary format later on, should the need arise.Anyway, if you do want to go down this route, just make sure you use a proper imaging library to save and load images with. The .bmp format isn't always that straight-forward so don't go muddle with it manually if you don't have to. With Python, I would use PIL or Pygame, but there should be similar libraries for use with C++. As for GDI... it's deprecated in favor of GDI+, but there are much better alternatives for game and tool development. Are you familiar with SDL or SFML, or C# (possibly combined with XNA)?As for power-of-2 images, if a library can't handle anything else, you really should look for something less restricted. Such libraries aren't worth your time.   ;  No, not at all. I want to draw into the bitmap with functions like Ellipse, Rect, RoundRect, etc., and have that show up in the tile map. This concerns level creation and editing.The levels will be saved as an array of tile id's plus other level-specific information.   ;  I tested it. It works. Of course it works. I should have known this.   ;  Ah, so you wanted to reuse those drawing routines for quickly painting tile patterns... I thought you wanted to use it for storage, heh. :)Some Bresenham line algorithms shouldn't be too hard to dig up, but this sounds like a faster way to get what you want, so yeah, why not?   ;Quote:Original post by Captain PSome Bresenham line algorithms shouldn't be too hard to dig up, but this sounds like a faster way to get what you want, so yeah, why not?Oh, I've got plenty of those! I have lines, Bezier, at least three different ellipse algorithms, etc. They all work well and I've even got them to draw multiple widths by filling spans. But, they are all extremely complex. Then I tried to implement an arc algorithm... *curls in a ball under my desk*I just don't see any point in reinventing the wheel here, if it can be avoided.   