()
| 70 | |
| 71 | |
| 72 | def introscreen(): |
| 73 | run = True |
| 74 | pygame.mixer.music.load("startingMusic.mp3") |
| 75 | pygame.mixer.music.play() |
| 76 | while run: |
| 77 | screen.fill((0, 0, 0)) |
| 78 | introImg(0, 0) |
| 79 | play(100, 450) |
| 80 | Instruction(280, 450) |
| 81 | ABOUT(615, 450) |
| 82 | |
| 83 | ####### getting coordinates of mouse cursor ####### |
| 84 | x, y = pygame.mouse.get_pos() |
| 85 | |
| 86 | ###### storing rectangle coordinates (x, y, length, height) by making variables |
| 87 | button1 = pygame.Rect(60, 440, 175, 50) |
| 88 | button2 = pygame.Rect(265, 440, 300, 50) |
| 89 | button3 = pygame.Rect(600, 440, 165, 50) |
| 90 | |
| 91 | ##### Drawing rectangles with stored coorditates of rectangles.###### |
| 92 | ###### pygame.draw.rect takes these arguments (surface, color, coordinates, border) ##### |
| 93 | pygame.draw.rect(screen, (255, 255, 255), button1, 6) |
| 94 | pygame.draw.rect(screen, (255, 255, 255), button2, 6) |
| 95 | pygame.draw.rect(screen, (255, 255, 255), button3, 6) |
| 96 | |
| 97 | #### if our cursor is on button1 which is PLAY button |
| 98 | if button1.collidepoint(x, y): |
| 99 | ### changing from inactive to active by changing the color from white to red |
| 100 | pygame.draw.rect(screen, (155, 0, 0), button1, 6) |
| 101 | #### if we click on the PLAY button #### |
| 102 | if click: |
| 103 | countdown() ## CALLING COUNTDOWN FUNCTION TO START OUR GAME |
| 104 | |
| 105 | #### if our cursor is on button2 which is INSTRUCTION button |
| 106 | if button2.collidepoint(x, y): |
| 107 | ### changing from inactive to active by changing the color from white to red |
| 108 | pygame.draw.rect(screen, (155, 0, 0), button2, 6) |
| 109 | #### if we click on the INSTRUCTION button #### |
| 110 | if click: |
| 111 | instructionIMG(0, 0) ### DISPLAYING OUR INSTRUCTION IMAGE BY CALLING IT |
| 112 | |
| 113 | #### if our cursor is on button3 which is ABOUT button |
| 114 | if button3.collidepoint(x, y): |
| 115 | ### changing from inactive to active by changing the color from white to red |
| 116 | pygame.draw.rect(screen, (155, 0, 0), button3, 6) |
| 117 | #### if we click on the ABOUT button #### |
| 118 | if click: |
| 119 | aboutIMG(0, 0) ### DISPLAYING OUR ABOUT IMAGE BY CALLING IT |
| 120 | |
| 121 | ###### checking for mouse click event |
| 122 | click = False |
| 123 | for event in pygame.event.get(): |
| 124 | if event.type == pygame.QUIT: |
| 125 | run = False |
| 126 | if event.type == pygame.MOUSEBUTTONDOWN: |
| 127 | if event.button == 1: |
| 128 | click = True |
| 129 | pygame.display.update() |
no test coverage detected