Track Editor part 2


My current goal is to use Inkscape as the track editor for my Genesis game. Define my racing game's tracks via SVG files.

Today I've proven the concept out, I have this process working:

1) Use Inkscape to draw the path for my track

2) In Python, have Inkscape render the track to a PNG

3) In Python, load this image, and for each pixel draw a tile. If the pixel is a track edge, make it a grass tile, otherwise make it a road tile.

4) Not implemented yet- Read other data out of the SVG file to generate collision information, checkpoints, and spawnables. I've proven out that I can load this data via the SVG libraries in Python.

5) Output this image as the track graphic, to the Genesis resources folder

6) Rebuild the Sega Genesis game

7) Done, I can drive around the track I drew in Inkscape now.

What does this do for me? Fast and rapid iteration on creating tracks for my racing game. Inkscape has a lot of great tools for manipulating curves, and I can easily define a loop for a lap based level, or a non-looped curve for a point to point race track.

This also lets me define tilesets and swap between them easily. I could output a track as a snowy track, or desert track, or city track trivially. Just change which tileset I'm using when I convert the SVG to a track.

The most contentious choice here is probably step number 2. If I'm using an SVG library in Python to read this data, why use Inkscape to render to a PNG? This is because I wanted to use variable thickness on the track curve, so I could have it be more interesting and get wider or narrower in different spots. I didn't want to manage two curves, an outer and inner wall, that's a much slower workflow. Instead, I use an Inkscape extension for variable width curves.

I could then have Inkscape convert this to an inner and outer wall by having it save it as a standard SVG, but I couldn't find an easy way to figure out what's between those two curves using the SVG library. Also, I didn't like that how I had to sample along the curves using the SVG python library, it was difficult to pick a good rate to do this that captured enough detail but also didn't take forever.

Here's this process in action:

First, there's the SVG file in Inkscape


Second, is the rendered track. Right now I'm just outputting the track, and not the checkpoint line or the obstacle.Third is the created track with the tiles. Right now the tiles are hardcoded 2D arrays in Python, but I can also load these tiles as PNGs, and define tilesets as subfolders.


Third is the created track with the tiles. Right now the tiles are hardcoded 2D arrays in Python, but I can also load these tiles as PNGs, and define tilesets as subfolders.


Finally, is the gameplay. I'm able to drive along the track I've created.


Files

roguerider_v009.bin 384 kB
Jan 29, 2022

Get Redline Reaver

Leave a comment

Log in with itch.io to leave a comment.