Components
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 sprite. 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
Last updated
Was this helpful?