View Single Post
  #3  
Old 06-19-2012, 03:36 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by E_Man View Post
But what is pi, it's in both gs1 and gs2 scripts, is that 3.14 or does it mean something else?
Programming languages typically work in radians instead of degrees. There's 2pi radians in a circle.



Notice how the radians on the circle (they have pi attached) compare to the degrees.

So to get the angle bullets should fly at, we can do..
PHP Code:
(player.dir 1) * (pi 2
Let's say I'm facing left, which means my dir is 1.



So we can start filling in values for that expression

PHP Code:
(1) * (pi 2
simplifies to..

PHP Code:
* (pi 2
which simplifies using basic math to simply pi. If we look on that circle, we can see where the angle pi lies.



This is where our bullets will fly. Try the same thing for any direction and you'll find the angle matches up to the direction the player is facing.
__________________
Reply With Quote