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;
- namespace Colour_Game
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.SetWindowSize(80, 19);
- Console.SetBufferSize(80, 19);
- Console.CursorVisible = false;
- Game game = new Game();
- Console.ForegroundColor = ConsoleColor.White;
- Console.SetCursorPosition(34, 1);
- Console.WriteLine("COLOUR GAME");
- Console.WriteLine("\nThe Objective of The Game is to Follow The Colours Presented in The Right Order.");
- Console.SetCursorPosition(21, 5);
- Console.WriteLine("Every Turn One New Move Will be Added.");
- Console.SetCursorPosition(28, 7);
- Console.WriteLine("What Score Can You Get?");
- Console.SetCursorPosition(34, 13);
- Console.WriteLine("<P> to Play");
- Console.SetCursorPosition(34, 17);
- Console.WriteLine("<X> to Exit");
- Console.ForegroundColor = ConsoleColor.Black;
- ConsoleKeyInfo launch = Console.ReadKey();
- if (launch.Key == ConsoleKey.P)
- {
- Console.Clear();
- game.DefColours();
- game.Start();
- game.Score();
- while (true)
- {
- game.RandomSelection();
- }
- }
- else
- {
- System.Environment.Exit(0);
- }
- Console.ReadLine();
- }
- }
- class Game
- {
- static int score = 0, inputNew, x;
- private List<Sequence> sqc = new List<Sequence>();
- public void DefColours()
- {
- for (int i = 0; i <= 15; i++)
- {
- Console.BackgroundColor = ConsoleColor.Red;
- Console.SetCursorPosition(0, i);
- Console.WriteLine(" ");
- Console.SetCursorPosition(9, 2);
- Console.ForegroundColor = ConsoleColor.White;
- Console.WriteLine("R");
- Console.SetCursorPosition(9, 13);
- Console.WriteLine("1");
- }
- for (int i = 0; i <= 15; i++)
- {
- Console.BackgroundColor = ConsoleColor.Green;
- Console.SetCursorPosition(20, i);
- Console.WriteLine(" ");
- Console.SetCursorPosition(30, 2);
- Console.ForegroundColor = ConsoleColor.Black;
- Console.WriteLine("G");
- Console.SetCursorPosition(30, 13);
- Console.WriteLine("2");
- }
- for (int i = 0; i <= 15; i++)
- {
- Console.BackgroundColor = ConsoleColor.Blue;
- Console.SetCursorPosition(40, i);
- Console.WriteLine(" ");
- Console.SetCursorPosition(50, 2);
- Console.ForegroundColor = ConsoleColor.White;
- Console.WriteLine("B");
- Console.SetCursorPosition(50, 13);
- Console.WriteLine("3");
- }
- for (int i = 0; i <= 15; i++)
- {
- Console.BackgroundColor = ConsoleColor.Yellow;
- Console.SetCursorPosition(60, i);
- Console.WriteLine(" ");
- Console.SetCursorPosition(70, 2);
- Console.ForegroundColor = ConsoleColor.Black;
- Console.WriteLine("Y");
- Console.SetCursorPosition(70, 13);
- Console.WriteLine("4");
- }
- }
- public void Start()
- {
- Console.BackgroundColor = ConsoleColor.Black;
- Console.ForegroundColor = ConsoleColor.White;
- Console.SetCursorPosition(34, 17);
- Console.WriteLine("<S> to Start");
- Console.ForegroundColor = ConsoleColor.Black;
- ConsoleKeyInfo start = Console.ReadKey();
- if (start.Key == ConsoleKey.S)
- {
- Console.SetCursorPosition(0, Console.CursorTop - 1);
- Console.Write(new string(' ', Console.WindowWidth));
- }
- else
- {
- System.Environment.Exit(0);
- }
- }
- public void Score()
- {
- Console.BackgroundColor = ConsoleColor.Black;
- Console.ForegroundColor = ConsoleColor.White;
- Console.SetCursorPosition(35, 17);
- Console.WriteLine("SCORE: {0}", score);
- Console.ForegroundColor = ConsoleColor.Black;
- }
- public void RandomSelection()
- {
- Random rnd = new Random();
- int random = rnd.Next(1, 5);
- sqc.Add(new Sequence() { value = random });
- foreach (var x in sqc)
- {
- System.Threading.Thread.Sleep(250);
- if (x.value == 1)
- {
- for (int i = 0; i <= 15; i++)
- {
- Console.BackgroundColor = ConsoleColor.White;
- Console.SetCursorPosition(0, i);
- Console.WriteLine(" ");
- Console.SetCursorPosition(9, 2);
- Console.ForegroundColor = ConsoleColor.Black;
- Console.WriteLine("R");
- Console.SetCursorPosition(9, 13);
- Console.WriteLine("1");
- }
- }
- else if (x.value == 2)
- {
- for (int i = 0; i <= 15; i++)
- {
- Console.BackgroundColor = ConsoleColor.White;
- Console.SetCursorPosition(20, i);
- Console.WriteLine(" ");
- Console.SetCursorPosition(30, 2);
- Console.ForegroundColor = ConsoleColor.Black;
- Console.WriteLine("G");
- Console.SetCursorPosition(30, 13);
- Console.WriteLine("2");
- }
- }
- else if (x.value == 3)
- {
- for (int i = 0; i <= 15; i++)
- {
- Console.BackgroundColor = ConsoleColor.White;
- Console.SetCursorPosition(40, i);
- Console.WriteLine(" ");
- Console.SetCursorPosition(50, 2);
- Console.ForegroundColor = ConsoleColor.Black;
- Console.WriteLine("B");
- Console.SetCursorPosition(50, 13);
- Console.WriteLine("3");
- }
- }
- else if (x.value == 4)
- {
- for (int i = 0; i <= 15; i++)
- {
- Console.BackgroundColor = ConsoleColor.White;
- Console.SetCursorPosition(60, i);
- Console.WriteLine(" ");
- Console.SetCursorPosition(70, 2);
- Console.ForegroundColor = ConsoleColor.Black;
- Console.WriteLine("Y");
- Console.SetCursorPosition(70, 13);
- Console.WriteLine("4");
- }
- }
- System.Threading.Thread.Sleep(750);
- DefColours();
- }
- UserInput();
- }
- public void UserInput()
- {
- x = 0;
- foreach (var i in sqc)
- {
- Console.SetCursorPosition(x, 18);
- Console.BackgroundColor = ConsoleColor.Black;
- Console.ForegroundColor = ConsoleColor.Black;
- ConsoleKeyInfo input = Console.ReadKey();
- if (input.Key == ConsoleKey.R || input.Key == ConsoleKey.D1)
- {
- inputNew = 1;
- }
- else if (input.Key == ConsoleKey.G || input.Key == ConsoleKey.D2)
- {
- inputNew = 2;
- }
- else if (input.Key == ConsoleKey.B || input.Key == ConsoleKey.D3)
- {
- inputNew = 3;
- }
- else if (input.Key == ConsoleKey.Y || input.Key == ConsoleKey.D4)
- {
- inputNew = 4;
- }
- if (inputNew == sqc[x].value)
- {
- }
- else
- {
- Console.BackgroundColor = ConsoleColor.Black;
- Console.ForegroundColor = ConsoleColor.White;
- Console.Clear();
- Console.SetCursorPosition(35, 6);
- Console.WriteLine("GAME OVER!");
- Console.SetCursorPosition(32, 12);
- Console.WriteLine("YOUR SCORE IS: {0}", score);
- System.Threading.Thread.Sleep(10000);
- System.Environment.Exit(0);
- }
- x++;
- }
- score = score + 1;
- Score();
- RandomSelection();
- }
- }
- class Sequence
- {
- public int value { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement