Esempio n. 1
0
        private System.Windows.Forms.Timer timer1; // Create a timer

        #endregion Fields

        #region Constructors

        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // Sets the size of the maze
            Maze.kDimension = 10;

            // Sets the size of the cells
            Cell.kCellSize = 30;

            // The number of Stones, the location of the score and stone message all depend on the size of the maze
            NumberOfStones = (Maze.kDimension - 5) * (Maze.kDimension - 5);
            TheScore = new Score(((Maze.kDimension * 2/3) * (Cell.kCellSize + Cell.kPadding)), 10);
            TheStoneMessage = new GameMessage(((Maze.kDimension * 3/4) * (Cell.kCellSize + Cell.kPadding)), 10);
            TheNameMessage = new GameMessage(8, (Maze.kDimension) * Cell.kCellSize + Cell.kPadding + 22);
            AskName();

            // Determines how much time you are given, according to the size of the maze
            if (Maze.kDimension >= 10 && Maze.kDimension <= 20)
                TheSeconds = 90;
            if (Maze.kDimension >= 20)
                TheSeconds = 120;

            // Records the start time
            startTime = TheSeconds;

            TheMaze.Initialize();
            TheMaze.Generate();

            InitializeStones();
            InitializeEater();
            InitializeGhost();

            InitializeMessage();
            InitializeTimer();
            InitializeScore();

            // Sets window size
            SetBounds(10, 10, 700, 800);

            //(Maze.kDimension + 2) * Cell.kCellSize + Cell.kPadding, (Maze.kDimension + 3) * Cell.kCellSize + Cell.kPadding + 8)
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.DoubleBuffer, true);

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }