# A Tutorial Introduction

Let's make your first game. When prosperon is launched, it looks in the folder it's in for a ```config.js``` and ```main.js```. These are your first two examples of a module and a program.

A module is a file that returns a single value. It could be any value: a number, a function, a string. Usually, it's an object. Values are **frozen** before returning, so they cannot be modified. A module is ran once and cached, so any program that accesses a module subsequently is simply getting the already cached object. Modules can import other modules. Circular references are not allowed.

The ```config.js``` module must return a single object that describes your game. It sets up the window name, starting size, etc. Below is the default config, demonstrating all of the values that can be set on it.

| Key                | Default Value                                                   | Type    | Description                                                                                                           |
|--------------------|----------------------------------------------------------------|---------|-----------------------------------------------------------------------------------------------------------------------|
| **title**          | `Prosperon [\${prosperon.version}-\${prosperon.revision}]`   | string  | Title of the game window, typically including version information.                                                   |
| **width**          | `1280`                                                       | number  | Initial width of the game window.                                                                                    |
| **height**         | `720`                                                        | number  | Initial height of the game window.                                                                                   |
| **icon**           | `graphics.make_texture(io.slurpbytes('icons/moon.gif'))`     | object  | Icon texture for the game window, loaded from the provided file.                                                     |
| **high_dpi**       | `0`                                                          | number  | Enables (1) or disables (0) High DPI support for the window.                                                         |
| **alpha**          | `1`                                                          | number  | Alpha channel setting for the window (0 to disable, 1 to enable transparency).                                       |
| **fullscreen**     | `0`                                                          | number  | Sets whether the window should launch in fullscreen (1) or windowed (0).                                             |
| **sample_count**   | `1`                                                          | number  | Multisampling count for rendering. Increasing this can improve image quality at the cost of performance.             |
| **enable_clipboard** | `true`                                                     | boolean | Enables clipboard functionality within the application.                                                              |
| **enable_dragndrop** | `true`                                                     | boolean | Enables drag-and-drop functionality for files into the window.                                                       |
| **max_dropped_files** | `1`                                                       | number  | Maximum number of files that can be dropped into the window at once.                                                 |
| **swap_interval**  | `1`                                                          | number  | Controls vertical synchronization (VSync). Commonly 1 for enabling or 0 for disabling VSync.                         |
| **name**           | `"Prosperon"`                                                | string  | Human-readable name of the application.                                                                              |
| **version**        | `prosperon.version + "-" + prosperon.revision`               | string  | Version string for the application, dynamically built from Prosperon's version info.                                 |
| **identifier**     | `"world.pockle.prosperon"`                                   | string  | Package or bundle identifier for your game/application.                                                              |
| **creator**        | `"Pockle World LLC"`                                         | string  | Name of the creator or organization behind the application.                                                          |
| **copyright**      | `"Copyright Pockle World 2025"`                              | string  | Copyright declaration for the application.                                                                           |
| **type**           | `"application"`                                              | string  | The general content type or category of this project.                                                                |
| **url**            | `"https://github.com/johnbrethauer/prosperon"`               | string  | URL link associated with the project, such as a repository or official homepage.                                     |


With the engine configured, prosperon starts ```main.js``` as the first **actor** of the game. Actors are created from files that **do not** return a value. An actor executes the statements in its script. Initialization should happen here. An actor can pull in other chunks of code by importing modules. Modules are imported with the ```use``` statement. ```use``` returns the value the module returned, and it can be assigned to any variable. To use the internal ```io``` module, for example, you might say ```var io = use('io')```.

Actors exist until they are explicitly killed, by invoking their ```kill``` function. Because the actor created from ```main.js``` is the root actor for the entire game, when it is killed, the program exits. In an actor script file, ```this``` is set to the actor being spawned from the script.

## Our first program
With that out of the way, we can establish our first simple program.

In the folder with your ```prosperon``` executable, create a ```config.js``` and set it to be the following:

```
return {
  title: "Hello World",
  width: 500,
  height:500
}
```

This will cause prosperon to launch a 500x500 window with the title 'Hello World'. In your ```main.js```, write the following:

```
console.log("Hello world")

this.delay(_ => {
  this.kill();
}, 3)
```

**delay** is a function on all actors in prosperon. It executes a given function after a number of seconds. In this case, after 3 seconds, the root actor kills itself, closing the window.

## The prosperon global
The global object called `prosperon` has a variety of engine specific settings on it that can be set to influence how the engine behaves. For example, `prosperon.argv` contains a list of the command line arguments given to prosperon; `prosperon.PATH` is an array of paths to resolve resources such as modules and images. `prosperon` is fully documented in the API section.

## Getting help
The `prosperon` global has a 'doc' function, which can be invoked on any engine object to see a description of it and its members. For example, to learn about `prosperon`, try printing out `prosperon.doc(prosperon)` in your `main.js`.

Writing documentation for your own modules and game components will be explored in the chapter on actors & modules.