Ludum Dare Hard Mode

I'm looking into creating a native game engine from scratch in C and open-sourcing any tools developed along the way.

Development Strategy

Development will occur in two repositories: code (open-source), team (closed-source). - code repository: C modules that might be open sourced - team repository: everything else needed to plan & publish an actual game - code: main branch: released \ open-sourced modules - code: dev branch: unreleased \ experimental modules - code: staging branch : modules picked from dev to merge to main to release

Since the team repository is closed source it will be okay to store todo lists, drafts, and screenshots in the main branch so that they are not lost in a discarded topic or feature branch.

Embedding Files in Comments

C modules will have additional files embedded in comments.

In the following example there is a test.c unit-test program and test.sh runner embedded in the mylib.h header library:

``` // mylib.h - useful functions for video games

pragma once

include

typedef uint8t U8; typedef uint16t U16;

define U8MAX UINT8MAX

define U16MAX UINT16MAX

define def static inline

//:test.sh cc -Wall -Wextra -Wpedantic -O3 test.c -o test; ./test /*:test.c

include "mylib.h"

include

include

int main(){ */

// sadd : saturated addition def U8 saddu8(U8 a, U8 b){ U8 c=a+b; return c < a ? U8MAX : c; } //:test.c assert(saddu8(128,128) == 255); def U16 saddu16(U16 a, U16 b){ U16 c=a+b; return c < a ? U16MAX : c; } //:test.c assert(saddu16(32768,32768) == 65535);

/*:test.c printf("okay. "); return 0; } */ ```

Note: LDJam.com makes comments hard to read (very low contrast), but they are easy to see in my editor.

A tool then copies the original file + embedded files to new directory and runs an optional command:

codetool mylib.h /tmp/mylib/ ls mylib.h test.c test.sh codetool mylib.h /tmp/mylib/ bash test.sh okay.

This way related files for experiments can be stored, drafted, and discarded together without littering the repository.

Future

I'm also prototyping a dependency resolver so codetool can copy imported modules to the output folder as well. The resolver parses dependencies from embedded comments without needing a separate folder or metadata file per unit. My hypothesis is that embedding files in comments will be useful for attaching unit tests, examples, manuals, build scripts, and shaders to single-file modules since C has no default package manager. Instead of embedding a test.c program in a mylib.h library, it might also be possible to embed a mock mygame.h library in a game-engine.c program. Not sure how this will play out yet.