-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
90 lines (72 loc) · 2.13 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using System.Collections.Generic;
namespace GitLearn
{
class Program
{
static void Main(string[] args)
{
int obj1x = 5;
int obj1y = 5;
bool isalive1 = true;
int obj2x = 10;
int obj2y = 10;
bool isalive2 = true;
int obj3x = 15;
int obj3y = 15;
bool isalive3 = true;
Random random = new Random();
while (true)
{
if (obj1x == obj2x && obj1y == obj2y)
{
isalive1 = false;
isalive2 = false;
}
if (obj1x == obj3x && obj1y == obj3y)
{
isalive1 = false;
isalive3 = false;
}
if (obj2x == obj3x && obj2y == obj3y)
{
isalive2 = false;
isalive3 = false;
}
obj1x += random.Next(-1, 1);
obj1y += random.Next(-1, 1);
obj2x += random.Next(-1, 1);
obj2y += random.Next(-1, 1);
obj3x += random.Next(-1, 1);
obj3y += random.Next(-1, 1);
if (obj1x < 0)
obj1x = 0;
if (obj1y < 0)
obj1y = 0;
if (obj2x < 0)
obj2x = 0;
if (obj2y < 0)
obj2y = 0;
if (obj3x < 0)
obj3x = 0;
if (obj3y < 0)
obj3y = 0;
if (isalive1)
{
Console.SetCursorPosition(obj1x, obj1y);
Console.Write("1");
}
if (isalive2)
{
Console.SetCursorPosition(obj2x, obj2y);
Console.Write("2");
}
if (isalive3)
{
Console.SetCursorPosition(obj3x, obj3y);
Console.Write("3");
}
}
}
}
}