示例#1
0
        static void Main(string[] args)
        {
            //declare vars
            bool runProg = true;            // flags to see if program should continue running and restart
            decimal userMoney;              // stores total amount of money user is calcuating
            CDrawer window = new CDrawer(); // window where money is visually drawn
            decimal[,] cashAndCoins = null; // array to store cash/coin amounts and discrete amounts of each for
                                            // a given cash value
            
            //loops if the user wishes to restart and try again.
            do
            {
                //resets all values, if possible
                if (cashAndCoins != null) Array.Clear(cashAndCoins, 1, 10);
                window.Clear();
                Console.Clear();
                Console.WriteLine("\t\tCMPE 1700 Money Calculator\n\n");
                
                // gets input from user, and sends it to be calculated and stored in the array.
                userMoney = getMoney();
                cashAndCoins = calcMoney(userMoney);

                //displays the amount and draws it in GDIDrawer.
                Console.WriteLine("Now displaying {0:C}", userMoney);
                drawMoney(window, userMoney, cashAndCoins);

                //checks to see if user wants to run again, which they can do by pressing the Enter key.
                Console.Write("Press Enter to run again, or any other key to exit.");
                if (!(Console.ReadKey().Key.Equals(ConsoleKey.Enter)))
                    runProg = false;
            } while (runProg);

        }
示例#2
0
        //helper methods
        private static void RenderGrid(CDrawer canvas, Color[,] colAr)
        {
            canvas.Clear();

            for (int iR = 0; iR < canvas.ScaledHeight; iR++)
                for (int iC = 0; iC < canvas.ScaledWidth; iC++)
                    canvas.SetBBScaledPixel(iC, iR, colAr[iR, iC]);

            for (int i = 0; i < canvas.ScaledWidth; i++)
                canvas.AddLine(i, 0, i, canvas.ScaledWidth, Color.Black, 1);

            for (int i = 0; i < canvas.ScaledHeight; i++)
                canvas.AddLine(0, i, canvas.ScaledWidth, i, Color.Black, 1);

            canvas.Render();
        }
示例#3
0
        private static int screenWidth = 800; // Width of Canvas screen

        #endregion Fields

        #region Methods

        public static void Main(string[] args)
        {
            CDrawer canvas = new CDrawer(screenWidth, screenHeight);     // Initializes new Canvas window
            Random  rng    = new Random();                               // Random number generator

            Ball example = new Ball(screenWidth, screenHeight, 25, 150, 100, 10, 1, 350);
            Ball example2 = new Ball(screenWidth, screenHeight, 25, 300, 300, 1, 1, 300);

            for (int i = 0; i < 10000; i++)
            {
                canvas.AddEllipse(example.centerX - example.radius, example.centerY - example.radius, 2 * example.radius, 2 * example.radius);
                canvas.AddEllipse(example2.centerX - example2.radius, example2.centerY - example2.radius, 2 * example2.radius, 2 * example2.radius);
                System.Threading.Thread.Sleep(5);
                canvas.Clear();
                example.Update();
                example.CollideWithWall();
                example2.CollideWithWall();
                example.CollideWithBall(example2);
            }
            Console.ReadKey();
        }
示例#4
0
 // RefreshSprites(...) - Clears screen, calls DrawTarget and DrawCannon and renders screen.
 private static void RefreshSprites(CDrawer screen, int cannonX, int targetX, int cannonY, int TargetY, int barrelAngle,
                                                                                Color wheel, Color barrel, Color target)
 {
     screen.Clear();
     DrawCannon(screen, cannonX, cannonY, MyMethods.ConvertDegreesToGDIDrawerLineRotation(barrelAngle), wheel, barrel);
     DrawTarget(screen, targetX, TargetY, target);
     screen.Render();
 }