Exemplo n.º 1
0
        protected override void UpdateCore(AnimatedSprite subject)
        {
            //Rectangle viewportRect = SpriteManager.Instance.Game.GraphicsDevice.Viewport.Bounds;
            viewportRect = new Rectangle(0, 0, 1280, 720);
            subject.screenPos += subject.velocity;

            // Check for collision with right edge, if so, bounce
            if (subject.screenPos.X + subject.sourceRect.Width / 2 > viewportRect.Right)
            {
                //subject.velocity.X *= +1;
                //subject.screenPos.X = (viewportRect.Left +40) - subject.sourceRect.Width / 2;

            }
            else if (subject.screenPos.X - subject.sourceRect.Width / 2 < viewportRect.Left)
            {
                //subject.velocity.X *= +1;
                //subject.screenPos.X = (viewportRect.Right -100) + subject.sourceRect.Width / 2;
            }
            else if (subject.screenPos.Y - subject.sourceRect.Height / 2 < (viewportRect.Top - 600))
            {
                //subject.velocity.Y *= -1;
                //subject.screenPos.Y = viewportRect.Top + subject.sourceRect.Height / 2;
            }
            else if (subject.screenPos.Y + subject.sourceRect.Height / 2 > viewportRect.Bottom)
            {
                //subject.screenPos.Y = viewportRect.Top - subject.sourceRect.Height / 2;
                //subject.velocity.Y *= -1;
                //subject.screenPos.Y = viewportRect.Bottom - subject.sourceRect.Height / 2;
            }
        }
Exemplo n.º 2
0
 // blue gem method
 private AnimatedSprite createGem(Vector2 position, Vector2 velocity)
 {
     ContentManager content = ScreenManager.Game.Content;
     textures.ContentManager = ScreenManager.Game.Content;
     sounds.ContentManager = ScreenManager.Game.Content;
     fonts.ContentManager = ScreenManager.Game.Content;
     Texture2D enemygemTexture = content.Load<Texture2D>("Textures\\loading_w");
     AnimatedSprite d = new AnimatedSprite(
         enemygemTexture,
         new Vector2(105, 15),
         position,
         new Rectangle(0, 0, 210, 30),
         velocity,                                                       // allows random velocity
         1, 1, 1);                                                       // tilesheet animation, rows, columns, frames
     d.Behaviour = normalBehaviour;                                      // sets behaviour
     return d;
 }
Exemplo n.º 3
0
 protected abstract void UpdateCore(AnimatedSprite subject);
Exemplo n.º 4
0
 protected abstract void EndCore(AnimatedSprite subject);
Exemplo n.º 5
0
 protected abstract void BeginCore(AnimatedSprite subject);
Exemplo n.º 6
0
 public void Update(AnimatedSprite subject)
 {
     UpdateCore(subject);
 }
Exemplo n.º 7
0
 public void End(AnimatedSprite subject)
 {
     EndCore(subject);
 }
Exemplo n.º 8
0
 public void Begin(AnimatedSprite subject)
 {
     BeginCore(subject);
 }
Exemplo n.º 9
0
 protected override void EndCore(AnimatedSprite subject)
 {
 }
Exemplo n.º 10
0
 protected override void BeginCore(AnimatedSprite subject)
 {
 }
Exemplo n.º 11
0
 protected override void UpdateCore(AnimatedSprite subject)
 {
     subject.screenPos += 5 * subject.velocity;
     subject.velocity.X *= -1;
     subject.velocity.Y *= -1;
 }
Exemplo n.º 12
0
 private AnimatedSprite createAsteroid01(Vector2 position, Vector2 velocity)
 {
     AnimatedSprite d = new AnimatedSprite( asteroid01, new Vector2(75, 56),
         position, new Rectangle(0, 0, 150, 113), velocity, 6, 6, 36);       // tilesheet animation, rows, columns, frames
     d.Behaviour = normalBehaviour;                                          // sets behaviour
     return d;
 }