PursuedPyBear

Logo

Unbearably Fun Game Development

20 June 2020

June Solstice 2020 Release: More Rendering Options

by Piper

This has been an exciting release cycle! Most of our focus has been on things interacting with the Renderer, so let’s go down the list.

Text Rendering

We finally support text rendering! We don’t support system fonts, so you’ll need to include your .ttf or .otf files with the rest of your resources just like images or sounds.

Just like the rest of ppb, text resizes based on the shape of your sprite, and it attempts to fill the space.

Rectangular Sprites

In tackling text rendering, it became required to loosen the restrictions on the shapes of Sprites. As such, we now support rectangular sprites as well as square ones. The default Sprite is still a square, but you can also use ppb.RectangleSprite to manage things that aren’t square.

Part of this refactor included doing away with the Sides interface: instead of Sprite.top.left it’s Sprite.top_left.

Cameras

ppb has long supported a basic software camera as part of its rendering process. Building levels bigger than your viewport is much more simple than in other libraries since the constructs already exist. That said, the original camera was somewhat ugly. You had to know and understand the difference between the window screen space and the in-game coordinate grid.

The good news: we rebuilt the camera. Now, it’s width and height attempt to approximate the actual dimensions of the window, translated into game space. So if you test collision between the camera and an object, you’ll know if the object is visible on screen.

The bad news: In order to make the Camera work as well as it does, it gets added to new scenes by the Renderer during the SceneStarted event. So instead of setting up your camera in Scene.__init__ you should do your initialization in Scene.on_scene_started.

Renderer changes

This will be short and sweet:

We removed the DoNotRender flag. A Sprite with an image of None simply won’t render.

We added some initial (and optional) hooks for tinting your sprites and setting the render opacity of your sprites. Include Sprite.tint with a 3 tuple color (r, g, b all in the range 0-255) to tint. Sprite.opacity with a value between 0 and 255 to change the opacity of a render.

See the detailed change log on github and get the latest version of ppb with pip install ppb.

tags: ppb - releases