External Exam Download Resources Web Applications Games Recycle Bin

Cups guessing game

cups guessing game.py

import pygame
pygame.init()
screen = pygame.display.set_mode((400, 300))
done = False

cup1 = pygame.image.load("cup.png")
cup2 = pygame.image.load("cup.png")
cup3 = pygame.image.load("cup.png")

while not done:
  for event in pygame.event.get():
    if event.type == pygame.QUIT:
      done = True
    if event.type == pygame.MOUSEBUTTONDOWN:
      click = pygame.mouse.get_pos()
      if cup1.get_rect(topleft=(0,50)).collidepoint(click):
        cup1 = pygame.image.load("cup_and_nothing.png")     
      if cup2.get_rect(topleft=(150,50)).collidepoint(click):
        cup2 = pygame.image.load("cup_and_nothing.png")
      if cup3.get_rect(topleft=(300,50)).collidepoint(click):
        cup3 = pygame.image.load("cup_and_ball.png")    
  screen.blit(cup1, (0, 50))
  screen.blit(cup2, (150, 50))
  screen.blit(cup3, (300, 50))
  pygame.display.flip()
  
pygame.quit()
     
put all images and python file into same folder: