Змейка - 77 строк на С++

Змейка - 77 строк на С++

Игра C++ и Arctic Engine, подробнее о нем и о goto-ориентированном C++ читайте в моих предыдущих постах.

1 int x = 10; 2 int y = 5; 3 int tx = 9; 4 int ty = 5; 5 At(4,5); 6 Print("*****>>"); 7 loop: 8 if (IsKey(6)) { 9 At(x,y); 10 Print("^"); 11 } 12 if (IsKey(7)) { 13 At(x,y); 14 Print("v"); 15 } 16 if (IsKey(5)) { 17 At(x,y); 18 Print(">"); 19 } 20 if (IsKey(4)) { 21 At(x,y); 22 Print("<"); 23 } 24 int nx = x; 25 int ny = y; 26 string s = Screen(x, y); 27 if (s == "^") { 28 ny = (y + 1) % 18; 29 } 30 if (s == "v") { 31 ny = (y - 1 + 18) % 18; 32 } 33 if (s == ">") { 34 nx = (x + 1) % 32; 35 } 36 if (s == "<") { 37 nx = (x - 1 + 32) % 32; 38 } 39 At(nx, ny); 40 if (Screen(nx, ny) == " ") { 41 Print(s); 42 x = nx; 43 y = ny; 44 string s = Screen(tx, ty); 45 At(tx, ty); 46 Print(" "); 47 if (s == "^") { 48 ty = (ty + 1) % 18; 49 } 50 if (s == "v") { 51 ty = (ty - 1 + 18) % 18; 52 } 53 if (s == ">") { 54 tx = (tx + 1) % 32; 55 } 56 if (s == "<") { 57 tx = (tx - 1 + 32) % 32; 58 } 59 } 60 if (Screen(nx, ny) == "*") { 61 Print(s); 62 x = nx; 63 y = ny; 64 generate: 65 nx = Random32(0, 31); 66 ny = Random32(0, 17); 67 if (Screen(nx, ny) != " ") { 68 goto generate; 69 } 70 At(nx, ny); 71 Print("*"); 72 } 73 Sleep(0.1); 74 Show(); 75 if (IsKey(27) == 0) { 76 goto loop; 77 }
33
7 комментариев

Надеюсь за такой код палкой с гвоздями пиздят

Ответить

Что не так?

1
Ответить