Пример #1
0
        public void Move(GameObject obj, ShipUpdateInfo info)
        {
            //Get the direction from the player (controller)
            Vector2 direction = player.input.ShipMoveDirNormal();

            //Check is the player is trying to move
            //Since update (GameObject) will try and move the ship
            //if player is not trying to move we flag it false
            if (direction.X == 0 && direction.Y == 0)
            {
                obj.moving = false;
            }
            else
            {
                obj.moving = true;             //re-flag true in case set to false

                direction.Normalize();         //just in case....
                obj.SetRotation(direction);

                //Since SetRotation() above, also turns the "face" direction
                //we need to correct this for the human players whose ships
                //always face directly upwards on the screen
                obj.SetFaceDir(VecUtil.GetNormUP());
            }
        }
Пример #2
0
        private Vector2 dir;    //left, right, up, or down, in Vector2 form

        public MMCardinal(Cardinal direction)
        {
            switch (direction)
            {
            case Cardinal.Down:
                dir = VecUtil.GetNormDown();
                break;

            case Cardinal.Up:
                dir = VecUtil.GetNormUP();
                break;

            case Cardinal.Left:
                dir = VecUtil.GetNormLeft();
                break;

            case Cardinal.Right:
                dir = VecUtil.GetNormRight();
                break;
            }
        }