Prototype Update A - Devtech Brain Juice


3 months in

We started development in November last year. Since then Krystof has been at work getting the game concept docs together. I've been getting chummy with C/C++ and Raylib. And we've got an illustrator. She has been doing 3d modeling and illustrations for characters and key scenes.


I'm just going to use this update post to talk about some technical things I've been doing that I find interesting, and/or just rant about certain topics. In the future when more progress is happening on the game I will be covering that instead. So here's some Synthasmagoria-Brand Brain Juice.

Update

Marching squares collision generation experiment

Since we're using an image to decide where to spawn trees in the world and where road is supposed to be I had an idea for how we can keep the car on the road. But how do you know when a pixel on an image represents an edge, and what direction is that edge facing? It is possible to find out using the marching squares algorithm.

The algorithm can take an image like this.


And turn it into data that is visualized like this.


From there it is possible to polygonize the data like so


And with polygon data like that you can create one-way rotated rectangular colliders - that are easy to implement - that look like this (the input for this one is a different image though):


Considering that we'll be working with images that are much higher resolution than this I'll most likely have to use Ramer Douglas Peuker Reduction algorithm to reduce the number of vertices in each polygon so that I don't end up with too many colliders.

Although we most likely won't be using Marching Squares based collision since it seems pretty imprecise. We want to have the colliders accurately follow the winding road through the landscape. Maybe it could be a good fit for other types of games though.

It was fun researching though. I was initially inspired by the Godot Engine source code:
Marching Squares: https://github.com/godotengine/godot/blob/eee39f004b42a4948af90cdebedf65c34a4a4970/scene/resources/bit_map.cpp#L171
Reduction: https://github.com/godotengine/godot/blob/eee39f004b42a4948af90cdebedf65c34a4a4970/scene/resources/bit_map.cpp#L426

ImGui integration

I quickly realized that it would be very nice to have some debug overlay. So I spent a day adding it to my project structure. It was easy thanks to rlImGui: https://github.com/raylib-extras/rlImGui

Trying to make the best of VSCode

I don't have the sigma grindset to use NeoVim - especially since I'd have to configure it for the DVORAK keyboard layout. I'll eventually try CLion since it seems to do everything I currently need to do + better refactorings. But I have no need for the CMake support that it offers. For these reasons I'm currently sticking with VSCode, or rather; VSCodium. Learning all the shortcuts has served me well in navigating my code, but some things could definitely be better.

  • I would kill to have a "next/previous function/symbol hotkey"
  • Spread/unspread function call or struct initialization
    // this long ass line
    v4 bilinearValue = Vector4Lerp(Vector4Lerp(value, valueRight, lerpRight), Vector4Lerp(valueDown, valueRightDown, lerpRight), lerpDown);
    // becomes this using a hotkey and vice versa
    v4 bilinearValue = Vector4Lerp(
        Vector4Lerp(value, valueRight, lerpRight),
        Vector4Lerp(valueDown, valueRightDown, lerpRight),
        lerpDown);
    
  • Refactor function signature aka. the arguments passed to it (I know you can do this with ctrl+t, but its pretty finicky)
  • Some nice way to navigate my symbols other than searching (something like the outline window but better)

To make navigating my code easier I tried using this bookmarks extension (https://open-vsx.org/extension/alefragnani/Bookmarks), but the bookmarks kept moving around my code file which essentially made it useless. I'll probably keep finding solutions to a lot of these issues, but in the future I'll try some other code editor. Maybe even one that controls like Vim or something. Though, most likely I'll have to relearn QWERTY when that time comes. There's a reason they decided to use h, j, k, and, l for navigation. But for now I'll just try using the Clangd extension instead of the Microsoft C/C++ extension since it's supposedly better.

Conclusion

We were initially aiming for the prototype to be done in December. But looking at it now I see that I still have a lot to learn. It is much more realistic to say that a prototype should be ready by the end of April. I think at this point we're 50% of the way there. Expect another update once I've found a part time job that I can use to keep funding the development of Midnight Driver.

Leave a comment

Log in with itch.io to leave a comment.