Coder Social home page Coder Social logo

gamebox-frame-manager's 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
                                             :dt-target (/ 1 30.0)))

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

(defclass my-game (frame-manager)
  ((dt-target :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 slog:*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 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 Michael Fiano [email protected].

Licensed under the MIT License.

A copy of the license is available here.

gamebox-frame-manager's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.