public ComponentManager(ContentManager contentManager, Microsoft.Xna.Framework.GraphicsDeviceManager graphicsDeviceManager) { _contentManager = contentManager; _resourceRepository = new ResourceRepository(new BasicResourceRepositoryConfiguration(), _contentManager); Font = _resourceRepository.GetFont(); _spaceShipTexture = _resourceRepository.GetTextureByType(typeof(SpaceShip)); var graphicsDevice = graphicsDeviceManager.GraphicsDevice; Configuration = new BasicGameConfiguration( _spaceShipTexture.Height, Font ); graphicsDeviceManager.PreferredBackBufferWidth = Configuration.ScreenSize.Width; graphicsDeviceManager.PreferredBackBufferHeight = Configuration.ScreenSize.Height; graphicsDeviceManager.ApplyChanges(); SpaceShip = new SpaceShip(Configuration, new Size(_spaceShipTexture.Width, _spaceShipTexture.Height)); _ballTexture = _resourceRepository.GetTextureByType(typeof(BasicBall)); BallRepository = new BallRepository(Configuration, new Size(_ballTexture.Width, _ballTexture.Height)); Balls = new List <IBall>(); _drawer = new ComponentDrawer(graphicsDevice, Font); Prizes = new List <IPrize>(); Shoots = new List <IShoot>(); MediaPlayer.Volume = .03f; }
public void IfIGoVeryFastToTheLeftICantGoMoreFarThanTheSpace() { IGameConfiguration configuration = new BasicGameConfiguration(90, null); SpaceShip spaceShip = new SpaceShip(configuration, new Size(10, 10)); spaceShip.Position = new Vector2(2, 0); spaceShip.Speed = new Vector2(-3, 0); spaceShip.Move(); Assert.AreEqual(0, spaceShip.Position.X); spaceShip.Move(); Assert.AreEqual(spaceShip.Speed.X, spaceShip.Position.X); }
public void IfIGoUpVeryFastICantGoMoreFarThanTheSpace() { IGameConfiguration configuration = new BasicGameConfiguration(42, null); BasicBall ball = new BasicBall(configuration, new Size(42, 42)); ball.Position = new Vector2(42, 3); ball.Speed = new Vector2(42, -4); ball.Move(); Assert.AreEqual(0, ball.Position.Y); ball.Move(); Assert.AreEqual(ball.Speed.Y, ball.Position.Y); }
public void IfIGoVeryFastToTheRightICantGoMoreFarThanTheSpace() { int screenWidth = 100, spaceShipWidth = 10; IGameConfiguration configuration = new BasicGameConfiguration(90, null); SpaceShip spaceShip = new SpaceShip(configuration, new Size(spaceShipWidth, 10)); spaceShip.Position = new Vector2(89, 0); spaceShip.Speed = new Vector2(3, 0); spaceShip.Move(); Assert.AreEqual(screenWidth - spaceShipWidth, spaceShip.Position.X); spaceShip.Move(); Assert.AreEqual(spaceShip.Speed.X, (float)Math.Round(screenWidth - spaceShipWidth - spaceShip.Position.X, 2) * -1); }
public void IfIGoVeryFastToTheLeftICantGoMoreFarThanTheSpace() { int speed = 4; IGameConfiguration configuration = new BasicGameConfiguration(42, null); BasicBall ball = new BasicBall(configuration, new Size(42, 42)); ball.Position = new Vector2(speed - 1, 42); ball.Speed = new Vector2(speed * -1, 42); ball.Move(); Assert.AreEqual(0, ball.Position.X); ball.Move(); Assert.AreEqual(ball.Speed.X, ball.Position.X); }
public void IFindCollisions() { var configuration = new BasicGameConfiguration(0, null); var blocks = new List <IBlock>() { new BasicBlock(configuration, new Size(64, 32)) { Position = new Vector2(5, 5) } }; var ball = new BasicBall(configuration, new Size(5, 5)) { Position = new Vector2(15, 26.15f), Speed = new Vector2(0, -2) }; var board = new Board(blocks, null, new Size(100, 100), ball.Size.Width * ball.Scale.X); var block = board.Collides(ball); }
public void IfIGoVeryFastToTheRightICantGoMoreFarThanTheSpace() { int screenWidth = 800, ballWidth = 21, speed = 4; int roundErrorForBallScaleFloatValue = 1; IGameConfiguration configuration = new BasicGameConfiguration(42, null); BasicBall ball = new BasicBall(configuration, new Size(ballWidth, 42)); ball.Position = new Vector2(screenWidth - ballWidth - speed + 1, 42); ball.Speed = new Vector2(speed, 42); ball.Move(); Assert.AreEqual(screenWidth - ballWidth, ball.Position.X - roundErrorForBallScaleFloatValue); ball.Move(); Assert.AreEqual(ball.Speed.X, (float)Math.Round(screenWidth - ballWidth - ball.Position.X, 2) * -1 - roundErrorForBallScaleFloatValue); }