ultimate-smash-friends
ultimate-smash-friends copied to clipboard
Remove Hard-Coded calculations
A lot of code is written with concrete "magic" numbers, which not only makes it difficult to update code, but makes it difficult to interpret existing code as well. These should be replaced with constants, and functions/methods that abstract the calculations so that algorithms may be changed when needed, without breaking the game.
A few examples (references using my fork):
- lines 94-97 in usf/game.py
- players_barycenter method of Game object in usf/game.py
- center_zoom_camera method of Game object in usf/game.py
This happens in plenty of other files as well, but as I was looking at the new camera implementation, it was easiest to point out the examples in game.py
I agree, there are those hard coded values all over the place, either we find computations not requiering them, or we try to keep them hard coded in as few places as possible (i.e. one time each).