Anonymous avatar Anonymous committed d8bebe2

Working on issue 6

Comments (0)

Files changed (3)

pypong-clock/ball.py

             self.rect.left = (self.surface.get_width()/2)
             #set the new velocity to a random between initial and max
             self.velocity[0] = random.randint(self._initial_velocity[0], MAX_HORIZONTAL_VELOCITY)
-            self.velocity[1] = random.randint(self._initial_velocity[1], MAX_VERTICAL_VELOCITY)
+            self.velocity[1] = -1 * abs(random.randint(self._initial_velocity[1], MAX_VERTICAL_VELOCITY))
             self.velocity[0] *= -1.0  # change direction
             self.need_updated_intercept_position = True
             self.point_scored('left')
             self.rect.left = (self.surface.get_width()/2)   
             #set the new velocity to a random between initial and max
             self.velocity[0] = random.randint(self._initial_velocity[0], MAX_HORIZONTAL_VELOCITY)
-            self.velocity[1] = random.randint(self._initial_velocity[1], MAX_VERTICAL_VELOCITY)
+            self.velocity[1] = -1 * abs(random.randint(self._initial_velocity[1], MAX_VERTICAL_VELOCITY))
             #self.velocity[0] *=	-1  #change direction
             #print 'right player score - ball exited at: ' + str(t_position.top)
             self.point_scored('right')

pypong-clock/paddle.py

         t_position = pygame.Rect((self._rect.left, self._rect.top + self.velocity, self._rect.width, self._rect.height))
 
         #only stop moving if we will move above the top or bottom edge and tracking beneath or above it
-        if t_position.top <= self.play_area.top and \
-                                self.track_to_position - self._rect.height / 2  < self.play_area.top:
+        # for #6 changed boundary check to greater than rather than greater than or equal this allows paddle
+        # to travel further up.
+        if t_position.top < self.play_area.top and \
+                                self.track_to_position - self._rect.height / 2 < self.play_area.top:
             turn_velocity = self.play_area.top - self._rect.top  # move next to border
             at_boundary = True
 
-        if t_position.bottom >= self.play_area.top + self.play_area.height \
+        if t_position.bottom > self.play_area.top + self.play_area.height \
             and self.track_to_position + self._rect.height / 2 > \
                                 self.play_area.top + self.play_area.height:
             turn_velocity = self.play_area.top + self.play_area.height - self._rect.bottom

pypong-clock/pypong-clock.py

     now = datetime.datetime.now()
     hour = now.strftime("%I")
 
+    # Working on Issue # 6
+    if left_score.score > int(hour):
+        right_score.reset_score()
+        left_score.reset_score()
+        CAN_RESET_HOUR = False
+        return
+
     if left_score.score < int(hour):
         right_paddle.allow_score()
         return
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.