There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Phil Freihofner wrote:
This implementation has some definite limitations, because the distance traveled per time slice will be larger on diagonals than on horizontal or vertical paths. One can use trig functions to ensure distance traveled is the same in all directions.
"Il y a peu de choses qui me soient impossibles..."
I think you can skip the trig, Phil.
Phil Freihofner wrote:
I think you can skip the trig, Phil.
I was referring to the following common situation:
If the rocket is standing still and has its X velocity increased by 1, it will be going 1 pixel per slice. If this rocket then has its Y velocity increased by 1, it will be going something more like 1.4 pixels per slice, yes?
Many early games and simple games treat a distance of 1 along the diagonal as equivalent to 1 along the horizontal or vertical. The classic "Snake" comes to mind as an example.
If you have a "booster" or "accelerator" for your rocket, and it can go in any direction, then at some point in the process you will need trig to determine how to break out a given amount of boost into the component X and Y vectors, if you want to maintain a more accurate physical model.
"Il y a peu de choses qui me soient impossibles..."
Phil Freihofner wrote:I'm in total agreement, but am uncomfortable being told that I obtained the 1.4 number without trig. In fact, I did look up to verify sin(PI/4) and cos(PI/4) both equal approx 0.7. An alternate route, the Pythagorean equation a^2 = b^2 + c^2, leading in this case to the square root of 2 also kind of counts as something learned in trig, yes?
"Il y a peu de choses qui me soient impossibles..."
The first person to drink cow's milk. That started off as a dare from this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|