From 7f5c1506e2ab09e197538953847893c127902a98 Mon Sep 17 00:00:00 2001 From: Don Clark Date: Mon, 19 Aug 2013 21:28:17 -0700 Subject: [PATCH] Working on issue 6 --- pypong-clock/ball.py | 26 ++++++++++++++++++++++++-- pypong-clock/pypong-clock.py | 7 ++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/pypong-clock/ball.py b/pypong-clock/ball.py index 1613a6c..ade5232 100644 --- a/pypong-clock/ball.py +++ b/pypong-clock/ball.py @@ -92,7 +92,7 @@ class Ball(pygame.sprite.DirtySprite): print 'distance c', distance_c print 'position', self.rect - + down = False if self.velocity[1] > 0: down = True @@ -157,7 +157,29 @@ class Ball(pygame.sprite.DirtySprite): elif t_position.bottom > self.surface.get_height() - self.top_bottom_offset: self.velocity[1] *= -1.0 self.need_updated_intercept_position = True - + + #6 Attempt to fix #6 where we have zombie balls with the next two elifs + + elif self.rect.left > self.surface.get_width() + 40: # #6 should not happen + self.rect.top = (self.surface.get_height()/2) + 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] = -1 * abs(random.randint(self._initial_velocity[1], MAX_VERTICAL_VELOCITY)) + self.velocity[0] *= -1.0 # change direction + self.need_updated_intercept_position = True + + elif self.rect.left - self.rect.width < -40: # #6 should not happen right edge more than 40 off0 + self.rect.top = (self.surface.get_height()/2) + 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] = -1 * abs(random.randint(self._initial_velocity[1], MAX_VERTICAL_VELOCITY)) + self.velocity[0] *= -1.0 # change direction + self.need_updated_intercept_position = True + + # What happens if we're off screen here? + #Check to see if we score elif t_position.right > self.surface.get_width(): # score #increase score for left player diff --git a/pypong-clock/pypong-clock.py b/pypong-clock/pypong-clock.py index 3772f05..cba1533 100644 --- a/pypong-clock/pypong-clock.py +++ b/pypong-clock/pypong-clock.py @@ -40,7 +40,7 @@ FIELD_EDGE_HEIGHT = 4 # Height of edging FIELD_EDGE_OFFSET = 8 # Offset between the display surface edge and the edging CAN_RESET_HOUR = True # On the hour we reset the score to 00, 00 -SCREEN_MODE = pygame.FULLSCREEN # RESIZABLE as option +SCREEN_MODE = pygame.RESIZABLE # RESIZABLE as option #Check argv for anything interesting. for arg in sys.argv: @@ -181,6 +181,11 @@ def check_time(right_paddle, left_paddle, left_score, right_score, ball): If different it forces a miss to increase the score""" global CAN_RESET_HOUR now = datetime.datetime.now() + print "Time ", now + print "Hour ", now.strftime("%I") + print "Minute ", now.minute + + #now = time.localtime() hour = now.strftime("%I") # Working on Issue # 6 -- 2.1.1.1.g1fb337f