Esempio n. 1
0
        //Falling Reset Code
        public void Fall()
        {
            if (hitbox.Intersects(fallBound) == true)
            {
                if (Lives == 0)
                {
                    Game1.currentGameState = GameState.GameOver;
                }
                else
                {
                    lives             -= 1;
                    position.X         = 0;
                    position.Y         = 200;
                    currentGlitchState = GlitchState.IdleRight;
                    hasJumped          = false;
                    onVertPlatform     = false;
                    onHorzPlatform     = false;
                    onGroundPlatform   = true;

                    onTile1 = false;
                    onTile2 = false;
                    onTile3 = false;
                    onTile4 = false;

                    currentPlatform = null;
                    currentKeyState = keyboardState.Right;
                    velocity.X      = 0f;
                    velocity.Y      = 0f;
                }
            }
        }
Esempio n. 2
0
        //Constructor
        public Glitch()
        {
            //Setting Previous GlitchState
            previousGlitchState   = currentGlitchState;
            previousKeyboardState = currentKeyState;

            currentGlitchState = GlitchState.IdleRight;
            currentKeyState    = keyboardState.Right;

            //Setting Start* Position
            this.position = new Rectangle(0, 200, 580, 760);
            //Setting Hitbox
            hitbox       = new Rectangle(position.X, position.Y, 125, 400);
            bottomHitBox = new Rectangle(position.X, position.Y, 125, 10);
            swordHitBox  = new Rectangle(position.X, position.Y + 20, 760, 580);

            //Setting Life Count
            lives = 2;

            //Setting Platform Boolean
            onHorzPlatform   = false;
            onVertPlatform   = false;
            onGroundPlatform = true;

            onTile1 = false;
            onTile2 = false;
            onTile3 = false;
            onTile4 = false;

            //Setting fallBound
            fallBound = new Rectangle(-1000000, 2000, 2000000, 10);

            //Jump
            hasJumped = false;

            //Initialize ground TEST*
            ground = new Ground();

            //Animation Initializers
            frameSize.X    = 1000;
            frameSize.Y    = 1000;
            currentFrame.X = 0;
            currentFrame.Y = 0;
            numFrames      = 1;
            frameRate      = 200;
            flip           = SpriteEffects.None;

            //Animation Initializers
            swordFrameSize.X = 744;
            swordFrameSize.Y = 866;
            swordNumFrames   = 5;
        }
Esempio n. 3
0
        //Reset* Method
        public void Reset()
        {
            lives              = 2;
            position.X         = 0;
            position.Y         = 200;
            currentGlitchState = GlitchState.IdleRight;
            hasJumped          = false;
            onVertPlatform     = false;
            onHorzPlatform     = false;

            onTile1 = false;
            onTile2 = false;
            onTile3 = false;
            onTile4 = false;

            currentPlatform = null;
            currentKeyState = keyboardState.Right;
            velocity.X      = 0f;
            velocity.Y      = 0f;
        }
Esempio n. 4
0
        //Move*
        public void Move()
        {
            previousKeyState = key;
            key = Keyboard.GetState();

            if (key.IsKeyDown(Keys.Z) && previousKeyState.IsKeyUp(Keys.Z))
            {
                Attack();
            }

            //Moving Right*
            if (key.IsKeyDown(Keys.Right) == true)
            {
                //Changes the KeyState to Right
                currentKeyState = keyboardState.Right;

                //Makes sure that glitch isn't in Jump before switching the state so that she doesn't stop midair
                if (currentGlitchState != GlitchState.Jump)
                {
                    currentGlitchState = GlitchState.MoveRight;
                    position.X        += 7;
                }
                else
                {
                    //Makes sure Glitch flips visually in air
                    if (previousGlitchState == GlitchState.MoveRight)
                    {
                        flip = SpriteEffects.FlipHorizontally;
                    }
                    position.X += 7;
                }

                Console.WriteLine(position.X);
            }

            //Moving Left*
            else if (key.IsKeyDown(Keys.Left) == true)
            {
                //Changes the KeyState to Right
                currentKeyState = keyboardState.Left;

                //Makes sure that glitch isn't in Jump before switching the state so that she doesn't stop midair
                if (currentGlitchState != GlitchState.Jump)
                {
                    currentGlitchState = GlitchState.MoveLeft;
                    position.X        -= 7;
                }
                else
                {
                    //Makes sure Glitch flips visually in air
                    if (previousGlitchState == GlitchState.MoveRight)
                    {
                        flip = SpriteEffects.None;
                    }
                    position.X -= 7;
                }

                if (position.X < -280)    //prevents glitch from going back too far and stops her at x = -280
                {
                    position.X = -280;
                }
            }

            if (previousKeyState.IsKeyUp(Keys.Left) == true && key.IsKeyDown(Keys.Left) == true)
            {
                if (currentGlitchState != GlitchState.Jump)
                {
                    currentGlitchState = GlitchState.IdleLeft;
                }
            }
            else if (previousKeyState.IsKeyUp(Keys.Right) == true && key.IsKeyDown(Keys.Right) == true)
            {
                if (currentGlitchState != GlitchState.Jump)
                {
                    currentGlitchState = GlitchState.IdleRight;
                }
            }

            //Makes Glitch Jump
            if (previousKeyState.IsKeyUp(Keys.Up) == true && key.IsKeyDown(Keys.Up) == true)
            {
                currentGlitchState = GlitchState.Jump;
            }

            //Makes her move with platform
            //Ground*
            if (onGroundPlatform == true && currentPlatform == null)
            {
                //checks to see if she's on any ground tile (1-4)
                if (bottomHitBox.Intersects(Ground.hitboxList[0]) == false && bottomHitBox.Intersects(Ground.hitboxList[1]) == false && bottomHitBox.Intersects(Ground.hitboxList[2]) == false && bottomHitBox.Intersects(Ground.hitboxList[3]) == false)
                {
                    onGroundPlatform = false;

                    //Makes sure that she falls
                    hasJumped          = true;
                    currentGlitchState = GlitchState.Jump;
                }
            }

            //Horizontal
            if (onHorzPlatform == true && currentPlatform != null)
            {
                if (bottomHitBox.Intersects(currentPlatform.HitBox) == false)
                {
                    onHorzPlatform     = false;
                    currentPlatform    = null;
                    hasJumped          = true;
                    currentGlitchState = GlitchState.Jump;
                }
                else
                {
                    if (Horizontal_Platform.pubActive == false)
                    {
                        onHorzPlatform     = false;
                        currentPlatform    = null;
                        hasJumped          = true;
                        currentGlitchState = GlitchState.Jump;
                    }
                }

                if (Horizontal_Platform.direction == true)
                {
                    position.X += 5;
                }
                else
                {
                    position.X -= 5;
                }
            }

            //Vertical
            if (onVertPlatform == true && currentPlatform != null)
            {
                if (bottomHitBox.Intersects(currentPlatform.HitBox) == false)
                {
                    onVertPlatform     = false;
                    currentPlatform    = null;
                    hasJumped          = true;
                    currentGlitchState = GlitchState.Jump;
                }
                else
                {
                    if (Vertical_Platform.pubActive == false)
                    {
                        onVertPlatform     = false;
                        currentPlatform    = null;
                        hasJumped          = true;
                        currentGlitchState = GlitchState.Jump;
                    }
                }

                //Decides which position to move glitch in.
                if (Vertical_Platform.direction == true)
                {
                    position.Y -= 5;
                }
                else
                {
                    position.Y += 5;
                }
            }
        }