How to use python to hit brick Mini Game
This article mainly introduces how to use python to achieve hit brick Mini Game related knowledge, the content is detailed and easy to understand, simple and fast operation, has a certain reference value, I believe that everyone after reading this article on how to hit brick Mini Game with python will have a harvest, let's take a look at it.
To develop educational brick Mini Game, you can try how many pieces you can play.
Import pygame,sys,time,randomfrom pygame.locals import * # from static_params import * # introduces all static parameters from GameClass import * pygame.init () # initialize the game mainclock = pygame.time.Clock () # clock setting Exit = 0global Surface Surface = pygame.display.set_mode ([WindowWidth,WindowHeight] 0 intro_Ball.png' 32) # window setting pygame.display.set_caption ('Brick Game') # setting window title def BeforeGame (): StartImage = pygame.image.load ('Brick). Convert_alpha () # Interface of the start image button = Button (Surface,FontColor,TextLocation 'StartGame') flag = True while flag: for event in pygame.event.get (): if event.type = = QUIT: Exit = 1 pygame.quit () exit () if event.type = = MOUSEBUTTONUP: if button.is_overed (): flag = False Surface.blit (StartImage ImageLocation) button.ButtonBlit () pygame.display.update () mainclock.tick (100) def Gaming (): # set a pause function def pause (): button = Button (Surface,FontColor,TextLocation,'Continue') Surface.fill ((0mem0) 0) flag = True while flag: for event in pygame.event.get (): if event.type = = QUIT: Exit = 1 pygame.quit () exit () if event.type = = MOUSEBUTTONUP: if button.is_overed () Flag = False pygame.mouse.set_visible (True) button.ButtonBlit () pygame.display.update () mainclock.tick (100) Ball = ball (BallCenter BallRadius,BallColor,BallSpeed,MoveAngle,Surface) paddle = Paddle (0PaddleHeightGrampaddleWidthRecompaddleWidthParticles) # set a brick matrix BrickMatrix = [Brick [Brick] (BrickWidthMoreBrickHeightFormBrickHeightFormBrickHeightFormBrickHeightFormBrickHeightForm3) if i+BrickWidth WindowHeight: if Ball.center [0] > paddle.left and Ball.center [0] brick.left and Ball.center [0] brick.bottom and Ball.center [1]-