> For the complete documentation index, see [llms.txt](https://vypxl.gitbook.io/scar/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vypxl.gitbook.io/scar/application-structure/systems.md).

# Systems

Systems are where all game logic should happen. Systems move [entities](/scar/application-structure/entities.md), 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 [app](/scar/application-structure/app.md), the current [space](/scar/application-structure/spaces.md) 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

```ruby
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
```
