Ejemplo n.º 1
0
        public void CheckCollision(Syringe syringe)
        {
            Rectangle heartHitBox = new Rectangle((int)this.Position.X, (int)this.Position.Y, this.Sprite.Width, this.Sprite.Height);
            Rectangle syringeHitBox = new Rectangle((int)syringe.Position.X, (int)syringe.Position.Y, syringe.Sprite.Width, syringe.Sprite.Height);

            if (heartHitBox.Intersects(syringeHitBox))
                this.Position = new Vector2(2000, 0);
        }
Ejemplo n.º 2
0
        public void Update(int screenWidth, int screenHeight, Syringe syringe)
        {
            if (Position.X > screenWidth - MARGIN - Sprite.Width)
                heartSpeed *= -1;
            else if (Position.X < MARGIN)
                heartSpeed *= -1;
            Position = new Vector2(Position.X + heartSpeed, Position.Y);

            CheckCollision(syringe);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            //this.IsMouseVisible = true;

            heart = new Heart();

            syringe = new Syringe();

            keyboardState = Keyboard.GetState();

            base.Initialize();
        }