コード例 #1
0
        static void Main() //the main method of the program
        {
            Console.Title           = "Paul's Pong";
            Console.BackgroundColor = ConsoleColor.DarkGray;
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.SetWindowSize(80, 30); //sets the window of the console to 80 by 25
            Console.BufferHeight = 30;     //sets the height limit of the console
            Console.BufferWidth  = 80;
            Console.Clear();               //clears the console screen (directory info etc)
            DrawBox(0, 0, 79, 25, ConsoleColor.DarkGray, ConsoleColor.Green, false);

            ball   ball    = new ball();
            paddle paddles = new paddle();

            ball.drawBall();
            paddles.drawPaddle();

            do
            {
                ball.updateBall();
                paddles.update();
                /*This slows down each process in the program to ???ms*/
                System.Threading.Thread.Sleep(50);
                /*Program loops while escape is not false (!escape)*/
            } while (!escape);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: NullandKale/csharp_pong
        static void Main(string[] args)
        {
            i  = new InputManager();
            d  = new display();
            gb = new gameBoard(d);
            pd = new paddle(2, d, 1);
            b  = new ball(d, 2, pd);

            //c = new Controllers.PlayerController();
            //c = new Controllers.PerfectAI();
            c = new Controllers.PerfectAiHybrid();

            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            int counter = 0;

            while (!i.IsKeyFalling(OpenTK.Input.Key.Escape))
            {
                stopwatch.Start();

                i.Update();
                d.draw(true);
                doGameUpdate();

                //System.Threading.Thread.Sleep(5);

                stopwatch.Stop();

                counter++;
                fps = (int)(1.0 / ((double)stopwatch.ElapsedMilliseconds / (double)counter) * 1000.0);

                if (counter > 200)
                {
                    stopwatch.Reset();
                    counter = 0;
                }
            }
        }