Пример #1
0
        public MoleShooter()
        {
            InitializeComponent();


            this.SetStyle(
                System.Windows.Forms.ControlStyles.UserPaint |
                System.Windows.Forms.ControlStyles.AllPaintingInWmPaint |
                System.Windows.Forms.ControlStyles.OptimizedDoubleBuffer,
                true);

            _mole = new CMole()
            {
                Left = 300, Top = 450
            };


            _scoreframe = new CScoreFrame()
            {
                Left = 10, Top = 10
            };
            _sign = new CSign()
            {
                Left = 580, Top = 192
            };


            _splat = new CSplat();


            Bitmap b = new Bitmap(Resources.Site);

            this.Cursor = CustomeCursor.CreateCursor(b, b.Height / 2, b.Width / 2);
        }
Пример #2
0
        //The game program is not executed as sequential but by timer
        public MoleShooter()
        {
            //Don't put anything before InitializeComponent().
            InitializeComponent();

            //need this code to make the form update smoothly
            this.SetStyle(
                System.Windows.Forms.ControlStyles.UserPaint |
                System.Windows.Forms.ControlStyles.AllPaintingInWmPaint |
                System.Windows.Forms.ControlStyles.OptimizedDoubleBuffer,
                true);

            //Update the initial position of the mole when the game is loaded
            //_mole position will be changed during the game
            //Outer class ( Mole Shooter) creates the cointained class ( CMole) upon start-up
            //If we did not, the _mole would begin life as a null reference
            _mole = new CMole()
            {
                Left = 300, Top = 450
            };

            //intialize the initial position of _scoreFrame and _sign
            //these positons will be fixed during playing game
            //Outer class ( Mole Shooter) creates the cointained classes (_scoreframe and _sign) upon start-up
            //If we did not, the _scoreframe and _sign would begin life as a null reference
            _scoreframe = new CScoreFrame()
            {
                Left = 10, Top = 10
            };
            _sign = new CSign()
            {
                Left = 580, Top = 192
            };

            //_splat positon will be updated in Hit() method
            //Outer class ( Mole Shooter) creates the contained class ( _splat) upon start-up
            //If we did not, the _splat would begin life as a null reference
            _splat = new CSplat();

            //Create Scope Site
            //the center point is ( b.Height/2, b.Width/2)
            Bitmap b = new Bitmap(Resources.Site);

            this.Cursor = CustomeCursor.CreateCursor(b, b.Height / 2, b.Width / 2);
        }