Example #1
0
        /// <summary>
        /// Initializes the <see cref="Entity"/>. Is called once the entity
        /// has been added to a <see cref="Playground"/> and after the
        /// <see cref="Entity.Playground"/> field has been set.
        /// </summary>
        public override void Initialize()
        {
            BreakoutPartyGame game = Playground.State.Manager.Game;

            _Batch = game.Batch;

            _PaddleTexture  = game.Content.Load <Texture2D>("Paddle");
            _PaddleHitSound = game.Content.Load <SoundEffect>("PaddleHit");

            _Origin = new Vector2(_PaddleTexture.Width * 0.5f, _PaddleTexture.Height * 0.5f);

            PhysicsBody = FarseerPhysics.Factories.BodyFactory.CreateRoundedRectangle(
                Playground.World,
                _PaddleTexture.Width * BreakoutPartyGame.MeterPerPixel,
                _PaddleTexture.Height * BreakoutPartyGame.MeterPerPixel,
                12 * BreakoutPartyGame.MeterPerPixel,
                3 * BreakoutPartyGame.MeterPerPixel,
                6,
                1f,
                Vector2.Zero,
                0f,
                FarseerPhysics.Dynamics.BodyType.Kinematic,
                this);
            PhysicsBody.IgnoreGravity       = true;
            PhysicsBody.CollisionCategories = CollisionGroups.Paddle;
            PhysicsBody.CollidesWith        = CollisionGroups.Ball;
            PhysicsBody.OnCollision        += PhysicsBody_OnCollision;
            MakePhysicsBodyBouncy();
        }
Example #2
0
        /// <summary>
        /// Initializes the <see cref="Entity"/>. Is called once the entity
        /// has been added to a <see cref="Playground"/> and after the
        /// <see cref="Entity.Playground"/> field has been set.
        /// </summary>
        public override void Initialize()
        {
            BreakoutPartyGame game = Playground.State.Manager.Game;

            _Batch = game.Batch;

            _BallTexture = game.Content.Load <Texture2D>("Ball");

            _Origin = new Vector2(_BallTexture.Width * 0.5f, _BallTexture.Height * 0.5f);

            PhysicsBody = FarseerPhysics.Factories.BodyFactory.CreateCircle(
                Playground.World,
                _BallTexture.Width * 0.5f * BreakoutPartyGame.MeterPerPixel,
                1f,
                Vector2.Zero,
                FarseerPhysics.Dynamics.BodyType.Dynamic,
                this);
            PhysicsBody.IgnoreGravity       = true;
            PhysicsBody.CollisionCategories = CollisionGroups.Ball;
            PhysicsBody.CollidesWith        = CollisionGroups.Ball
                                              | CollisionGroups.Block
                                              | CollisionGroups.Paddle;
            MakePhysicsBodyBouncy();
        }
Example #3
0
 /// <summary>
 /// Creates a new <see cref="GamestateManager"/> instance.
 /// </summary>
 /// <param name="game">The <see cref="BreakoutPartyGame"/>.</param>
 public GamestateManager(BreakoutPartyGame game)
 {
     Game = game;
 }
Example #4
0
 /// <summary>
 /// Creates a new <see cref="SoundManager"/> instance.
 /// </summary>
 /// <param name="game">The <see cref="BreakoutPartyGame"/> the manager belongs to.</param>
 public SoundManager(BreakoutPartyGame game)
 {
     _Game = game;
     SoundEffect.MasterVolume = game.Data.SoundVolume;
     MediaPlayer.Volume       = game.Data.MusicVolume;
 }