A manager for frames within a game loop.
Common Lisp
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
LICENSE
README.md
gamebox-frame-manager.asd

README.md

gamebox-frame-manager

A manager for frames within a game loop.

Overview

This is a simple manager for frame updates within a main game loop. After creating a simple frame manager, one can just call a function every iteration of the main game loop, and have it handle the desired physics updates at the correct times. It also provides a logging feature to show the game's current frame rate, and other useful information.

Install

(ql:quickload :gamebox-frame-manager)

Usage

First, create a FRAME-MANAGER object with your desired delta time:

(defparameter *frame-manager* (make-instance 'frame-manager :delta (/ 1 30.0)))

Instead, you can also sub-class FRAME-MANAGER:

(defclass my-game (frame-manager)
  ((delta :initform (/ 1 30.0))))

(defparameter *my-game* (make-instance 'my-game))

You will likely want the frame rate logged to the REPL during development of your game. In that case, set the current logging level to :DEBUG:

(setf simple-logger:*current-level* :debug)

Then call the TICK method every step of the main game loop, with the correct value for your monitor's refresh rate, and a custom physics update function to apply.

(tick *frame-manager* 60 #'step-func)

This will call STEP-FUNC, a function you define that takes no arguments, only when needed - that is, enough time has passed between the last physics update based on the frame manager's target delta time. Within your STEP-FUNC, you have access to the reader method (ALPHA FRAME-MANAGER) to obtain the interpolation coefficient that can be used to blend the previous and current frames.

With the current log message level set to :DEBUG, you should see the frame rate printed every 5 seconds.

License

Copyright © 2014-2018 Michael Fiano.

Licensed under the MIT License.