I'm making a small game where you play as a turret in the middle of the screen trying to shoot the enemies coming after you. I am having difficulties, however, in trying to figure out how to make the turret change sprites depending on where my mouse cursor is pointing. I don't want to rotate the sprite, mind you, as I already have made different variations of the same sprite for the different directions it will face:
I have an idea of how to accomplish this, but I don't know how to make it happen:
The program generates 42 rays, (one for each turret sprite), that originate from the turret
If the cursor falls between two of those rays, a specific sprite will be drawn
How would I go about doing this? It doesn't have to be the method described above as long as it produces the same result.
Thanks for your help in advance!