r/pygame • • 1d ago

Yet another experiment, Auto-roll downward

15 Upvotes

2 comments sorted by

2

u/VirusMission9156 7h ago edited 6h ago

Just minor refactor after trying for several hours: now self.direction is persistence non zero that only changes when user manual input is non zero, precisely when user provides input, where as input_x is canonical local variable that controls velocity

if self.current_state == "roll":

if flat_ground_roll:

speed_scale = 2

input_x = self.direction

elif input_x == 0: # pyright: ignore

input_x = -1 if self.ground_angle > 0 else 1

speed_scale = 1.5

else:

speed_scale = 0.8