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

Components

PreviousEntitiesNextSystems

Last updated 5 years ago

Was this helpful?

Components contain data for entities or act as tags. You have to create you own components by inheriting from the abstract Scar::Component or use the builtin ones.

There are numerous builtin components such as . You can find them in the 'Builtin Components' chapter of this book.

class PlayerComponent < Scar::Component
    property :health, :attack
    def initialize(@health: Int32, @attack: Int32)
    end
end
...
# e. g. in app#init 
player = Entity.new("player",
    PlayerComponent.new(1337, 42),
    position: Vec.new(128, 128)
)

scene["level"] << player
sprite