You could do this. But then you'd have to redo it whenever you decide to change your angle resolution from 24 steps per turn to 32 or 64 or whatever. I guess it depends on how strictly you want to interpret "don't repeat yourself".DRW wrote: ↑Fri Jun 26, 2020 5:40 pm I could simply create a little C++ program in Windows that does this:I wouldn't even need to write this output into a source code file. Since I only have four numbers anyway, I could just calculate them once and use them directly in my program, couldn't I?Code: Select all
for (int i = 1; i <= 7; i += 2) { cout << "#define TURN_" << i << " " << (int)(256 * tan((double)i / 64 * M_PI * 2)) << "\n"; }
Shooting projectiles at the player from predefined angles
Moderator: Moderators
Re: Shooting projectiles at the player from predefined angles
Re: Shooting projectiles at the player from predefined angles
If I ever decide to do more angles, I need to define movement arrays for these angles anyway, and I have to do more ifs manually. So, this should be alright.
By the way, I tried it out and it works great. I'll take this method now. Thanks a lot.
Oh, by the way: Your calculation of the slope could create a division by zero if hero and weapon have the same y position.
By the way, I tried it out and it works great. I'll take this method now. Thanks a lot.
Oh, by the way: Your calculation of the slope could create a division by zero if hero and weapon have the same y position.
My game "City Trouble":
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
Re: Shooting projectiles at the player from predefined angles
My NES-side angle calculation routine reflects the (X, Y) coordinates into the first octant before calculating the angle. That way, the slope is always in the [0 ... 1] interval.