abstract class Scar::System

Overview

Base class for Systems

Systems define behaviours in the application e. g. player movement, ai updates, ..

Example usage:

class MySystem < Scar::System
  def init(app, space)
    puts "MySystem initialized!"
  end

  def update(app, space, dt)
    # Move the player entity
    space["player"].move(Vec.new(10, 0) * dt)
  end

  def render(app, space, dt)
    puts "Executing custom rendering logic..."
  end
end

Direct Known Subclasses

Defined in:

scar/system.cr

Instance Method Summary

Instance Method Detail

def init(app : App, space : Space) #

Override this for one-time initialization

This method is called by the space containing this System on the first frame after it was added.


[View source]
def initialized : Bool #

This property keeps track of wether #init has been called


[View source]
def initialized=(initialized : Bool) #

This property keeps track of wether #init has been called


[View source]
def render(app : App, space : Space, dt) #

Override this for custom rendering logic

This method is called by the space containing this System on every frame before any rendering occurs.


[View source]
def update(app : App, space : Space, dt) #

Override this for any behaviour you want in you application

This method is called by the space containing this System on every frame before any rendering occurs.


[View source]