using System;
using System.Collections.Generic;
using System.Text;

namespace Grupp1_Pong
{
    class Program
    {
        const int broatn = 80;
        const int heachn = 25;
        const int Paddlelengen = 5;
        
        public static char[,] Spuelfeld = new char[broatn,heachn];

        public static char untermBolln;

        static void Main(string[] args)
        {

            DrawCourt(broatn, heachn);
            Play();

            Console.ReadLine();
        }

        static void PrintCharAt(int xPos, int yPos, ConsoleColor Forb, char Zeichn)
        {
            Console.SetCursorPosition(xPos, yPos);
            Console.ForegroundColor = Forb;
            Console.Write(Zeichn);
            Spuelfeld[xPos, yPos] = Zeichn;
        
        }

        static char getCharAt(int xPos, int yPos)
        {
            return Spuelfeld[xPos, yPos];
        }

        static void DrawCourt(int broat, int hoach)
        {
            
            for (int i = 0; i < broat; i++)
            {
                PrintCharAt(i,0,ConsoleColor.White,'=');
                PrintCharAt(i,hoach-1, ConsoleColor.White, '=');

            }
            for (int i = 0; i < hoach; i += 2)
            {
                PrintCharAt(broat/2, i, ConsoleColor.White, '|');
            }

        }

        static void DaPaddle(int xPos, int yPos)
        {
            for (int i = 0; i < Paddlelengen; i++)
            {
                PrintCharAt(xPos, i+yPos, ConsoleColor.Yellow, '#');
            }
        }

        static void DaBoin(int xPos, int yPos, bool Sechata)
        {
            
            if (Sechata)
            {
                untermBolln = getCharAt(xPos, yPos);
                PrintCharAt(xPos, yPos, ConsoleColor.Green, 'o');
            }
            else
            {
                PrintCharAt(xPos, yPos, ConsoleColor.White, untermBolln);
            }
        }


        static void Play()
        {
            int Paddlelincks = (heachn-Paddlelengen)/2;
            int Paddlerechts = (heachn-Paddlelengen)/2;

            int BoinX = broatn / 2, BoinY = heachn / 2;
            int BoiVecX = 1, BoiVecY = 1;

            int ScoreLinks = 0, ScoreRechts = 0;

            ConsoleKeyInfo Taste;

            DaBoin(BoinX, BoinY, true);

            for (;;)
            {

                System.Threading.Thread.Sleep(70);

                if (Console.KeyAvailable)
                {
                    Taste=Console.ReadKey(true);
                    switch (Taste.KeyChar)
                    {
                        case 'w':
                            if (Paddlelincks > 1)
                            {
                                Paddlelincks -= 1;
                                PrintCharAt(0, Paddlelincks + Paddlelengen, ConsoleColor.Black, ' ');
                            }
                            break;

                        case 's':
                            if (Paddlelincks < heachn - Paddlelengen - 1)
                            {
                                PrintCharAt(0, Paddlelincks, ConsoleColor.Black, ' ');
                                Paddlelincks += 1;
                            }
                            break;

                        case 'i':
                            if (Paddlerechts > 1)
                            {
                                Paddlerechts -= 1;
                                PrintCharAt(broatn-1, Paddlerechts + Paddlelengen, ConsoleColor.Black, ' ');
                            }
                            break;

                        case 'k':
                            if (Paddlerechts < heachn - Paddlelengen - 1)
                            {
                                PrintCharAt(broatn-1, Paddlerechts, ConsoleColor.Black, ' ');
                                Paddlerechts += 1;
                            }
                            break;

                    }       // - - - > SCH´┐ŻES WOCHENENDE!!!!!!!!!!!!!!!!!!



                   

                }
                DaPaddle(0, Paddlelincks);
                DaPaddle(broatn-1, Paddlerechts);

                DaBoin(BoinX, BoinY, false);

                // boin bewegn



                BoinX += BoiVecX;
                BoinY += BoiVecY;

                if (getCharAt(BoinX, BoinY) == '=')
                {
                    BoiVecY *= -1;
                    BoinY += BoiVecY;

                }


                if (getCharAt(BoinX, BoinY) == '#')
                {
                    BoiVecX *= -1;
                    BoinX += BoiVecX;

                }

                if (BoinX < 1)
                {
                    ScoreRechts++;
                    
                    BoinX = broatn / 2; BoinY = heachn / 2;
                    BoiVecX = 1; BoiVecY = 1;
                    System.Threading.Thread.Sleep(1500);
                }

                if (BoinX > broatn-2)
                {
                    ScoreLinks++;

                    BoinX = broatn / 2; BoinY = heachn / 2;
                    BoiVecX = -1; BoiVecY = -1;
                    System.Threading.Thread.Sleep(1500);
                }  

                DaBoin(BoinX, BoinY, true);

                PrintCharAt(38, 3, ConsoleColor.Cyan, (char)(ScoreLinks + '0'));
                PrintCharAt(42, 3, ConsoleColor.Cyan, (char)(ScoreRechts + '0'));
            }
            
        }

    }
}

syntax highlighted by Code2HTML, v. 0.9.1