Jump to content
  • Advertisement

alexsok90

Member
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

127 Neutral

About alexsok90

  • Rank
    Newbie
  1. public float XVel = 1.0f; public void BallMove() { if (ball.X < 0 || ball.X > 420) XVel *= -1; ball.X += XVel; }   Something more readable.
  2. alexsok90

    Turret rotation

    These values don't make any sense. Are you sure you are using Atan2 method? Also keep in mind that this code makes use of radian angles (not degrees). Or maybe your rotationSpeed value is too high. In my project it was like 0.02f (i was calling this method every update).   #EDIT You can also try replacing that "else if" with "if" only. Or swapping Atan2 arguments from "src - target" to "target - src".
  3. alexsok90

    Turret rotation

    Ah, sorry - this topRotation should be currentRotation. I was renaming the variables and missed this one.
  4. alexsok90

    Turret rotation

    Here is the code from tank game I developed. It rotates the turret clockwise or counter-clockwise (depeding on which path is shorter) with desired speed.   destinationRotation = Math.Atan2(turret.Y - target.Y, turret.X - target.X) + Math.PI; if (destinationRotation != currentRotation) { if (destinationRotation > currentRotation) { if (currentRotation < destinationRotation - Math.PI) currentRotation -= rotationSpeed; else currentRotation += rotationSpeed; } else if (destinationRotation < topRotation) { if (currentRotation > destinationRotation + Math.PI) currentRotation += rotationSpeed; else currentRotation -= rotationSpeed; } if (currentRotation > Math.PI * 2.0f) currentRotation = 0; if (currentRotation < 0) currentRotation = Math.PI * 2.0f; }
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!