示例#1
0
文件: Player.cs 项目: JSinc/choco
 /******* UPDATE ENEMY COLLISION METHOD *******/
 public void UpdateEnemyCollision(Enemy enemy)
 {
     if (health > 0 && playerRectangle.Intersects(enemy.destinationRectangle))
         health--;
 }
示例#2
0
文件: Game1.cs 项目: JSinc/choco
        protected override void Initialize()
        {
            player = new Player();
            enemy = new Enemy();
            largeEnemy = new LargeEnemy();
            playerHealth = new HealthBar();
            stats = new Stats(player);

            background1 = new Scrolling(Content.Load<Texture2D>("Backgrounds/background1"), new Rectangle(0, 0, screenWidth, screenHeight));
            background2 = new Scrolling(Content.Load<Texture2D>("Backgrounds/background1"), new Rectangle(screenWidth, 0, screenWidth, screenHeight));

            base.Initialize();
        }
示例#3
0
文件: Player.cs 项目: JSinc/choco
        /************ UPDATE METHOD ************/
        public void Update(GameTime gametime, Enemy enemy)
        {
            currentState = Keyboard.GetState();
            theKeyboardState = Keyboard.GetState();

            particleTarget = new Vector2(position.X + 45, position.Y + 51);

            // TODO: Add your update logic here
            UpdateWalking();
            UpdateJumping();
            UpdateRunning();
            UpdateBorderCollision();
            UpdateEnemyCollision(enemy);

            oldKeyboardState = theKeyboardState;

            sourceRectangle = new Rectangle(frameSize.X * currentFrame.X, frameSize.Y * currentFrame.Y, frameSize.X, frameSize.Y);

            playerRectangle = new Rectangle((int)position.X, (int)position.Y, characterTexture.Width / sheetWidth , characterTexture.Height / sheetHeight);

            base.Update(gametime, speed, direction);
        }