When working on this game framework recently I have been concentrating on improving the entity system. Improvements with the entity system now implemented include the addition of entity lifecycle functions that can be used by entity subclasses.

Animated sprite support using sprite sheets is another new feature that I have now implemented, as well as working on visual themes for the small game, Racket, that I am using to build the framework features around.

Mechanical Theme Gear Debug

Entity Lifecycle

With the recent improvements to the entity system, entity subclasses can now be used for gameplay code. These entities can use the following lifecycle functions to work with the framework.

  • void Start()
    • This is run when the game simulation is starting.
  • void Update(double deltaTime)
    • This function is called when the game simulation is updating. The current delta time is provided as a parameter.

Below is an example entity subclass that displays a log message to the debug console when the entity is started, and when the keyboard key E is pressed.

ExampleEntity.h

/**
 * Game Framework
 */

#pragma once

#include "Entity.h"

/**
 * ExampleEntity class
 */
class ExampleEntity : public Entity
{

public:

    /**
     * Constructor
     */
    ExampleEntity();

    /**
     * Start function that is called when the game starts
     */
    void Start();

    /**
     * Update function that is called when the game is updating
     */
    void Update(double deltaTime);

};

ExampleEntity.cpp

/**
 * Game Framework
 */

#include "ExampleEntity.h"

#include "Log.h"
#include "Input.h"

ExampleEntity::ExampleEntity()
{
}

void ExampleEntity::Start()
{
    Log::Message("Example Entity - Start");
}

void ExampleEntity::Update(double deltaTime)
{
    if (Input::GetKeyDown(SDLK_e))
    {
        Log::Message("Example Entity - E key pressed");
    }
}

Sprite Animation

Entities can now be set up to render sprite animations as shown with the gears in the corners of the board in the GIF below.

Mechanical Theme GIF

This works by providing a sprite sheet of the animation, and setting an animation frame rate that should be used when playing back in the game.

Mechanical Gear Example

The animated gears in the GIF above use the following sprite sheet I made of a rotating gear:

Mechanical Gear Sprite Sheet Click to see the full size sprite sheet

Racket themes

Racket now has a set of themes that can be switched between from the menu, with the currently in progress Mechanical theme making use of the newly added sprite animation support to display animated gears in the corners of the board.

Classic Theme Classic Theme

Classic Inverted Theme Classic Inverted Theme

Mechanical Theme (In Progress) Mechanical Theme

Next update

In the next update I aim to have the web build of Racket in a state that is tested and ready to be published, in addition to further work continuing on the features of the game framework.