public void Setup()
        {
            _world = new World(800, 600, 1f) { GameSpeed = 2f };
            _world.LoadLevel(new LevelWithFourBricks());

            _ballsModel = new BallsModel(_world, BoxLength, BoxLength, new Vector2(0f, 0f), new Vector2(0f, 0f));
        }
Example #2
0
 public FrameModel(World world)
     : base(world)
 {
     Rectangle viewport = world.GetViewport();
     _topWall = new Rectangle(viewport.Left + WallWidth, viewport.Top, viewport.Width - (WallWidth * 2), WallWidth);
     _leftWall = new Rectangle(viewport.Left, viewport.Top, WallWidth, viewport.Height);
     _rightWall = new Rectangle(viewport.Right - WallWidth, viewport.Top, WallWidth, viewport.Height);
 }
Example #3
0
 public PlayerModel(World world, float scale)
     : base(world)
 {
     _world = world;
     _width = 120;
     _height = 20;
     var viewport = world.GetViewport();
     _ship = new Rectangle(viewport.Center.X,
             (viewport.Bottom - viewport.Height / 8),
             (int)(_width * scale), (int)(_height * scale));
 }
Example #4
0
        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());
        }
Example #5
0
 public BallsModel(World world, int width, int height, Vector2 startPosition, Vector2 startDirection)
     : base(world)
 {
     _world = world;
     _width = width;
     _height = height;
     _startPosition = startPosition;
     _startDirection = startDirection;
     _balls = new List<Ball>();
     Add(new Ball(_width, _height, _startPosition, _startDirection));
 }
Example #6
0
 public void SetUp()
 {
     _world = new World(800, 600, 1f) { GameSpeed = 1f };
 }
Example #7
0
 public WorldViewer(World world, SpriteFont infoFont)
 {
     _world = world;
     _infoFont = infoFont;
 }
Example #8
0
 public LevelViewer(World world, Texture2D yellowSquareTexture)
 {
     _world = world;
     _yellowSquareTexture = yellowSquareTexture;
 }
Example #9
0
        public void Setup()
        {
            _world = new World(800, 600, 1f) { GameSpeed = 1f };

            _playerModel = new PlayerModel(_world, 1f);
        }
Example #10
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);
        }
Example #11
0
        public void Setup()
        {
            _world = new World(800, 600, 1f) { GameSpeed = 1f };

            _ballsModel = new BallsModel(_world, BoxLength, BoxLength, new Vector2(0f, 0f), new Vector2(0f, 0f));
        }