コード例 #1
0
ファイル: Ball.cs プロジェクト: daniellee/BallBounce
        public void HandleCollisionWithAnyGameObject(World world)
        {
            var ballRectangle = new Rectangle((int)Position.X, (int)Position.Y, Width, Height);
            var frame = world.GetFrameModel();
            HandleFrameAndBallCollision(ballRectangle, frame);

            var player = world.GetPlayerModel();
            HandlePlayerAndBallCollision(ballRectangle, player);

            _brickCollisionHandler.HandleBrickAndBallCollisions(ballRectangle, world.CurrentLevel.GetBricks());
        }
コード例 #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _world = new World(_graphics.GraphicsDevice.Viewport.Width, _graphics.GraphicsDevice.Viewport.Height);

            BallsModel ballsModel = _world.GetBallsModel();
            _ballTexture = Content.Load<Texture2D>("Sprites\\SilverBall");
            _ballsViewer = new BallsViewer(ballsModel.GetAllBalls(), _ballTexture);

            _frameTexture = Content.Load<Texture2D>("Frame\\titanium");
            _frameViewer = new FrameViewer(_world.GetFrameModel(), _frameTexture);

            var infoFont = Content.Load<SpriteFont>("Fonts\\InfoFont");
            _worldViewer = new WorldViewer(_world, infoFont);

            _playerTexture = Content.Load<Texture2D>("Sprites\\PlayerShip");
            PlayerModel playerModel = _world.GetPlayerModel();
            _playerController = new PlayerController(playerModel);
            _playerViewer = new PlayerViewer(playerModel, _playerTexture);

            _yellowSquareTexture = Content.Load<Texture2D>("Sprites\\yellowsquare");
            _levelViewer = new LevelViewer(_world, _yellowSquareTexture);
        }