Diary of a Game: Day 9


Got debug drawing working today for physics bodies, and then started working on a multi-camera system. I added a new Viewport component in Flecs that encapsulated a Raylib Camera2D and a RenderTexture, as well as other data needed to specify where the viewport should appear on the primary display, which I call the playfield. The playfield itself is of a fixed resolution, and is displayed within the game window. It may be letterboxed or pillarboxed if the window is of different dimensions.

The screenshot above shows three viewports, with red, green and blue backgrounds, each displaying a different view of the same physics scene in world space. The viewports are of different resolutions; the chunky one in the bottom-right corner is just 50x50, while the red one is 800x600, but being downscaled to be displayed within the 640x480 playfield.

The next step will be to display textures and have them driven by the physics engine, instead of just relying on debug drawing (which can be toggled off, and which is completely disabled in release builds). I also want to add controls to allow the camera within each viewport to be moved, rotated and zoomed in and out.

A good day today after some back-and-forth yesterday. Physics is working well, and Chipmunk is completely hidden behind a few Flecs components and systems. And I’m glad that Raylib supports drawing to a virtual camera, properly clipping the results. Bodes well for the work that lays ahead!

Get Gravitas

Buy Now$1.99 USD or more

Leave a comment

Log in with itch.io to leave a comment.