def __init__(self):
# run pygame in headless mode
# os.environ["SDL_VIDEODRIVER"] = "dummy"
pygame.init()
pygame.key.set_repeat(10, 100)
# set constants
self.COLOR_WHITE = (255, 255, 255)
self.COLOR_BLACK = (0, 0, 0)
self.GAME_WIDTH = 400
self.GAME_HEIGHT = 400
self.BALL_WIDTH = 20
self.BALL_HEIGHT = 20
self.PADDLE_WIDTH = 50
self.PADDLE_HEIGHT = 10
self.GAME_FLOOR = 350
self.GAME_CEILING = 10
# based on experimentation, the ball tends to move 4 times
# between each paddle movement. Since here we alternate ball
# and paddle movement, we make ball move 4x faster.
self.BALL_VELOCITY = 10
self.PADDLE_VELOCITY = 20
self.FONT_SIZE = 30
# self.MAX_TRIES_PER_GAME = 100
self.MAX_TRIES_PER_GAME = 1
self.CUSTOM_EVENT = pygame.USEREVENT + 1
self.font = pygame.font.SysFont("Comic Sans MS", self.FONT_SIZE)
评论列表
文章目录