The gamebox-frame-manager Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The gamebox-frame-manager Reference Manual

This is the gamebox-frame-manager Reference Manual, version 1.0.0, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 03:55:19 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

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.


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 gamebox-frame-manager

Maintainer

Michael Fiano <mail@michaelfiano.com>

Author

Michael Fiano <mail@michaelfiano.com>

Home Page

https://www.michaelfiano.com/projects/gamebox-frame-manager

Source Control

(:git "git@github.com:mfiano/gamebox-frame-manager.git")

Bug Tracker

https://github.com/mfiano/gamebox-frame-manager/issues

License

MIT

Description

A manager for frames within a game loop.

Long Description

# 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

“‘ lisp
(ql:quickload :gamebox-frame-manager)
“‘

## Usage

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

“‘ lisp
(defparameter *frame-manager* (make-instance ’frame-manager :delta (/ 1 30.0)))
“‘

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

“‘ lisp
(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‘:

“‘ lisp
(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.

“‘ lisp
(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](mailto:mail@michaelfiano.com).

Licensed under the MIT License.

Version

1.0.0

Dependencies
Source

gamebox-frame-manager.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 gamebox-frame-manager.asd

Location

/home/quickbuilder/quicklisp/dists/quicklisp/software/gamebox-frame-manager-20180228-git/gamebox-frame-manager.asd

Systems

gamebox-frame-manager (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 gamebox-frame-manager/package.lisp

Parent

gamebox-frame-manager (system)

Location

package.lisp

Packages

box.frame


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.3 gamebox-frame-manager/log.lisp

Dependency

package.lisp (file)

Parent

gamebox-frame-manager (system)

Location

log.lisp


Previous: , Up: Lisp files   [Contents][Index]

3.1.4 gamebox-frame-manager/frame-manager.lisp

Dependency

log.lisp (file)

Parent

gamebox-frame-manager (system)

Location

frame-manager.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 box.frame

Source

package.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Functions

Function: tick FRAME-MANAGER REFRESH-RATE STEP-FUNC &key PERIODIC-FUNC

This is designed to be called each iteration of a main game loop, which calls STEP-FUNC to update the physics when necessary, based on the DELTA of the frame manager. PERIODIC-FUNC is a function to be called periodically, controlled by the PERIOD-INTERVAL slot of FRAME-MANAGER.

Package

box.frame

Source

frame-manager.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Generic functions

Generic Function: alpha OBJECT

The interpolation factor for the blending of the current frame with the last.

Package

box.frame

Methods
Method: alpha (FRAME-MANAGER frame-manager)

automatically generated reader method

Source

frame-manager.lisp (file)

Generic Function: delta OBJECT

The fraction denoting the desired duration in seconds for a frame.

Package

box.frame

Methods
Method: delta (FRAME-MANAGER frame-manager)

automatically generated reader method

Source

frame-manager.lisp (file)

Generic Function: frame-time OBJECT

The actual duration in seconds of the current frame.

Package

box.frame

Methods
Method: frame-time (FRAME-MANAGER frame-manager)

automatically generated reader method

Source

frame-manager.lisp (file)

Generic Function: total-time OBJECT

The total duration in seconds of all frames that have elapsed.

Package

box.frame

Methods
Method: total-time (FRAME-MANAGER frame-manager)

automatically generated reader method

Source

frame-manager.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Classes

Class: frame-manager ()

An object which keeps track of all the game frame state.

Package

box.frame

Source

frame-manager.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: %start
Initform

(local-time:now)

Slot: %now
Initform

(local-time:now)

Slot: %before
Initform

0

Slot: %total-time
Initform

0

Readers

total-time (generic function)

Slot: %delta
Initargs

:delta

Initform

(/ 30.0)

Readers

delta (generic function)

Slot: %delta-buffer
Initform

0

Slot: %frame-time
Initform

0

Readers

frame-time (generic function)

Slot: %accumulator
Initform

0

Slot: %alpha
Initform

0.0

Readers

alpha (generic function)

Slot: %period-elapsed
Initform

(local-time:now)

Slot: %period-interval
Initargs

:period

Slot: %debug-interval
Initargs

:debug-interval

Initform

5

Slot: %debug-time
Initform

0

Slot: %debug-count
Initform

0


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Functions

Function: calculate-frame-rate FRAME-MANAGER

Calculate the frames-per-second and milliseconds-per-frame, and emits them as a log message.

Package

box.frame

Source

frame-manager.lisp (file)

Function: periodic-update FRAME-MANAGER FUNC

A periodic physics update. If the frame manager class is instantiated with a :period argument, call FUNC every PERIOD-INTERVAL seconds. This is useful when you need to call an expensive operation or perform operations periodically, rather than every game tick.

Package

box.frame

Source

frame-manager.lisp (file)

Function: smooth-delta-time FRAME-MANAGER REFRESH-RATE

Smooth the delta time based on the monitor’s refresh rate. This improves the rendering quality.

Package

box.frame

Source

frame-manager.lisp (file)

Function: update FRAME-MANAGER STEP-FUNC

A single physics update which calls the user-supplied STEP-FUNC when necessary. The ALPHA reader method of the frame manager stores the interpolation coefficient to be used for blending frames in the STEP-FUNC.

Package

box.frame

Source

frame-manager.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   G   L  
Index Entry  Section

F
File, Lisp, gamebox-frame-manager.asd: The gamebox-frame-manager<dot>asd file
File, Lisp, gamebox-frame-manager/frame-manager.lisp: The gamebox-frame-manager/frame-manager<dot>lisp file
File, Lisp, gamebox-frame-manager/log.lisp: The gamebox-frame-manager/log<dot>lisp file
File, Lisp, gamebox-frame-manager/package.lisp: The gamebox-frame-manager/package<dot>lisp file

G
gamebox-frame-manager.asd: The gamebox-frame-manager<dot>asd file
gamebox-frame-manager/frame-manager.lisp: The gamebox-frame-manager/frame-manager<dot>lisp file
gamebox-frame-manager/log.lisp: The gamebox-frame-manager/log<dot>lisp file
gamebox-frame-manager/package.lisp: The gamebox-frame-manager/package<dot>lisp file

L
Lisp File, gamebox-frame-manager.asd: The gamebox-frame-manager<dot>asd file
Lisp File, gamebox-frame-manager/frame-manager.lisp: The gamebox-frame-manager/frame-manager<dot>lisp file
Lisp File, gamebox-frame-manager/log.lisp: The gamebox-frame-manager/log<dot>lisp file
Lisp File, gamebox-frame-manager/package.lisp: The gamebox-frame-manager/package<dot>lisp file

Jump to:   F   G   L  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   A   C   D   F   G   M   P   S   T   U  
Index Entry  Section

A
alpha: Exported generic functions
alpha: Exported generic functions

C
calculate-frame-rate: Internal functions

D
delta: Exported generic functions
delta: Exported generic functions

F
frame-time: Exported generic functions
frame-time: Exported generic functions
Function, calculate-frame-rate: Internal functions
Function, periodic-update: Internal functions
Function, smooth-delta-time: Internal functions
Function, tick: Exported functions
Function, update: Internal functions

G
Generic Function, alpha: Exported generic functions
Generic Function, delta: Exported generic functions
Generic Function, frame-time: Exported generic functions
Generic Function, total-time: Exported generic functions

M
Method, alpha: Exported generic functions
Method, delta: Exported generic functions
Method, frame-time: Exported generic functions
Method, total-time: Exported generic functions

P
periodic-update: Internal functions

S
smooth-delta-time: Internal functions

T
tick: Exported functions
total-time: Exported generic functions
total-time: Exported generic functions

U
update: Internal functions

Jump to:   A   C   D   F   G   M   P   S   T   U  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   %  
S  
Index Entry  Section

%
%accumulator: Exported classes
%alpha: Exported classes
%before: Exported classes
%debug-count: Exported classes
%debug-interval: Exported classes
%debug-time: Exported classes
%delta: Exported classes
%delta-buffer: Exported classes
%frame-time: Exported classes
%now: Exported classes
%period-elapsed: Exported classes
%period-interval: Exported classes
%start: Exported classes
%total-time: Exported classes

S
Slot, %accumulator: Exported classes
Slot, %alpha: Exported classes
Slot, %before: Exported classes
Slot, %debug-count: Exported classes
Slot, %debug-interval: Exported classes
Slot, %debug-time: Exported classes
Slot, %delta: Exported classes
Slot, %delta-buffer: Exported classes
Slot, %frame-time: Exported classes
Slot, %now: Exported classes
Slot, %period-elapsed: Exported classes
Slot, %period-interval: Exported classes
Slot, %start: Exported classes
Slot, %total-time: Exported classes

Jump to:   %  
S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   B   C   F   G   P   S  
Index Entry  Section

B
box.frame: The box<dot>frame package

C
Class, frame-manager: Exported classes

F
frame-manager: Exported classes

G
gamebox-frame-manager: The gamebox-frame-manager system

P
Package, box.frame: The box<dot>frame package

S
System, gamebox-frame-manager: The gamebox-frame-manager system

Jump to:   B   C   F   G   P   S