Graphics and Rendering – Reviewing and Fixing My Old Ludum Dare Games

Welcome to episode three of the Genesis series! In this series, we explore one of my first-ever games, where we analyze both the strengths and weaknesses of the game. We discuss the graphics and rendering aspects, and in the next episode, we will delve into the game logic. So let’s get started!

Graphics and Rendering - Reviewing and Fixing My Old Ludum Dare Games
Graphics and Rendering – Reviewing and Fixing My Old Ludum Dare Games

Rendering the Graphics

First, let’s discuss the process of rendering graphics in the game. We have a Screen class that handles the manipulation of pixel data, allowing us to render various elements. The Screen class essentially acts as a rendering context, allowing us to render tiles, mobs, and other game elements.

To begin rendering a tile, we use the renderTile method. This method takes in the position and color of the tile and applies any necessary transformations or effects. We also check if the tile is a torch tile, as we want to preserve its original color regardless of the lighting conditions.

Next, we have a renderMob method that renders mobs, such as enemies or characters. In this method, we have a parameter called flip, which determines if the sprite should be flipped horizontally or vertically. By manipulating the order in which we read the pixels, we can achieve the desired flipping effect.

Applying Lighting

In our game, we have a day/night cycle, which affects the lighting conditions of the level. To achieve this, we have a brightness value that represents the level of brightness. Based on the distance between a mob and a light source, we modify the brightness of the mob. This creates a visual effect where mobs closer to the light source appear brighter.

Further reading:  A Comprehensive Guide to Writing and Reading Files in 3D Game Programming

We also have a color tag that shows if a female mob can spawn a child. Color tags are implemented by changing the color of specific pixels on the sprite. For example, if a female mob can spawn a child, we change the color of certain pixels to green. This tag serves as a visual indicator for gameplay mechanics.

Text Rendering

In addition to rendering graphics, we also have text rendering in the game. We use a renderText method that takes in the text, position, and color as parameters. The method sets the color of the graphics context, uses a specified font, and draws the text at the specified position.

It’s worth noting that in the current implementation, we create a new font every time we render text. This can be improved by using font caching techniques to enhance performance.

Conclusion

In this episode, we explored the graphics and rendering aspects of the game. We learned about rendering tiles, applying lighting, and rendering text. We also discussed possible improvements, such as font caching, to optimize performance.

Join us in the next episode as we dive into the game logic and mechanics. Stay tuned for more exciting insights into my old Ludum Dare games!

Techal