Here’s my “editor”. I’m testing the TileSheet class alongside the Region class. The problem is, I’m using calloc() to allocate the memory, but it’s not zeroed out. Instead, I’m getting what you see here. Initially I created a region of size {40,40,3}, which was causing some lag, so I dropped it to {20,20,1}, and this is what came up. The window on the right is the memory’s dump in progress. I guess I should just switch back to using the new operator and some loops, but I wanted to try and avoid doing that for speed reasons. However, I’d rather have it working.
Anyway, I’ll push the buggy code, and work on it more tomorrow; my mother wants the computer :(

Here’s my “editor”. I’m testing the TileSheet class alongside the Region class. The problem is, I’m using calloc() to allocate the memory, but it’s not zeroed out. Instead, I’m getting what you see here. Initially I created a region of size {40,40,3}, which was causing some lag, so I dropped it to {20,20,1}, and this is what came up. The window on the right is the memory’s dump in progress. I guess I should just switch back to using the new operator and some loops, but I wanted to try and avoid doing that for speed reasons. However, I’d rather have it working.

Anyway, I’ll push the buggy code, and work on it more tomorrow; my mother wants the computer :(

Above you can see a mock up of my specialized spinner dialog, next to an actual image of similar code in action. It sucks.

The first was made believing that I’d need at most 3 characters in those buttons, but I forgot about the ‘+’ and ‘-’ characters, so the individual buttons will be wider. The second is just a demo of what it should look like, using the raster font and button images.

However, since these would need different images (for a different number of characters in the strings), I’ve gotten an idea: I should write an actual system to create the button surfaces at run time. I’d use a bitmap file to define how high I want the buttons, as well as the button colours, but I’d just have to create new surfaces of various sizes at run time for different button types.

It’s important to note that the buttons leave a 2 pixel boarder around the text strings. That’s why, even though it won’t cause any code to crash, the existing button images have a maximum string size (otherwise they overflow and look ugly). The current button image is 68 pixels wide (16 (1 char) * 8 (max chars) + 4 (gap)).

Edit: all in all, the dialog will be 3 characters high, plus borders, and (to be safe) 20 characters wide plus borders. But of couse I’ll write the code to be flexible, so this can change down the road.

I’m tired, and I’m overthinking too much. But at least I’m making slow, but steady progress on the Sketch map editor. I’m hoping that the speed of development will increase when I actually have a solid foundation to the game.

Anyway, you can see my scratchings for sketch here, and you can see an idea for handling the multiple shared tilesets under the cut.

Read More

map classes breakdown

this is just so I can get it straight.

This is the sort of thing you need documentation for.

Read More

I wonder if the Tileset class would benefit from not being an aggregate of Image. That way, it can receive (or load, depending on if I use the surface manager or not) a surface, and the Map class can simply ask it to draw a specific tile to a specific location; the Tileset’s DrawTo() would… actually, what if the Tileset rearranged the surface into a straight strip of tile images? That way, instead of doing this:

tileX = tileIndex % surfaceWdith
tileY = tileIndex / surfaceWdith

it can just do this:

tileX = tileIndex * tileWidth
tileY = 0

Division & Modulus are apparently the most expensive operations, so I think this would make it run faster.

This was just going to be a train of thought, but it’s actually pretty good. But I’m getting tired again, and its 4am, so I’m going back to bed. Any feed back is appreciated!?

Here’s an example of a filter I wanted to write. I was running out of time, and it’s designed for only one tileset in existence, so I decided to leave it out.
Basically, the filter would iterate over the map; when it hit a short grass-long grass pair on the first layer, it would switch out the tiles to make it more like the square on the right.
Since there are actually 5 tilesets in the terrain.bmp file, it can use fancy maths to apply this to every tileset: tilesets closer to the bottom exist on top of tilesets on the top.
I’ll probably write this for a future version, but right now it’s OK as it is.

Here’s an example of a filter I wanted to write. I was running out of time, and it’s designed for only one tileset in existence, so I decided to leave it out.

Basically, the filter would iterate over the map; when it hit a short grass-long grass pair on the first layer, it would switch out the tiles to make it more like the square on the right.

Since there are actually 5 tilesets in the terrain.bmp file, it can use fancy maths to apply this to every tileset: tilesets closer to the bottom exist on top of tilesets on the top.

I’ll probably write this for a future version, but right now it’s OK as it is.

Looks great. You should print the controls in the console or overlay them onscreen. Not everyone reads the read-me :p.

Good idea thanks!

Very clever program here! I’m curious though why the black terminal box stays open after the programs launches. Have you tried compiling with flag -Wl,—subsystem,windows ?

Actually, I use the console for emergency output via stderr and lua’s default print(), which is renamed consoleprint(). I also use a batch file to keep the window from closing and losing the messages. I didn’t include that, simply because it cluttered the folder a bit.

Sketch is a simple, lightweight 2D tile map editor, written with C++, SDL and lua. The core is written in C++ with graphics and input handled by SDL. Lua scripts are used by the editor to process the map in various ways such as custom saving and loading formats, random terrain generation or extended functionality.


This project is only in alpha, therefore many (or any) features are currently missing. Anything with a strikethrough is currently unimplemented.


Basic Functionality

  • Custom layered map sizes
  • Map pagination
  • Multiple tilesets per map
  • Clean interface
  • Smooth, intuitive controls


Scripts And Filters

  • Standard brush filters
  • Standard saving/loading
  • Standard lua scripts
  • Custom saving/loading
  • Custom brush filters
  • Custom Lua scripts

Extended Functionality

  • Collision map
  • Position markers
  • Waypoints
Well, not quite as spectacular as I was hoping. You need to set the tile and layer using the terminal at the bottom. left clicking changes the tiles, of course, using a script called “pencil”. I’ll write more scripts soon, but it’s already possible to write those yourself.
I’ve added the script files into the git repo, since it seems like you can’t use it now without them. You can run any lua code directly from that terminal, and you can hack the *.lua files that come with it.
So far, the current libraries available are:
Map
Tileset
Brush
Brush is a purely lua based structure, but it’s still needed, since it’s called from the C++ code. Each brush type has these functions: “mousemotion”, “mousebuttondown” and “mousebuttonup’, which are basically wrappers around the C++/SDL events. I tried adding keyboard events, but they were a little finicky.
There are no save scripts (yet), but you can write those yourself. That’s actually the inspiration for this whole thing: a simple tool that allows people to write their own save formats for use in their own games.
I don’t think anybody will use this, and I don’t think that I’d do it again if I knew what I was getting myself into. The best part of this (apart from learning lua) what that it doesn’t use my Codebase, which I think was holding me back in someways. The loop-in-main structure was only supposed to be temporary until I got the modules going, but it looks like it’s here to stay.
A few more tweaks until the final release, but I REALLY want to avoid feature creep. I’d like a depiction of the actual tileset, so that the user can pick the tile themselves, but I think to do that properly would require a big overhaul of the graphics systems. I’d also like to store the scripts, maps, etc. in a file structure, and make it easier to port to different platforms (since it directly references the WINDOWS folder to load the font).
Overall, I’m tired, and I want to move onto a game.
GitHub Page, and the brush file.

Well, not quite as spectacular as I was hoping. You need to set the tile and layer using the terminal at the bottom. left clicking changes the tiles, of course, using a script called “pencil”. I’ll write more scripts soon, but it’s already possible to write those yourself.

I’ve added the script files into the git repo, since it seems like you can’t use it now without them. You can run any lua code directly from that terminal, and you can hack the *.lua files that come with it.

So far, the current libraries available are:

  • Map
  • Tileset
  • Brush

Brush is a purely lua based structure, but it’s still needed, since it’s called from the C++ code. Each brush type has these functions: “mousemotion”, “mousebuttondown” and “mousebuttonup’, which are basically wrappers around the C++/SDL events. I tried adding keyboard events, but they were a little finicky.

There are no save scripts (yet), but you can write those yourself. That’s actually the inspiration for this whole thing: a simple tool that allows people to write their own save formats for use in their own games.

I don’t think anybody will use this, and I don’t think that I’d do it again if I knew what I was getting myself into. The best part of this (apart from learning lua) what that it doesn’t use my Codebase, which I think was holding me back in someways. The loop-in-main structure was only supposed to be temporary until I got the modules going, but it looks like it’s here to stay.

A few more tweaks until the final release, but I REALLY want to avoid feature creep. I’d like a depiction of the actual tileset, so that the user can pick the tile themselves, but I think to do that properly would require a big overhaul of the graphics systems. I’d also like to store the scripts, maps, etc. in a file structure, and make it easier to port to different platforms (since it directly references the WINDOWS folder to load the font).

Overall, I’m tired, and I want to move onto a game.

GitHub Page, and the brush file.