Diary of a Game: Day 8

Gravitas - Wed, 08 Sep 2021 12:30:50 GMT

Well, what is it they say about best-laid plans?

I went into the weekend full of vim and vigor, with a firm idea of what I wanted to achieve, and instead I woke up with terrible hayfever, which triggered a sinus headache which completely killed my productivity until it started clearing up Tuesday afternoon.

Oh, well.

Today I got back onto the horse, so to speak, and started getting Chipmunk and Flecs talking to each other. Actually, before doing that, I used the StarterKit to create a new codebase for Gravitas, so all future updates will be made in a private repository, and will be back-ported to the StarterKit once Gravitas has shipped.

I started by making Chipmunk structs, such as cpSpace, cpBody and cpShape, first-class components in Flecs, which means Flecs would be responsible for managing their lifetime. But I just couldn’t get this working. Chipmunk asserts heavily that all data looks sane when compiled in debug mode, and I was triggering asserts left, right and centre.

Back to the drawing board, I worked to hack in the “hello chipmunk” example, not bothering to integrate it with Flecs at all, just to make sure things worked as expected. And they did. I really should have started from that point, and I’ll make a note to do so next time I integrate a third-party library like this.

I was then able to implement a few simple wrapper structs in Flecs, that just encapsulated pointers to Chipmunk data, leaving Chipmunk to manage the lifetime of its objects. And that all worked swimmingly. So I’m off to the races again.

Tomorrow I plan to get physics debug drawing working, and will then move on to rendering those spaceship sprites after all.

In future I will remember to slow down and to forget trying to keep a tight schedule. Nature abhors a workaholic, as they say.