Page 1 of 1

Finding right angles

PostPosted: Sun Feb 08, 2009 10:48 am
by Fuzzy
It is not often that I post GEDs here. I like people to do their own coding, and generally focus on trying to help people learn problem solving. You can learn GE and C just about anywhere, but after you get the basics, You'll have a hard time until you learn problem solving. If you need to do something and its taking lines and lines of code, chances are you are doing it wrong. There is always a way that is simple and clean. Efficient(and bug free) coding is finding that way.

This is one of those little situations where you need to find an angle 90 degrees to the right of left of a line or direction. You will note that I dont use any funny math, and certainly not one bloody IF!

Use the mouse to press the arrow keys to change x and y velocity. The red line will show direction of travel, and the blue and green lines will be 90 degrees of that. Numbers indicate magnitude of each. All the interesting stuff happens in pointer.draw

All my lines are commented. Comments add no size to your completed game and have no effect on performance. Always comment your lines.

If you find a use for the grass tile, feel free to use it. It is copyright to me and it is free for public use.

The zip and rar contain the same files. Use the one you like better.
Find90Degrees.zip
(528.34 KiB) Downloaded 195 times
Find90Degrees.rar
(512.6 KiB) Downloaded 161 times

Re: Finding right angles

PostPosted: Sun Feb 08, 2009 3:06 pm
by jimmynewguy
Great! I myself have yet to find a use for it in a game, but im sure someone will, either way its neato :D


PS: We need to make a rule where you can't download something without leaving a post.... :lol: so many things get downloaded like 50 times with only 3 people saying anything about :evil: oh well, you can't change some things...

Re: Finding right angles

PostPosted: Sun Feb 08, 2009 4:32 pm
by Camper1995
..wow.. :mrgreen:

Re: Finding right angles

PostPosted: Sun Feb 08, 2009 5:08 pm
by DST
Hey....shouldn't those arrows be clones of each other? :D

Re: Finding right angles

PostPosted: Sun Feb 08, 2009 8:57 pm
by Fuzzy
DST wrote:Hey....shouldn't those arrows be clones of each other? :D


Not If i wanted to avoid IFs!