> For the complete documentation index, see [llms.txt](https://pearl-docs.disco.zone/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pearl-docs.disco.zone/guides/creating-gameplay-with-components.md).

# Creating Gameplay with Components

{% hint style="warning" %}
This documentation hasn't been finished yet! Sorry about that.
{% endhint %}

Pearl is a framework built around the [Component pattern](http://gameprogrammingpatterns.com/component.html). Lots of big fancy game frameworks, like Unity and Unreal Engine, use this pattern, so you might find it familiar. If not, don't fret!

If you're familiar with OOP, you might best think of components as *really fancy mixins/traits*. In a component system, you have "entities" (in our case, actual entities in the game world), which are objects that only hold a few things:

* Metadata that makes it possible to identify what *kind* of entity this is. In Pearl, this is a *name* that gets set on an object, plus optional tags to further identify the entity. For example, if you were building a Pac-Man clone, you might create four ghost objects with their own name (e.g. `Inky`, `Blinky`, `Pinky`, and `Clyde`), but all sharing a `ghost` tag.
* A list of components that make up the entity. For a Pac-Man ghost, each ghost might have a `SpriteRenderer` to determine what to render and a `Physical` component determining its place in the game world. Since each ghost has different AI, you would then add different components to each ghost for their AI - e.g. `InkyAI`, `BlinkyAI` - that might all subclass a base `GhostAI` component.

Components can easily reference sibling components on the same component - for example, the `GhostAI` component could look up the `Physical` component to determine where it currently is, and make decisions based on the entity's current location.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://pearl-docs.disco.zone/guides/creating-gameplay-with-components.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
