Recovering my old starting point while recovering from surgery.

During eleven bed-ridden days, restarted an older project to make a platformer with fun movement. There are two primary inspirations for the work:

  1. Implementing the old N Ninja math tutorials for how their collision works.
  2. Supporting every sample from the アクションゲーム アルゴリズム マニアックス book.
    • Japanese programming book that reverse-engineers action game characters/mechanics from the ’80s up.
    • Translated title: ActionGame Algorithm Maniax.

The first goal is to use N Ninja-esque collision, and support every or almost every character/mechanic explained in the ActionGame book.

The work is all being done on Linux first. Windows support will eventually happen. Working completely within Linux is what I’m doing right now. So all tools used must also work there.

Main tools so far are:

  • clang for C++.
  • Vim for code/text file editing.
  • Terminator for terminal multiplexing.
  • gdb for debugging.

No code tags, intellisense, or anything like that yet. I’ll get around to it eventually, when the code’s complex enough to warrant it.

1. Projection test

Just get a vector p1->p0 (red->blue) projected onto the line segment p1->p2 (red->green). Make the handles draggable for testing.

  • SDL2 for window and input management, and rendering. Also their wonderful assert/trap/continue.
  • OpenGL 2 for some other rendering.
  • Dear ImGui for an easy way to both debug and poke things. I liked AntTweakBar in the past, but wanted something a little more modern in its API, and I liked that Dear ImGui doesn’t make its own draw calls.
  • CML (Configurable Math Library) for vectors, points, etc.

2. SAT box test

Mimic the Metanet tutorial sample seen here (Flash required). Shows what the projection of the box in the middle looks like on the line. Line can be moved around the box with the handle. Don’t mind the floating “p0” text. That’s an ImGui tooltip, which displays at the cursor’s position.

3. SAT boxes test

Have two moveable rectangular objects. If they overlap, show a vector that is the smallest movement of the red box available to separate the boxes.

4. SAT triangle test

Change one of the shapes to a triangle. Two legs must be axis-aligned. Press ‘R’ to resolve the “collision” by moving the red box out of the triangle the shortest possible distance.

5. SAT convex test

SAT test supports any two arbitrary convex shapes.

6. tile test

Add a tile map/world. Add a camera.

  • Tile assets by Kenney; you can find them in the voxel pack.
  • Tilemap files edited with Tiled.
  • “Mod” support with Icculus’ PhysicsFS.
  • Texture/image loading with the single-header library stb_image.h.
  • XML parsing with TinyXML.

7. platformer test

Red character is driven by “player 1” controls. Other characters share “player 2” controls. Controls are deliberately limited to four directions and one button. May become two directions and two buttons. Animations are hand-made XML for the time being.

Characters “wrap” by default if collision doesn’t stop them. Rendering updated so wrapping characters show on both sides of the screen (hacky).

Characters are controlled by Lua scripts. Scripts choose whether to turn tile world collision on or off, and whether or not they want gravity handled for them automatically. One of the goals is to make it very easy for a person with zero programming experience to make something fun. But without taking away so much control that an advanced user couldn’t do something completely unexpected. Like every other file being loaded from disk, these can be “modded” (replaced or added to).

-- simplest-player.lua
m_x = 0

function move()
    if input.right then
        m_x = m_x + 20

Tile collision (the second pass written) is built in the N Ninja style, from the Metanet tutorials. The borders between “empty space” and “solid tile with a plain edge” can be shown in red. No support for “interesting” edges yet (curves, cut-away tiles, etc.).

  • Character assets by Kenney; you can find them in the abstract platformer pack.
  • Started using Valgrind to check for leaks. Found a couple of my own, but most leaks are specific to the readily-available drivers for the Surface Pro 3 in Linux. Thankfully Valgrind makes it easy to build up an “ignore” file, too.