Exemplo n.º 1
0
        public override void EvtStep()
        {
            UpdateState();
            UpdateColliders();
            Sprite.UpdateImageRectangle();

            if (keyboard_check(Keys.W))
            {
                frameManager.ApplyAnimation("george", "north");
                ImageSpeed = imgSpd;

                if (instance_place(new Vector2(Position.X, Position.Y - speed), typeof(oSolidMask)) == null)
                {
                    Y -= speed;
                }
            }
            else if (keyboard_check(Keys.S))
            {
                frameManager.ApplyAnimation("george", "south");

                if (instance_place(new Vector2(Position.X, Position.Y + speed), typeof(oSolidMask)) == null)
                {
                    Y += speed;
                }

                ImageSpeed = imgSpd;
            }
            else if (keyboard_check(Keys.A))
            {
                frameManager.ApplyAnimation("george", "west");

                if (instance_place(new Vector2(Position.X - speed, Position.Y), typeof(oSolidMask)) == null)
                {
                    X -= speed;
                }

                ImageSpeed = imgSpd;
            }
            else if (keyboard_check(Keys.D))
            {
                frameManager.ApplyAnimation("george", "east");

                if (instance_place(new Vector2(Position.X + speed, Position.Y), typeof(oSolidMask)) == null)
                {
                    X += speed;
                }

                ImageSpeed = imgSpd;
            }
            else
            {
                ImageSpeed = 0;
                ImageIndex = ((int)ImageIndex / 4) * 4;
            }

            if (keyboard_check_pressed(Keys.Q))
            {
                audio_play_sound_fast(audio_get("MySong"), .3f);
            }
        }