Lambda expressions in C

C does not have built-in support for lambda expressions, but if you are using gcc, it is actually quite easy to implement them using a simple macro. This trick relies on two C extensions: nested functions and statement expressions. Both are available in gcc (but not in clang!) Here is a small program that could benefit from lambda expressions, written in conventional C: // A function taking a function pointer as argument....

2016 January 13

How I made my parallel self win the lottery

While I was in France recently I decided to make one of my parallel self a millionaire. It’s very easy and you too can do it if you want. How to do it? First you have to check how the national lottery of the country where you are works. In France, a lotto ticket costs 2 euro, you have to pick five different numbers from 1 to 49 (included), and one ’lucky’ number from 1 to 10 (included)....

2015 December 20

Goxel, an open source 3D voxel editor

Goxel is a new project I have been working on since last month. It’s an open source 3D editor to create voxel images (in the style of minecraft, or crossy road). It works on Linux and Windows. Features: 24 bits RGB colors. Unlimited scene size. Unlimited undo buffer. Layers. Smooth rendering mode. Export to obj and pyl.

2015 October 5

Voxel Snake 3D

I just released a small game on google play: Voxel Snake 3D. This is basically a snake game played on a 3D cube, using voxel rendering. Let me know what you think!

2015 July 28

Blowfish Rescue 1.0 Released

Just a small post to announce the release of my new video game: Blowfish Rescue. This is a 2d action/puzzle game using a fluid simulation solver. Most of the graphics are procedurally generated. The game is available for free on google play and iTune. Here is a promo video I did: In the following week I will open source the procedural generation code, as I think this is an interesting part of the code, and can probably be reused for other games....

2015 July 6

Procedural graphics generation in C

I introduce noc_turtle, a small MIT licence C library to create procedural graphics in plain C. I release it in the hope that some people will use it in their own project, and also to promote my video game Blowfish Rescue for which I wrote it. The library allows to write procedural rules directly in C, so it is very simple to embed it in a project and to mix it with custom code....

2015 June 12

Comparison of Doom 1, Quake, and Doom 3 entity references system

The architecture of a video game code is usually based around a list of entities that represent all the game elements: players, enemies, etc. The engine iterates over this list and call the appropriate methods to update or render the entities. Since game elements get constantly created and destroyed, the list is not static but need to be updated at each iteration. The problem is that some entities keep references to others....

2015 April 29

10 C99 tricks

Here are ten interesting patterns and tricks I sometime use in my C code, some are well known, some not so much. I am sure all of them work with clang and gcc (after fixing the evetual typos). I didn’t try with MSVC, but except for no 1 and 5, I think it should also work. [edit]: Here is a link to the hacker news thread. [edit]: Maybe the title is a bit misleading, this is not strictly about C99....

2015 February 13

Procedural colors for video games

Recently I have been spending a lot of time thinking about how to use procedural colors in my -still unnamed- incoming video game. [edit]: The game is done now, it is called Blowfish Rescue, and you can play it for free on Android of iOS. This is a problem that I am sure many other indie game developers have been thinking about, and there are not so many resources about it online, so I though I would share my experience so far on the subject....

2014 October 6

Named parameters in C

C99 introduced the concept of designated initializers, that allows to initialize a structure using the name of the fields, like this: struct MyStruct {int x; float y;}; struct MyStruct a = { .x = 10, .y = 3.6, }; Here is a C macro that extends this syntax to function calls. I present it as a curiosity, and I really wouldn’t advise anybody to actually use it in a project (except maybe for very special cases, like for example emulating the interface of a language that accepts named arguments)....

2014 July 14