Package playn.core

Class Game

java.lang.Object
playn.core.Game

public abstract class Game extends Object
Defines a simple game API. It's not necessary to use this abstraction for your PlayN games, but it takes care of some standard stuff that most games are likely to want.

This implementation separates game processing into two phases: simulation and render. The simulation phase takes place via update and is called with a monotonoically increasing timer at a fixed rate. The interpolation phase takes place via paint and is called every time the game is rendered to the display (which may be more frequently than the simulation is updated). The render phase will generally interpolate the values computed in update to provide smooth rendering based on lower-frequency simulation updates.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final Signal<Clock>
    A signal emitted on every frame.
    final Platform
    The platform on which this game is running.
    final Signal<Clock>
    A signal emitted on every simulation update.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Game(Platform plat, int updateRate)
    Creates a clocked game with the desired simulation update rate, in ms.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    paint(Clock clock)
    Called on every frame.
    void
    update(Clock clock)
    Called on every simulation update.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • plat

      public final Platform plat
      The platform on which this game is running.
    • update

      public final Signal<Clock> update
      A signal emitted on every simulation update.
    • paint

      public final Signal<Clock> paint
      A signal emitted on every frame.
  • Constructor Details

    • Game

      public Game(Platform plat, int updateRate)
      Creates a clocked game with the desired simulation update rate, in ms.
  • Method Details

    • update

      public void update(Clock clock)
      Called on every simulation update. The default implementation emits the clock to the updateClock signal, but you can override this method to change or augment this behavior.
      Parameters:
      clock - a clock configured with the update timing information.
    • paint

      public void paint(Clock clock)
      Called on every frame. The default implementation emits the clock to the paintClock signal, but you can override this method to change or augment this behavior.
      Parameters:
      clock - a clock configured with the frame timing information.