Update example.zd

This commit is contained in:
2026-05-06 20:49:12 -04:00
parent b470109fea
commit 979d9323cd

View File

@@ -1,90 +1,92 @@
using Math; using Math;
using System as Sys; using System as Sys;
namespace Demo; // this is a comment
struct Vector2 namespace Demo;
{
int x; struct Vector2
int y; {
} int x;
int y;
class Player }
{
string name; class Player
int health = 100; {
bool alive = true; string name;
int health = 100;
int Add(int a, int b) bool alive = true;
{
return a + b; int Add(int a, int b)
} {
return a + b;
void PrintStatus() }
{
if (health <= 0) void PrintStatus()
{ {
alive = false; if (health <= 0)
} {
else if (health < 25) alive = false;
{ }
health = health + 1; else if (health < 25)
} {
else health = health + 1;
{ }
health = health; else
} {
} health = health;
}
void Update() }
{
int i = 0; void Update()
{
while (i < 3) int i = 0;
{
health = health - 10; while (i < 3)
i = i + 1; {
} health = health - 10;
i = i + 1;
for (i = 0; i < 5; i = i + 1) }
{
if (i == 3) for (i = 0; i < 5; i = i + 1)
{ {
break; if (i == 3)
} {
} break;
}
repeat (2) }
{
health = health + 5; repeat (2)
} {
health = health + 5;
return; }
}
} return;
}
class Game }
{
Player player; class Game
{
void Main() Player player;
{
player = new Player void Main()
{ {
name = "Hero"; player = new Player
health = 75; {
}; name = "Hero";
health = 75;
int score = 0; };
bool running = true;
int score = 0;
if (running && player.health > 0) bool running = true;
{
score = player.Add(10, 20); if (running && player.health > 0)
} {
score = player.Add(10, 20);
player.Update(); }
return; player.Update();
}
return;
}
} }