Finding right angles
Posted: Sun Feb 08, 2009 10:48 am
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.
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.