@Chewy
Are you rotating the gun or positioning it?
If you're rotating then the angle you use must be between 0 and 360, if you want -20 use the
wrapvalue(n) function.
It takes n and checks whether it is within 0 to 360; if less than 0 it returns n+360, if more than 360 it returns n-360 . So wrapvalue(-20) would come out as 340.
As for the rest of your code read
this, you need to use subroutines and function if you want to write a game engine. Is this something you're planning for others to use?
Riddle: The more you take, the more you leave behind. What are they?
Answer