public void readMouseToAim(AnimatedGameObject gameObject)
 {
     float rel = MOUSE.SC.X - Screen.width / 2;
     float percentage = rel / Screen.width * 100;
     percentage = percentage * percentage * (percentage * 0.001f);
     gameObject.rotation += percentage / sensitivity;
 }
Beispiel #2
0
        public void chaseCam(AnimatedGameObject gameObject)
        {
            position = gameObject.position;
            float difference = gameObject.rotation - this.rotation;

            if (Math.Abs(difference) > Trig.PI)
            {
                if (rotation < Trig.PI)
                {
                    difference = -(Trig.PI_Two - Math.Abs(difference));
                }
                else
                {
                    difference = (Trig.PI_Two - Math.Abs(difference));
                }
            }

            rotation += ((difference) / sensitivity);
            position = Trig.MoveToCurrentDirection(position, rotation, -distanceBehind);
        }
        public void controlObject(AnimatedGameObject gameObject)
        {
            if (KEYBOARD.KeyDown(forwardKey))
            {
                gameObject._position = Trig.MoveToCurrentDirection(gameObject._position, gameObject.rotation, movementSpeed);
            }

            if (KEYBOARD.KeyDown(backwardKey))
            {
                gameObject._position = Trig.MoveToCurrentDirection(gameObject._position, gameObject.rotation, -movementSpeed);
            }

            if (KEYBOARD.KeyDown(leftKey))
            {
                gameObject._position = Trig.MoveToCurrentDirection(gameObject._position, gameObject.rotation -Trig.PI_Half, movementSpeed);

            }

            if (KEYBOARD.KeyDown(rightKey))
            {
                gameObject._position = Trig.MoveToCurrentDirection(gameObject._position, gameObject.rotation +Trig.PI_Half, movementSpeed);

            }
        }
Beispiel #4
0
 public void faceMouse(AnimatedGameObject gameObject)
 {
     gameObject.rotation = Trig.GetRadionsBetween(gameObject._position, mouseWC);
 }
        public void rotateObject(AnimatedGameObject gameObject)
        {
            if (KEYBOARD.KeyDown(rotateAntiClockwise))
            {
                gameObject.rotation -= rotationSpeed;
            }

            if (KEYBOARD.KeyDown(rotateClockwise))
            {
                gameObject.rotation += rotationSpeed;
            }
        }
Beispiel #6
0
 public void spawnBackground(int count)
 {
     for (int i = 0; i < count; i++)
     {
         float x = RANDOM.random.Next(0, 5000);
         float y = RANDOM.random.Next(0, 5000);
         Vector2 position = new Vector2(x, y);
         AnimatedGameObject gameObject = new AnimatedGameObject(position, Res.treeAnim);
         background.Add(gameObject);
     }
 }