> For the complete documentation index, see [llms.txt](https://rhythm-engine.gitbook.io/rhythm-engine/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rhythm-engine.gitbook.io/rhythm-engine/samples/mania-game-sample.md).

# Mania Game Sample

When a note falls on a key, press it.

<figure><img src="https://2453352182-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegXPFnkaY7ySpmnkFA8P%2Fuploads%2Flb8pXNPLmBHuPGlse1Hv%2Fezgif.com-video-to-gif%20(2).gif?alt=media&amp;token=d116b0da-26d9-47d4-b338-9870e8d14980" alt=""><figcaption><p>Mania Showcase</p></figcaption></figure>

<figure><img src="https://2453352182-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegXPFnkaY7ySpmnkFA8P%2Fuploads%2Frl9dyMOScS16ILu0ln7J%2Fimage.png?alt=media&amp;token=a5f77c87-f033-4149-a604-6f1bd13a2d27" alt=""><figcaption><p>Mania Game Scene</p></figcaption></figure>

ManiaDemo GameObject contains 3 scripts which split the gameplay logic into 3 parts: **spawning** notes, gathering **input** and general **gameplay** stuff (like judgements for example).&#x20;

ManiaInputManager.cs gathers input and invokes events for key presses; it also takes care of the visuals of pressing the individual keys.

ManiaNoteManager.cs reads the Song's note list and instantiates notes, moves them down, and destroys them whenever needed.

ManiaGameplayManager.cs makes use of the note and input manager to actually calculate the input timings and offsets.

<figure><img src="https://2453352182-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegXPFnkaY7ySpmnkFA8P%2Fuploads%2FedBwmiMdbZ2tv5Ko1Zy8%2Fimage.png?alt=media&amp;token=84c24ac2-2e49-4db4-a8bc-cbaa502ea259" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2453352182-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegXPFnkaY7ySpmnkFA8P%2Fuploads%2FXq5CEm1ZIku8ORNPOj3M%2Fimage.png?alt=media&amp;token=da630d20-990e-4d7b-9873-a72d5d7c6486" alt="" width="470"><figcaption></figcaption></figure>

ManiaNoteJudgementText.cs makes use of the judgements calculated in the gameplay manager and displays them on UI text.

<figure><img src="https://2453352182-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegXPFnkaY7ySpmnkFA8P%2Fuploads%2FppAWVDmC6Z46mdPOJ0vn%2Fimage.png?alt=media&amp;token=1fbfdca8-2dd3-46d3-bd38-40c0242740c8" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2453352182-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegXPFnkaY7ySpmnkFA8P%2Fuploads%2FtVyCKUSqh8msPv8sELWl%2Fimage.png?alt=media&amp;token=76bb65ed-bb39-4682-a5c6-40559f234e44" alt="" width="459"><figcaption></figcaption></figure>

ManiaSampleTextBounce.cs showcases a simple way of subscribing to (Auto) Beat Sequencer's OnInstrumentStep event to nicely bounce the sample text's scale to the beat of the music.&#x20;

<figure><img src="https://2453352182-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegXPFnkaY7ySpmnkFA8P%2Fuploads%2F5v022Pnpl8tdCqErRIOM%2Fimage.png?alt=media&amp;token=e689d036-3bc0-4c71-9ea8-0b399926f6f2" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2453352182-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegXPFnkaY7ySpmnkFA8P%2Fuploads%2FnKWH1GM9J6CD5FtOPiUy%2Fimage.png?alt=media&amp;token=ee3ae95d-6708-4066-9091-c1c02207e3c0" alt="" width="461"><figcaption></figcaption></figure>
