### Aiming crosshairs

#### magicpegasus

• Posts: 101
Hi, I've got my WIP of my next game, a cannon shooter called Mr. Turret, online and ready to play test.

http://www.stencyl.com/game/play/9662

One feature request I'm getting is an aiming reticle (crosshairs). Mr. Turret is able to aim in a quarter-circle range. The direction of the player is drawn on the lower left corner of the screen (angle).

How would I draw crosshairs based on the player's direction?

I know it must have something to do with radius and pi. Please point me in the right direction, Stencyl wizards!

Thank you,
MP

#### Miasmos Games

• Posts: 878
Wouldn't a 'beam' or line of some sort be better? The turret just fires infinitley in whatever direction it's point, rather than at a specific point.

Cupcake Bounce

#### DataRogue

• Posts: 20
After playing your game, if I understand you correctly. All you want is a crosshair to be drawn where you would theoretically fire your bullet correct?

If so, it has nothing to do with Pi or Radius. These are the equation you wanna use R*sin(theta)=Y, R*cos(theta)=X. Where R would be the distance you want the crosshair to be from the turret if the turret is either pointing directly up (90 degrees) or directly to the right (0 degrees). Theta is the angle which the turret is pointing at (The one you're currently displaying in your game.) Y and X are the respective cardinal coordinates of the cross hair.

Example: R is 20. Theta is 35.
Using that information R*sin(theta)=Y -> 20*sin(35)=11
R*cos(theta)=X -> 20*cos(35)=16

To check for accuracy we use the Pythagorean theorem 11^2 + 16^2 = 19.41. Considering I rounded the first time, it's close enough to 20.