Advertisement
Guest User

Untitled

a guest
Mar 9th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.37 KB | None | 0 0
  1. #!/usr/bin/python
  2. import pygame
  3. from pong import Pong
  4. from pygame.locals import *
  5.  
  6. # Create an instance
  7. game = Pong()
  8.  
  9. # Initalize the game
  10. pygame.init()
  11.  
  12. pygame.display.set_caption("Swift Pong!")  # Window Caption Title
  13.  
  14. screen = pygame.display.set_mode((900,600),0,32)
  15. screen.blit(screen, (0,0))
  16.  
  17. pygame.mouse.set_visible(False)     # Hide mr. mouse
  18. beeper = pygame.image.load('paddle.png')     # Paddle
  19. bpaddle = pygame.image.load('blank_paddle.png')     # Paddle that is drawn over the green one to ensure "motion"
  20.  
  21.  
  22.  
  23. paddle_rect = beeper.get_rect()
  24. bounds_rect = pygame.Rect(0, 0, 300, 300)
  25.  
  26. blank_rect = bpaddle.get_rect()
  27. b_bounds_rect = pygame.Rect(0, 0, 300, 300)
  28.  
  29. paddle_pos = (0,0)
  30. clock = pygame.time.Clock()
  31.  
  32. while True:
  33.     for event in pygame.event.get():
  34.         if event.type == QUIT:
  35.             sys.exit()
  36.  
  37.     screen.blit(bpaddle, paddle_pos)
  38.     # Draw the net
  39.     pygame.draw.line(screen, game.lineColor, game.net1, game.net2, game.netWidth)
  40.  
  41.     if (0,0) <= paddle_pos <= (300,300):
  42.          paddle_rect.center = pygame.mouse.get_pos()
  43.          paddle_rect.clamp_ip(bounds_rect)
  44.          screen.blit(beeper, paddle_rect)
  45.  
  46.          clock.tick(50)
  47.  
  48.          b_bounds_rect.center = pygame.mouse.get_pos()
  49.          b_bounds_rect.clamp_ip(b_bounds_rect)
  50.          screen.blit(bpaddle, blank_rect)
  51.          pygame.display.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement