Alright so here's my question - how would you go about limiting two variables to a common maximum? As in, the sum of X and Y cannot exceed M.
I ask because I started creating a space-ship movement system, where pressing the keys slowly changes your momentum. It's split into x-momentum and y-momentum. I like it because you can get the ship going at any angle and stop pressing the keys, and the ship will continue at the same angle (like in real outer space :D)
Anyway, the problem is that limiting each separately allows the ship to travel twice as fast if it is going diagonally. So if the max speed is 8, you could only go due north at 8 pixels per step. But, you could also go north at 8 pixels AND east at 8 pixels, and thus travel 16 pixels per step.
I was thinking of changing the whole thing, by instead having one speed variable, and an angle. But is there any other way?
Copyright © 2024 BYOND Software.
All rights reserved.