Upload files to "/"
an example of ZD
This commit is contained in:
90
example.zd
Normal file
90
example.zd
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
using Math;
|
||||||
|
using System as Sys;
|
||||||
|
|
||||||
|
namespace Demo;
|
||||||
|
|
||||||
|
struct Vector2
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Player
|
||||||
|
{
|
||||||
|
string name;
|
||||||
|
int health = 100;
|
||||||
|
bool alive = true;
|
||||||
|
|
||||||
|
int Add(int a, int b)
|
||||||
|
{
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintStatus()
|
||||||
|
{
|
||||||
|
if (health <= 0)
|
||||||
|
{
|
||||||
|
alive = false;
|
||||||
|
}
|
||||||
|
else if (health < 25)
|
||||||
|
{
|
||||||
|
health = health + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
health = health;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
while (i < 3)
|
||||||
|
{
|
||||||
|
health = health - 10;
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < 5; i = i + 1)
|
||||||
|
{
|
||||||
|
if (i == 3)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repeat (2)
|
||||||
|
{
|
||||||
|
health = health + 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Game
|
||||||
|
{
|
||||||
|
Player player;
|
||||||
|
|
||||||
|
void Main()
|
||||||
|
{
|
||||||
|
player = new Player
|
||||||
|
{
|
||||||
|
name = "Hero";
|
||||||
|
health = 75;
|
||||||
|
};
|
||||||
|
|
||||||
|
int score = 0;
|
||||||
|
bool running = true;
|
||||||
|
|
||||||
|
if (running && player.health > 0)
|
||||||
|
{
|
||||||
|
score = player.Add(10, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.Update();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user