scar
  • The scar game library
  • Application Structure
    • App
    • Scenes
    • Spaces
    • Entities
    • Components
    • Systems
    • Objects
    • Drawing
    • Events
  • Builtin Features
    • Actions
    • Assets
    • Config
    • Input
    • Logger
    • Music
    • Tweens
    • Util
    • Vectors & Rects
  • Builtin Components
    • Text
    • Sprite
    • Animated Sprite
  • Builtin Systems
    • Animate Sprites
Powered by GitBook
On this page

Was this helpful?

  1. Application Structure

Systems

PreviousComponentsNextObjects

Last updated 5 years ago

Was this helpful?

Systems are where all game logic should happen. Systems move , react to input, draw text and so on.

The Scar::System class is, just like Scar::Component, an abstract class but it declares three overridable methods: init, update and render. init should contain initialization logic, update should contain game logic while render should contain drawing logic. The last two get the current , the current and the delta time as parameters, init does not get a delta time.

There are many builtin systems available, you can find them in the 'Builtin Systems' chapter of this book.

Example

class PlayerSystem < Scar::System
    include Scar
    
    def update(app : App, space: Space, dt)
        space.each_with Components::PlayerComponent do |ent, player|
            ent.position.x += player.health * dt            
        end
    end
end
entities
app
space