Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using System.Threading;
- namespace ConsoleApp61
- {
- class Program
- {
- static void Main(string[] args)
- {
- char[,] intro1;
- sozdanieintro(out intro1,"intro1.txt");
- char[,] intro2;
- sozdanieintro(out intro2, "intro2.txt");
- char[,] intro3;
- sozdanieintro(out intro3, "intro3.txt");
- char[,] intro4;
- sozdanieintro(out intro4, "intro4.txt");
- char[,] intro5;
- sozdanieintro(out intro5, "intro5.txt");
- char[,] intro6;
- sozdanieintro(out intro6, "intro6.txt");
- char[,] alien1;
- sozdanieintro(out alien1, "alien1.txt");
- char[,] alien2;
- sozdanieintro(out alien2, "alien1.txt");
- Console.CursorVisible = false;
- int width = Console.WindowWidth;
- int height = Console.WindowHeight;
- Console.WindowWidth = width;
- Console.WindowHeight = height;
- string Hello = "Медленно нажимайте Enter, чтобы прочитать интро:)";
- string Hello1 = "Нажмите Enter для продолжения";
- Console.SetCursorPosition(width/2-Hello.Length/2,10);
- Console.Write(Hello);
- Console.SetCursorPosition(width / 2 - Hello.Length / 2, 11);
- Console.Write(Hello1);
- Console.ReadLine();
- Console.Clear();
- Console.BackgroundColor = ConsoleColor.White;
- Console.ForegroundColor = ConsoleColor.Black;
- for (int i = 0; i < width; i++)
- {
- for (int j = 0; j < height*3/2; j++)
- {
- Console.SetCursorPosition(i, j);
- Console.Write(" ");
- }
- Console.WriteLine();
- }
- Console.SetCursorPosition(0, 0);
- Console.WriteLine();
- Console.SetCursorPosition(0, 0);// норм расположение картинки
- Console.SetCursorPosition(50, 20);// текст
- int end = 0;
- Thread thr = new Thread(new ThreadStart(Program.intro));
- thr.Start();
- Thread.Sleep(350);
- //приветствие
- Console.SetCursorPosition(35, 20);
- Console.Write("Ну здарова!");
- Console.SetCursorPosition(35, 22);
- Console.Write("Зря ты появился в этом гребаном месте...");
- Console.ReadLine();
- Console.SetCursorPosition(35, 20);
- Console.Write(" ");
- Console.SetCursorPosition(35, 22);
- Console.Write(" ");
- Console.SetCursorPosition(35, 20);
- Console.Write("Я хотел просто жрать, спать, сидеть в инете");
- Console.SetCursorPosition(35, 22);
- Console.Write("Но потом явились они....");
- Console.ReadLine();
- Console.SetCursorPosition(35, 20);
- Console.Write(" ");
- Console.SetCursorPosition(35, 22);
- Console.Write(" ");
- Console.SetCursorPosition(35, 20);
- Console.Write("Эти уроды отняли у меня всё что было");
- Console.SetCursorPosition(35, 22);
- Console.Write("ПОРВЕМ КОЗЛОВ ЗА ИНЕТ!");
- Console.ReadLine();
- thr.Abort();
- thr.Join(500);
- Console.Clear();
- music();
- vuvodintro(intro1,0,0);
- Thread.Sleep(500);
- vuvodintro(intro2,0,0);
- Thread.Sleep(500);
- vuvodintro(intro3,0,0);
- Thread.Sleep(500);
- vuvodintro(intro4,0,0);
- Thread.Sleep(500);
- vuvodintro(intro5,0,0);
- Thread.Sleep(500);
- vuvodintro(intro6,0,0);
- Console.Clear();
- Console.SetCursorPosition(15, 6);
- Console.Write("Приветствую вас. В игре надо убивать монстров");
- Console.SetCursorPosition(15, 7);
- Console.Write("которые двигаются либо по верхней дорожке");
- Console.SetCursorPosition(15, 8);
- Console.Write("либо по нижней");
- Console.SetCursorPosition(15, 10);
- Console.Write("Перемещаться между дорожками Up и Down, соотвественно");
- Console.SetCursorPosition(15, 12);
- Console.Write("Стрелять на клавишу А");
- Console.SetCursorPosition(15, 14);
- Console.Write("P.S. Нельзя чтобы монстры дошли до вашего оружия!");
- Console.SetCursorPosition(15, 16);
- Console.Write("Нажмите Enter для начала игры");
- Console.ReadLine();
- Console.Clear();
- vuvodintro(intro6, 0, 0);
- int score = 0;
- Console.SetCursorPosition(0, 18);
- for (int i = 0; i < width / 2 - 5; i++)
- {
- Console.Write("#");
- }
- Console.Write(" СЧЕТ: " + score);
- Console.SetCursorPosition(width / 2 + 5, 18);
- Console.Write("#");
- for (int i = width / 2 + 6; i < width; i++)
- Console.Write("#");
- int down = 1;
- int up = 0;
- int bes1 = 0;
- int bes2 = 1;
- ConsoleKeyInfo Key;
- end = 0;
- int vustrel1 = 0;
- int vustrel2 = 0;
- int rang1 = 1;
- int rang2 = 1;
- int alienX = 0;
- int alienXX = 0;
- Random rnd1 = new Random();//снизу или сверху
- Random rnd2 = new Random();// шанс
- Console.WindowHeight = height * 3 / 2;
- int alienhero1 = 0;
- int alienhero2 = 0;
- int finish1 = 0;
- int finish2 = 0;
- int we = 0;
- while (end<2)
- {
- if (Console.KeyAvailable)
- {
- Key = Console.ReadKey(true);
- switch (Key.Key)
- {
- case ConsoleKey.UpArrow:
- if (up == 1)
- {
- vuvodintro(intro6,0,0);
- vuvodscore(ref score);
- down = 1;
- bes1 = 1;
- up = 0;
- }
- break;
- case ConsoleKey.DownArrow:
- if( down==1)
- {
- vuvodintro(intro6,0,20);
- vuvodscore(ref score);
- down = 0;
- bes2 = 0;
- up = 1;
- }
- break;
- case ConsoleKey.A:
- if (up == 0)
- {
- Console.SetCursorPosition(27, 9);
- vustrel1 = 1;
- }
- if( down ==0)
- {
- Console.SetCursorPosition(27, 29);
- vustrel2 = 1; ;
- }
- break;
- }
- }
- if (vustrel1 == 1)
- {
- kill(ref vustrel1, ref rang1, 9, ref alienX, ref alienhero1, ref alien1,ref score);
- }
- if (vustrel2 == 1)
- {
- kill(ref vustrel2, ref rang2, 29, ref alienXX, ref alienhero2, ref alien2,ref score);
- }
- Thread.Sleep(30);
- if (rang1 == 30 )
- {
- Console.SetCursorPosition(27 + rang1, 9);
- Console.Write(" ");
- rang1 = 0;
- vustrel1 = 0;
- }
- if (rang2 == 30)
- {
- Console.SetCursorPosition(27 + rang2, 29);
- Console.Write(" ");
- rang2 = 0;
- vustrel2 = 0;
- }
- if (vustrel1 == 1 )
- {
- rang1++;
- }
- if (vustrel2 == 1)
- {
- rang2++;
- }
- if (rnd1.Next(100) < 5 && alienhero1 == 0)
- {
- poyav(ref alienhero1, ref finish1, ref alienX, ref alien1, 3);
- }
- if (rnd1.Next(100) < 5 && alienhero2 == 0)
- {
- poyav(ref alienhero2, ref finish2, ref alienXX, ref alien2, 23);
- }
- if (alienhero1 == 1)
- {
- move(ref alienX,ref alien1, ref finish1,9);
- }
- if (alienhero2 == 1)
- {
- move(ref alienXX, ref alien2, ref finish2, 29);
- }
- if (finish1 == 30)
- {
- Console.Clear();
- Console.SetCursorPosition(width / 2-20, 15);
- Console.WriteLine("ВЫ ПРОИГРАЛИ!");
- Console.SetCursorPosition(width / 2-20, 16);
- Console.WriteLine("Количество очков которые вы набрали: " + score);
- Console.ReadLine();
- break;
- }
- if (finish2 == 30)
- {
- Console.Clear();
- Console.SetCursorPosition(width / 2-20, 15);
- Console.WriteLine("ВЫ ПРОИГРАЛИ!");
- Console.SetCursorPosition(width / 2-20, 16);
- Console.WriteLine("Количество очков которые вы набрали: "+ score);
- Console.ReadLine();
- break;
- }
- vuvodscore(ref score);
- }
- }
- static void move(ref int move, ref char[,] alien,ref int finish,int coor)
- {
- int width = Console.WindowWidth;
- move--;
- for (int j = 0; j < alien.GetLength(1); j++)
- {
- for (int i = 0; i < alien.GetLength(0); i++)
- {
- Console.SetCursorPosition(width - 17 + i + move, coor-6 + j);
- Console.Write(alien[j, i]);
- finish = width - 17 + i + move;
- }
- }
- }
- static void kill(ref int shot, ref int rang, int coor, ref int move, ref int monster, ref char[,] alien,ref int score)
- {
- int width = Console.WindowWidth;
- //coor=9;
- Console.SetCursorPosition(27 + rang, coor);
- int srav1 = 27 + rang;
- if (srav1 == width - 17 + move || srav1 == width - 16 + move || srav1 == width - 15 + move)
- {
- Console.SetCursorPosition(27 + rang - 1, coor);
- Console.Write(" ");
- score++;
- monster = 0;
- shot = 0;
- rang = 0;
- //исчезает монстр
- for (int j = 0; j < alien.GetLength(1); j++)
- {
- for (int i = 0; i < alien.GetLength(0); i++)
- {
- Console.SetCursorPosition(width - 17 + i + move, coor-6 + j);
- Console.Write(" ");
- }
- }
- }
- else
- {
- Console.Write(">");
- Console.SetCursorPosition(26 + rang, coor);
- Console.Write(" ");
- }
- }
- static void poyav(ref int monster,ref int finish,ref int move,ref char[,]alien,int coor)
- {
- //(ref alienhero1,ref qw,ref alienX,ref alien1);
- int width = Console.WindowWidth;
- monster = 1;
- finish = 0;
- move = 0;
- for (int j = 0; j < alien.GetLength(1); j++)
- {
- for (int i = 0; i < alien.GetLength(0); i++)
- {
- Console.SetCursorPosition(width - 17 + i, coor + j);
- Console.Write(alien[j, i]);
- }
- }
- }
- static void vuvodscore(ref int score)
- {
- int width = Console.WindowWidth;
- Console.SetCursorPosition(0, 18);
- for (int i = 0; i < width / 2 - 5; i++)
- {
- Console.Write("#");
- }
- Console.Write(" СЧЕТ: " + score);
- Console.SetCursorPosition(width / 2 + 5, 18);
- Console.Write("#");
- for (int i = width / 2 + 6; i < width; i++)
- Console.Write("#");
- }
- static void vuvodintro(char[,]intro,int q,int w)
- {
- Console.Clear();
- Console.SetCursorPosition(q, w);
- for (int i = 0; i < intro.GetLength(0); i++)
- {
- for (int j = 0; j < intro.GetLength(1); j++)
- {
- Console.Write(intro[i, j]);
- }
- Console.WriteLine();
- }
- }
- static void sozdanieintro(out char[,]intro,string sre)
- {
- string[] NewFile = File.ReadAllLines(sre);
- intro = new char[NewFile.Length, NewFile[1].Length];
- for (int i = 0; i < intro.GetLength(0); i++)
- {
- for (int j = 0; j < intro.GetLength(1); j++)
- {
- intro[i, j] = NewFile[i][j];
- }
- }
- }
- static void music()
- {
- System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"duck.wav");
- player.Play();
- }
- public static void intro()
- {
- string[] NewFile = File.ReadAllLines("intro1.txt");
- char[,] map = new char[NewFile.Length, NewFile[1].Length];
- for (int i = 0; i < map.GetLength(0); i++)
- {
- for (int j = 0; j < map.GetLength(1); j++)
- {
- map[i, j] = NewFile[i][j];
- }
- }
- Console.SetCursorPosition(0, 0);
- for (int i = 0; i < map.GetLength(0); i++)
- {
- for (int j = 0; j < map.GetLength(1); j++)
- {
- Console.Write(map[i, j]);
- }
- Console.WriteLine();
- }
- int napr = 0;
- int bok = -1;
- int vverh = 0;
- int end = 0;
- int s4et = 0;
- Random rnd4 = new Random();
- while (end < 2)
- {
- Console.SetCursorPosition(61 + bok, 15 + vverh);// дым начинается
- Console.WriteLine("$");
- if (bok == -4)
- {
- napr = 1;
- s4et = 0;
- }
- if (bok == 4)
- {
- napr = 0;
- }
- if (napr == 1)
- bok++;
- if (napr == 0)
- bok--;
- vverh--;
- if (vverh == -15)
- {
- vverh = 0;
- if (napr == 1)
- {
- napr = 0;
- }
- if (napr == 0)
- {
- napr = 1;
- }
- }
- Thread.Sleep(250);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement