コード例 #1
0
        public void Set(Game game)
        {
            game.Lifes = new Dictionary<PictureBox, string>();

            pboxLive1 = new PictureBox()
            {
                Parent = game.BoardUI,
                Image = global::BoringGame.Properties.Resources.liveActive,
                Location = new System.Drawing.Point(824, 124),
                Size = new System.Drawing.Size(19, 17)
            };

            pboxLive2 = new PictureBox()
            {
                Parent = game.BoardUI,
                Image = global::BoringGame.Properties.Resources.liveActive,
                Location = new System.Drawing.Point(824, 156),
                Size = new System.Drawing.Size(19, 17)
            };

            pboxLive3 = new PictureBox()
            {
                Parent = game.BoardUI,
                Image = global::BoringGame.Properties.Resources.liveActive,
                Location = new System.Drawing.Point(824, 189),
                Size = new System.Drawing.Size(19, 17)
            };

            game.Lifes.Add(pboxLive1, "active");
            game.Lifes.Add(pboxLive2, "active");
            game.Lifes.Add(pboxLive3, "active");
        }
コード例 #2
0
        public BoardUI()
        {
            InitializeComponent();

            GameItem = new Game() { BoardUI = this };

            GameItem.BallItem = new Ball(pboxBall.Width, pboxBall.Height);
            GameItem.PaddleItem = new Paddle(pboxPaddle.Width, pboxPaddle.Height);
        }
コード例 #3
0
        public GameField()
        {
            InitializeComponent();

            _game = Game.Instance();
            _game.PlayingBoard = this;

            _game.Ball = new Ball(pboxBall.Width, pboxBall.Height);
            _game.Paddle = new Paddle(pboxBallPad.Width, pboxBallPad.Height);

            ballTimer.Interval = 10;
            ballTimer.Tick += new EventHandler(timer_Tick);
        }
コード例 #4
0
        private void Move(Game game)
        {
            IsOut = false;

            string info = "Board [" + game.BoardUI.Width + ":H" + game.BoardUI.Height + "\n" +
                "ball: X: " + game.BoardUI.pboxBall.Location.X + "Y: " + game.BoardUI.pboxBall.Location.Y;

            game.BoardUI.Info.Text = info;

            Rectangle ceiling = new Rectangle(0, 0, game.BoardUI.Width, 1);
            Rectangle leftWall = new Rectangle(0, 0, 1, game.BoardUI.Height);
            Rectangle rightWall = new Rectangle(game.BoardUI.Width - 30, 0, 1, game.BoardUI.Height);
            Rectangle floor = new Rectangle(0, game.BoardUI.Height, game.BoardUI.Width, 1);

            if (CollidesWith(floor))
            {
                IsOut = true;
            }

            else if (CollidesWith(game.PaddleRectangle))
            {
                MoveUp();
                KeepHorizontalDirection();
            }
            else if (CollidesWith(ceiling))
            {
                MoveDown();
                KeepHorizontalDirection();
            }
            else if (CollidesWith(rightWall))
            {
                KeepVerticalDirection();
                MoveLeft();
            }
            else if (CollidesWith(leftWall))
            {
                KeepVerticalDirection();
                MoveRight();
            }
            else if (CurrentMotion.IsMovingDown())
            {
                MoveDown();
                KeepHorizontalDirection();
            }
            else
            {
                MoveUp();
                KeepHorizontalDirection();
            }
        }
コード例 #5
0
 public void Draw(Game game)
 {
     Move(game);
     game.BoardUI.pboxBall.Location = new Point(X, Y);
     game.BoardUI.pboxBall.Image = global::BoringGame.Properties.Resources.redBall;
 }
コード例 #6
0
 public void DrawPaddle(Game game)
 {
     game.BoardUI.pboxPaddle.Location = new Point(X, Y);
     game.BoardUI.pboxPaddle.Image = global::BoringGame.Properties.Resources.ballPad;
 }