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;
- namespace kalozhajo
- {
- class Program
- {
- static int függ1 = 0;
- static int viz1 = 0;
- static char lépés;
- static int függ2;
- static int viz2;
- static string géplép = "wasd";
- static int db = 0;
- static Random rand = new Random();
- static void Main(string[] args)
- {
- do
- {
- for (int i = 0; i < 2; i++)
- {
- énlépek();
- }
- gép();
- }
- while (!(függ1 == függ2 && viz1 == viz2));
- Console.SetCursorPosition(28, 12);
- Console.WriteLine("#### Nyertél! ####");
- Console.ReadLine();
- }
- static void kiírás()
- {
- Console.Clear();
- Console.SetCursorPosition(viz1, függ1);
- Console.Write("o");
- Console.SetCursorPosition(viz2, függ2);
- Console.Write("x");
- }
- static void énlépek()
- {
- kiírás();
- Console.SetCursorPosition(30, 12);
- lépés = Convert.ToChar(Console.ReadKey().KeyChar);
- if (lépés == 's')
- {
- függ1++;
- if (függ1 > 25)
- {
- függ1 = 25;
- }
- }
- if (lépés == 'a')
- {
- viz1--;
- if (viz1 < 0)
- {
- viz1 = 0;
- }
- }
- if (lépés == 'w')
- {
- függ1--;
- if (függ1 < 0)
- {
- függ1 = 0;
- }
- }
- if (lépés == 'd')
- {
- viz1++;
- if (viz1 > 80)
- {
- viz1 = 80;
- }
- }
- }
- static void gép()
- {
- Console.Clear();
- lépés = géplép[rand.Next(4)];
- if (db == 0)
- {
- viz2 = rand.Next(1, 80);
- függ2 = rand.Next(1, 25);
- Console.SetCursorPosition(viz2, függ2);
- db++;
- }
- if (lépés == 's')
- {
- függ2++;
- if (függ2 > 25)
- {
- függ2 = 25;
- }
- }
- if (lépés == 'a')
- {
- viz2--;
- if (viz2 < 0)
- {
- viz2 = 0;
- }
- }
- if (lépés == 'w')
- {
- függ2--;
- if (függ2 < 0)
- {
- függ2 = 0;
- }
- }
- if (lépés == 'd')
- {
- viz2++;
- if (viz2 > 80)
- {
- viz2 = 80;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement