Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simplifying random_speed() and correcting random_position(), also add…

…ing documentation.
  • Loading branch information...
commit 991811bfb4edc315cb86b4f904e22cd7a1e4528b 1 parent 4675c45
@asweigart authored
Showing with 9 additions and 2 deletions.
  1. +9 −2 square-shooter/square-shooter_makeover.py
View
11 square-shooter/square-shooter_makeover.py
@@ -109,11 +109,18 @@ def collides_with(self, other):
distance = math.sqrt(a * a + b * b)
return distance < (self.radius + other.radius)
+
def random_position():
- return (random.random() - 0.5) * 3 + 0.5;
+ """Returns a random float value that will be near the edge of the map"""
+ if random.randint(0, 1) == 0:
+ return random.uniform(0.0, 0.25)
+ else:
+ return random.uniform(0.75, 1.0)
def random_speed(magnitude):
- return (random.random() * magnitude * 2 - magnitude)
+ """Returns a random float value between -magnitude and magnitude."""
+ return random.uniform(-magnitude, magnitude)
+
def make_bubble(kind):
if kind == "big":
Please sign in to comment.
Something went wrong with that request. Please try again.