Self.brick_y = i*(self.brick_wide+20)+40if self.brick_list=1: Self.brick_list =,]ĭef brickarrange(self):for i inrange(5):for j inrange(6): (self.game_window,self.rect_color,((self.mouse_x-self.rect_length//2),(self.window_wide-self.rect_wide),self.rect_length,self.rect_wide))classBrick(object): Self.mouse_x = self.window_length-self.rect_length//2if self.mouse_x <= self.rect_length//2: If self.mouse_x = self.window_length-self.rect_length//2: # Draw the racket and define the horizontal boundary Self.over_sign =1classRect(object):'''Create a racket class''' Self.gameover = self.over_font.render("Game Over",False,(0,0,0)) # Ball speed doubles every 5 times the ball is received (self.game_window,self.ball_color,(self.ball_x,self.ball_y),self.radius) # Draw the ball and set the bounce trigger condition Self.ball_y = self.window_wide-self.rect_wide-self.radius # Set the radius, color and moving speed parameters of the ball Self.game_window.fill(self.window_color)classBall(object):'''Create ball''' # Draw the background color of the game window # Define the background color parameters of the game window Self.game_window = _mode((self.window_length,self.window_wide)) # Draw the game window, set the window size The specific content is as follows # Import moduleįrom pygame.locals import*import sys,random,time,mathĬlassGameWindow(object):'''Create game window class''' The examples in this article share the specific code of Python to realize the brick-and-mortar game for your reference.
0 Comments
Leave a Reply. |