Esempio n. 1
0
        private void uInput()
        {
            KeyboardState newState    = Keyboard.GetState();
            MouseState    sourisState = Mouse.GetState();

            if (newState.IsKeyDown(Keys.A))
            {
                foreach (Map map in maps)
                {
                    if (refreshImages && !perso.getPersoHitBox().Intersects(map.rightHitBox))
                    {
                        l = true;
                    }
                    else
                    {
                        l = false;
                        break;
                    }
                }
                if (l)
                {
                    perso.movePerso(new Vector2(perso.getPersoPos().X - 6, perso.getPersoPos().Y));
                }
                perso.changeSens(0);
            }
            else if (newState.IsKeyDown(Keys.D))
            {
                foreach (Map map in maps)
                {
                    if (refreshImages && !perso.getPersoHitBox().Intersects(map.leftHitBox))
                    {
                        r = true;
                    }
                    else
                    {
                        r = false;
                        break;
                    }
                }
                if (r)
                {
                    perso.movePerso(new Vector2(perso.getPersoPos().X + 6, perso.getPersoPos().Y));
                }
                perso.changeSens(1);
            }
            if (newState.IsKeyDown(Keys.W) && !oldState.IsKeyDown(Keys.W) && perso.canJump == true && !b)
            {
                perso.jump(true);
                perso.canJump = false;
                perso.walking = false;
                limiteSaut    = perso.getPersoPos().Y - 100;
            }

            if ((newState.IsKeyDown(Keys.Back) && !oldState.IsKeyDown(Keys.Back)) || perso.getPersoPos().Y > 800)
            {
                perso.movePerso(new Vector2(150, 180));
                Mob[0].moveMob(new Vector2(500, 250));
                Mob[1].moveMob(new Vector2(600, 250));
            }

            if (newState.IsKeyDown(Keys.S))
            {
                vitChutte = 2;
            }

            else
            {
                vitChutte = 1;
            }
            oldState = newState;

            if (sourisState.LeftButton == ButtonState.Pressed && oldSourisState.LeftButton != ButtonState.Pressed)
            {
                perso.attacking(true);
            }
            if (sourisState.RightButton == ButtonState.Pressed && oldSourisState.RightButton != ButtonState.Pressed && !attackDistance)
            {
                attackDistance = true;
            }
            oldSourisState = sourisState;
        }