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.

OK! Terminal system is finished, so check out the branch!

I’ll probably make this branch the master, overriding the original or something.

Now… how the hell do I implement the map???Q!!?!

Specification for the “Brush”

In the map editor, there will be a “brush”, the tool that you use to alter the map data. Now, I’m not sure if I should write this as a C++ class, or as a lua construct.

The purpose of using lua in the map editor was partially to learn more about it, but mostly so that custom “filters” could be written. So, if someone wanted to write a filter that creates a house from a specified tileset, they could. Then, the filter could have some randomization, so that not every house in a village looked the same. Then, using this script, the designer could write a script to automate the creation of entire villages and towns, to act as a base for the designers plans.

I know of at least two things that are necessary for the brush in general, a “selection”, which is the current tile, and “mounted” script, which would be the current filter attached to the brush. So, you could have a “circle” filter, which acts basically just like the giant circle brush in MS paint, but it’s done by running a script in lua.

So, if I had a class “Brush” I’d have an unchanging system with a “selection” and “mounted script”, but looking at it like that I don’t think that’s the best idea. Instead, I should have a global lua variable called “brush.selection” which would be the selection, and I could have the mounted script saved in lua, which might actually make things easier. If I make the “brush” a C library for lua, that could work even better, maybe. And it’d allow different specs for each different filter type (not every filter would use the “selection”).

On top of this, perhaps each filter could have a function for each input type. that is, when the user presses a mouse button, the current filter could have a specific action for that button. Hmm.

I’ll be expanding this article thought the day, so check back later when it’s finished.

First off, here is a list of awesome game ideas.

Now, I think I haven an idea for my platformer. I’m most familiar with RPGs similar to Final Fantasy but, you know, sidescrolling platformer. So, what if I made a platformer similar to Final Fantasy?

Some of the most prominent features of Final Fantasy are:

  • Combat systems
  • Equipment and item systems
  • Exploration of dungeons
  • Extensive narrative

None of those strictly prohibits a platformer. I’d like some sort of overworld too, but I’ll leave that until later. The actual platforming can focus on puzzles, etc. while entering into a random encounter every now and then. This could be really good, if done well.

Mixing two different genres is something I’ve wanted to do, because it’s probably the best way to attract attention. Now, I need to complete a basic working version of my map editor, which I can then use for the platformer prototype. This is ambitious, and will take time.

Edit: I’d like to avoid gameplay like metroidvania or hop ‘n’ bop. So, if the player falls to far, they gain fall damage like in various Zelda games? I wrote this prototype to try out a movement algorithm inspired by Mario and Braid, but I don’t think it quite fits this idea. It did give me some insights into my own collision system, which will hopefully help me flesh out what I have so far.

Map Editor: Modularity

OK, so to maintain simple modularity, I’ll divide my map editor’s architecture up like this:

SceneMgr

  • lua state
  • map utility
  • tileset image
  • Brush (tile selection, etc)

SceneEditor

  • Map editing
  • Drawing the map to the screen

SceneTileSelect

  • Select the tile from the tileset

SceneCollisions

  • control which tiles are “solid”

SceneLuaScripts

  • Run various lua scripts, including the custom saving/loading scripts.

Scene????

  • ????

I’m not certain how to expand that list above. Any ideas are welcome.

The above layout would mean that there would be a lot more switching between scenes than I’ve done before, so I’m not sure how the codebase or the editor will take it.

It also means that the overarching classes, like the map editor or the lua state would have to exist in SceneMgr so that they aren’t created and destroyed every time I switch a scene.

There’s nothing “wrong” with it, it’s just different.

Side note: Listening to major spoilers issue 396 gave me an idea: a combat triangle of Human, Alien and Demon. Human beats Demon (w/ holy thingies), Demon beats Alien (because their stronger) and Alien Beats Human (Invasion flicks, etc).

Train of Thought

One of these days I’m gonna write a script that takes a .h file, reads the class’ members, and outputs a fully formatted .cpp file, so I don’t have to write the function shells myself.


Would a missing array be an exception or a logic_error?

Strange, this should work:

cout « “make x” « endl;
    m_pArray = new int**[m_iXCount];

    for (int i = 0; i < m_iXCount; i++) {
        cout « “make y” « endl;
        m_pArray[i] = new int*[m_iYCount];

        for (int j = 0; j < m_iYCount; i++) {
            cout « “make l” « endl;
            m_pArray[i][j] = new int[m_iLCount];

            for (int k = 0; k < m_iLCount; k++) {
                cout « “zero tile” « endl;
                m_pArray[i][j][k] = 0;
            }
        }
    }

But it conks out after the second “make l” message.

EDIT: I found the problem in the code above. Can you? I’ll bet you $20 you’ve done that too.

for (int j = 0; j < m_iYCount; i++) { in this line you inkrement i instead of j

We have a winner!

I wonder if I should load the tileset as an SDL_Surface, or use my Image class. I wrote the image class to draw sprites to the screen, so I’d like to know how well it handles tile sheets. Since I’m altering the internals a bit each time, it might run slower, but I’ve never really worried about frame rate.

For now, I’ll handle the tileset in the scene, rather than inside MapUtility.

To support tile transparency, the tiles will NOT be zero indexed.

When I “zero” the array, layer 0 is completely set to 1, so that the first tile on the tilesheet is the initial state for the map. Then, all other layers that might be sitting on top are set to 0, making them transparent.

The array generator will reject invalid  numbers, even though the numbers will still be saved as the format.

I knocked my alarm clock out of the power board.

Basic MapUtility class finished, and pushed to github.

DAMN! It looks like SDL’s mouse button event recognizes when you have the mouse buttons reversed, but not the mouse motion event.

Strike that, my bad.