forked from ndyer/pygame-dvd
prevent the logo speed from dropping too low
This commit is contained in:
parent
ae84831c1c
commit
988c7ce248
@ -110,7 +110,11 @@ class SteamLogo(pygame.sprite.Sprite):
|
|||||||
# Mini logos have some randomness built into their bounce function to make the background look more organic.
|
# Mini logos have some randomness built into their bounce function to make the background look more organic.
|
||||||
if self.is_mini:
|
if self.is_mini:
|
||||||
# Reflect off the left or right wall, clamping the speed (in case it was raised too high)
|
# Reflect off the left or right wall, clamping the speed (in case it was raised too high)
|
||||||
self.x_speed = max(-1 * self.max_speed, min((self.x_speed * -1), self.max_speed))
|
# The speed gets clamped if it goes above the max speed or below the starting speed (max - 1)
|
||||||
|
if self.x_speed > 0:
|
||||||
|
self.x_speed = max(-1 * self.max_speed, min((self.x_speed * -1), (-1 * self.max_speed) + 1))
|
||||||
|
else:
|
||||||
|
self.x_speed = max(self.max_speed - 1, min((self.x_speed * -1), self.max_speed))
|
||||||
# Add or subtract anywhere from 0 to 10% of the max speed to the vertical speed component
|
# Add or subtract anywhere from 0 to 10% of the max speed to the vertical speed component
|
||||||
self.y_speed += random.uniform(self.max_speed * 0.1, self.max_speed * -0.1)
|
self.y_speed += random.uniform(self.max_speed * 0.1, self.max_speed * -0.1)
|
||||||
|
|
||||||
@ -122,7 +126,10 @@ class SteamLogo(pygame.sprite.Sprite):
|
|||||||
# Do the same stuff for the top and bottom walls
|
# Do the same stuff for the top and bottom walls
|
||||||
if self.float_y < 0 or self.float_y > self.max_y:
|
if self.float_y < 0 or self.float_y > self.max_y:
|
||||||
if self.is_mini:
|
if self.is_mini:
|
||||||
self.y_speed = max(-1 * self.max_speed, min((self.y_speed * -1), self.max_speed))
|
if self.y_speed > 0:
|
||||||
|
self.y_speed = max(-1 * self.max_speed, min((self.y_speed * -1), (-1 * self.max_speed) + 1))
|
||||||
|
else:
|
||||||
|
self.y_speed = max(self.max_speed - 1, min((self.y_speed * -1), self.max_speed))
|
||||||
self.x_speed += random.uniform(self.max_speed * 0.1, self.max_speed * -0.1)
|
self.x_speed += random.uniform(self.max_speed * 0.1, self.max_speed * -0.1)
|
||||||
else:
|
else:
|
||||||
self.y_speed *= -1
|
self.y_speed *= -1
|
||||||
|
Loading…
Reference in New Issue
Block a user