# Viewmodel

VM has only 2 variables whose updates trigger function updates.

<figure><img src="https://2666578692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FprL5jbtTDARElFG53w1w%2Fuploads%2FScfvSUNOP0s3IYzdEItn%2FScreenshot%202024-10-12%20at%2016.56.56.png?alt=media&#x26;token=1c5e2f3f-2804-4b1d-af4f-0a1e27e12950" alt="" width="563"><figcaption><p>Health Variable</p></figcaption></figure>

<figure><img src="https://2666578692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FprL5jbtTDARElFG53w1w%2Fuploads%2F0fA4POMbC9Vg0x09kEA2%2FScreenshot%202024-10-12%20at%2016.57.15.png?alt=media&#x26;token=7fd3b670-4380-4cef-85b3-6bc62c0f14e4" alt="" width="563"><figcaption><p>MaxHealth Variable</p></figcaption></figure>

Functions must always have only one return value, and must also have the attributes: pure and const. Two examples are given below.

<figure><img src="https://2666578692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FprL5jbtTDARElFG53w1w%2Fuploads%2Fj6JREnkmDU3rlCZUxqwq%2FScreenshot%202024-10-12%20at%2017.00.00.png?alt=media&#x26;token=717114ff-60e4-4b44-a8af-2f8ddaa71ddc" alt="" width="563"><figcaption><p>GetPercent() Properties</p></figcaption></figure>

<figure><img src="https://2666578692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FprL5jbtTDARElFG53w1w%2Fuploads%2FqHiDAeSmOYwj0fDxr9Ee%2FScreenshot%202024-10-12%20at%2017.01.46.png?alt=media&#x26;token=6684d972-d278-4118-a494-92063735c2ae" alt="" width="563"><figcaption><p>IsAlive() Properties</p></figcaption></figure>

The following is the content of the functions, for a better understanding of this example.

<figure><img src="https://2666578692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FprL5jbtTDARElFG53w1w%2Fuploads%2FwLdOywlAlxbmbbHaonX2%2FScreenshot%202024-10-12%20at%2017.05.13.png?alt=media&#x26;token=84f105a9-0b76-4b90-baf8-f0bdffa59058" alt="" width="563"><figcaption><p>GetPercent()</p></figcaption></figure>

<figure><img src="https://2666578692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FprL5jbtTDARElFG53w1w%2Fuploads%2FeWGHG700ub8Xa9BmBp2W%2FScreenshot%202024-10-12%20at%2017.05.23.png?alt=media&#x26;token=cf0544fe-dac7-44cb-b84a-67927cbd8742" alt="" width="563"><figcaption><p>GetInvertedPercent()</p></figcaption></figure>

<figure><img src="https://2666578692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FprL5jbtTDARElFG53w1w%2Fuploads%2FcriidKf334Oz2nmEBDYa%2FScreenshot%202024-10-12%20at%2017.06.38.png?alt=media&#x26;token=da7614f0-732b-4c1c-b381-15322b3dd9a7" alt="" width="563"><figcaption><p>IsVisible()</p></figcaption></figure>

<figure><img src="https://2666578692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FprL5jbtTDARElFG53w1w%2Fuploads%2FTEAjeVBXk1lBAhvswmc8%2FScreenshot%202024-10-12%20at%2017.07.17.png?alt=media&#x26;token=d97b8a19-221a-4f8c-b51f-30cf4c77c28f" alt="" width="563"><figcaption><p>IsAlive()</p></figcaption></figure>

<figure><img src="https://2666578692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FprL5jbtTDARElFG53w1w%2Fuploads%2Fwz3zLuyUuaWqQKON4XN8%2FScreenshot%202024-10-12%20at%2017.07.27.png?alt=media&#x26;token=a51bd6ec-f443-48f1-a28a-308a4da53d8a" alt="" width="563"><figcaption><p>IsDead()</p></figcaption></figure>

<figure><img src="https://2666578692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FprL5jbtTDARElFG53w1w%2Fuploads%2Fgq8jIOM4UC2W19PZAPFO%2FScreenshot%202024-10-12%20at%2017.07.35.png?alt=media&#x26;token=be3dea41-f002-4d77-b34d-834d4f3190b9" alt="" width="563"><figcaption><p>IsFull()</p></figcaption></figure>
