コード例 #1
0
ファイル: Crasher.cs プロジェクト: worthrd/PongCrasher
        public Crasher()
        {
            InitializeComponent();
            this.SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);

            gameState = new GameState();

            settings = GameSettings.GetInstance();

            Brick.Height = settings.BrickHeight;
            Brick.Width = settings.BrickWidth;

            Wall.Width = settings.WallWidth;
            Wall.Height = settings.WallHeight;

            Ball.Radius = settings.BallRadius;
            Ball.InitialSpeed = settings.BallInitialSpeed;

            settings.BallMaxX = (float)ClientSize.Width;

            settings.BallMaxY = (float)ClientSize.Height;

            //Create the bat Sprites - they need the keyboard controls and the gameplay area limits
            _player1 = new Wall(settings.PlayerDefaultX,Keys.Up,Keys.Down ,settings.MinPosition, (float)ClientSize.Height, Wall.Width, Wall.Height);

            //use this line for a second human player
            //_player2 = new Bat(player2Bat, ClientSize.Width - 30 - Bat.Width, Keys.P, Keys.L, 0, ClientSize.Height);

            //use this line for a computer player
            _player2 = new Wall((float)ClientSize.Width - settings.PlayerDefaultX - Wall.Width, settings.MinPosition, (float)ClientSize.Height, Wall.Width, Wall.Height);

            _ball_1 = new Ball(settings.BallMinX, (float)ClientSize.Width, settings.BallMinY, (float)ClientSize.Height, gameState, ref _player1, ref _player2);

            _player1.Ball = _ball_1;

            //Connect the AI player with the ball
            _player2.Ball = _ball_1;

            //Initialise and start the timer
            _lastTime = 0.0;
            _timer.Start();

            Sprite shotGun = new ShotGun(_player1, _player2, _ball_1);
            Sprite shotGun2 = new ShotGun(_player1, _player2, _ball_1);
            _player1.Weapons.Add(shotGun);
            _player1.Weapons.Add(shotGun2);
            /*
               ((Weapon)shotGun).Use();
               */
        }
コード例 #2
0
ファイル: ShotGunDrawer.cs プロジェクト: worthrd/PongCrasher
 public ShotGunDrawer(Sprite s)
     : base(s)
 {
     g = s as ShotGun;
 }