> 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/app.md).

# App

Each scar application should define a main class which inherits from `Scar::App`. This abstract class contains the basic structure of a scar app and takes care of running all the features of the library such as [events](/scar/application-structure/events.md), [tweens](/scar/builtin-features/tweens.md), [actions](/scar/builtin-features/actions.md) and so on.

You have to define three methods: `init`, `update(dt)` and `render(dt)`. In `init` all the applications' initialization should take place (like loading assets). `update` and `render` are intended for game logic updates and drawing. The class is then created with a SFML window and an Input manager instance (why will be explained in [Input Handling](/scar/builtin-features/input.md))

```ruby
require "scar"
# crsfml, json and yaml are required automatically

class MyCoolGame < Scar::App
    # this simplifies the use of scar features as
    # it removes the need for always typing Scar::
    include Scar
    
    def init
        # setup input
        # load assets
        # build scene
    end
    
    def update
        # update game
    end
    
    def render
        @window.clear(SF::Color::Black)
        # render stuff
    end
end

window = SF::RenderWindow.new(
            SF::VideoMode.new(1600, 900),
            "My cool game",
            SF::Style::Close)
app = MyCoolGame.new(window, Scar::Input.new)
app.run
```

The `init` and `update` functions should not update or draw any entities. They are supposed to be an easy way to update global game status or to debug. [Drawing](/scar/application-structure/drawing.md) is explained in a later section.

At the bottom of the example you can see how a scar app is executed. You just have to create a window and an input manager and pass them to his app class. To start the app, simply call the `App#run` method.

### More stuff

The `Scar::App` class defines getters for the sfml window `window`, the input handler `input`, the scene stack `scene_stack` and the current actions `actions`. Refer to the [reference](https://vypxl.github.io/scar/) for more info.

It also provides the `App#exit` instance method which can be used to exit the program. It unloads all assets and disposes the window before exiting with the given status code.

How [events](/scar/application-structure/events.md), [scenes](/scar/application-structure/scenes.md), [tweens](/scar/builtin-features/tweens.md) and [actions](/scar/builtin-features/actions.md) are handled is be explained in the respective sections of this book.
