Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame, sys
- # Setup pygame/window ---------------------------------------- #
- mainClock = pygame.time.Clock()
- from pygame.locals import *
- SCREEN_WIDTH = 1143
- SCREEN_HEIGHT = 650
- pygame.image.load(r"C:\Users\ga-sa\Downloads\iniciar.png")
- class Circuito(pygame.sprite.Sprite):
- def __init__(self):
- pygame.sprite.Sprite.__init__(self)
- self.images = [pygame.image.load(r'C:\Users\ga-sa\Downloads\00.png').convert_alpha(),
- pygame.image.load(r'C:\Users\ga-sa\Downloads\01.png').convert_alpha(),
- pygame.image.load(r"C:\Users\ga-sa\Downloads\02.png").convert_alpha(),
- pygame.image.load(r'C:\Users\ga-sa\Downloads\03.png').convert_alpha()]
- self.current_image = 0
- self.image = pygame.image.load(r'C:\Users\ga-sa\Downloads\00.png').convert_alpha()
- self.rect = self.image.get_rect()
- self.rect[0] = 500
- self.rect[1] = 10
- def update(self):
- self.current_image = (self.current_image + 1) % 4
- self.image = self.images[ self.current_image ]
- pygame.init()
- pygame.display.set_caption('game base')
- screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
- iniciar = pygame.image.load(r"C:\Users\ga-sa\Downloads\iniciar.png")
- config = pygame.image.load(r"C:\Users\ga-sa\Downloads\config.png")
- nivel = pygame.image.load(r"C:\Users\ga-sa\Downloads\nivel.png")
- sair = pygame.image.load(r"C:\Users\ga-sa\Downloads\sair.png")
- BACKGROUND = pygame.image.load(r'C:\Users\ga-sa\Downloads\honeycomb.png')
- BACKGROUND = pygame.transform.scale(BACKGROUND, (SCREEN_WIDTH, SCREEN_HEIGHT))
- BACKGROUND_FASE = pygame.image.load(r"C:\Users\ga-sa\Downloads\FaseSemX_1.png")
- BACKGROUND_FASE = pygame.transform.scale(BACKGROUND_FASE, (SCREEN_WIDTH, SCREEN_HEIGHT))
- font = pygame.font.SysFont(None, 20)
- def draw_text(text, font, color, surface, x, y):
- textobj = font.render(text, 1, color)
- textrect = textobj.get_rect()
- textrect.topleft = (x, y)
- surface.blit(textobj, textrect)
- click = False
- def main_menu():
- while True:
- screen.fill((0, 0, 0))
- draw_text('main menu', font, (255, 255, 255), screen, 20, 20)
- mx, my = pygame.mouse.get_pos()
- button_1 = pygame.Rect(400, 50, 800, 200)
- button_2 = pygame.Rect(450, 500, 720, 180)
- if button_1.collidepoint((mx, my)):
- if click:
- game()
- if button_2.collidepoint((mx, my)):
- if click:
- options()
- pygame.draw.rect(screen, (255, 0, 0), button_1)
- pygame.draw.rect(screen, (255, 0, 0), button_2)
- click = False
- for event in pygame.event.get():
- if event.type == QUIT:
- pygame.quit()
- sys.exit()
- if event.type == KEYDOWN:
- if event.key == K_ESCAPE:
- pygame.quit()
- sys.exit()
- if event.type == MOUSEBUTTONDOWN:
- if event.button == 1:
- click = True
- screen.blit(BACKGROUND, (0,0))
- screen.blit(iniciar, (400, 50))
- screen.blit(config, (450, 500))
- screen.blit(nivel, (400, 280))
- screen.blit(sair, (400, 700))
- pygame.display.update()
- mainClock.tick(60)
- def game():
- running = True
- while running:
- screen.fill((0, 0, 0))
- mx, my = pygame.mouse.get_pos()
- button_3 = pygame.Rect(300, 100, 1300, 700)
- if button_3.collidepoint((mx, my)):
- if click:
- begin()
- draw_text('game', font, (255, 255, 255), screen, 20, 20)
- for event in pygame.event.get():
- if event.type == QUIT:
- pygame.quit()
- sys.exit()
- if event.type == KEYDOWN:
- if event.key == K_ESCAPE:
- running = False
- # set the pygame window name
- img1 = pygame.image.load(r"C:\Users\ga-sa\Downloads\As.png")
- img2 = pygame.image.load(r"C:\Users\ga-sa\Downloads\AssetsXOR.png")
- img3 = pygame.image.load(r"C:\Users\ga-sa\Downloads\AssetsNOT.png")
- img4 = pygame.image.load(r"C:\Users\ga-sa\Downloads\AssetsAND.png")
- images = [img1, img2, img3, img4]
- current_image = -1
- img_rects = [images[i].get_rect(topleft=(20 + 40 * i, 20)) for i in range(len(images))]
- LeftButton = 0
- while 1:
- for e in pygame.event.get():
- if e.type == QUIT:
- pygame.quit()
- exit(0)
- if e.type == pygame.MOUSEBUTTONDOWN:
- mouse_rect = pygame.Rect(e.pos, (1, 1))
- current_image = mouse_rect.collidelist(img_rects)
- if e.type == MOUSEMOTION:
- if e.buttons[LeftButton]:
- rel = e.rel
- if 0 <= current_image < len(images):
- img_rects[current_image].x += rel[0]
- img_rects[current_image].y += rel[1]
- screen.fill(0)
- for i in range(len(images)):
- screen.blit(images[i], img_rects[i])
- pygame.display.flip()
- pygame.time.delay(30)
- screen.blit(BACKGROUND_FASE, (0, 0))
- pygame.display.update()
- mainClock.tick(60)
- def begin():
- running = True
- while running:
- screen.fill((0, 0, 0))
- draw_text('begin', font, (255, 255, 255), screen, 20, 20)
- for event in pygame.event.get():
- if event.type == QUIT:
- pygame.quit()
- sys.exit()
- if event.type == KEYDOWN:
- if event.type == KEYDOWN:
- running = False
- pygame.display.update()
- mainClock.tick(60)
- def options():
- running = True
- while running:
- screen.fill((0, 0, 0))
- draw_text('options', font, (255, 255, 255), screen, 20, 20)
- for event in pygame.event.get():
- if event.type == QUIT:
- pygame.quit()
- sys.exit()
- if event.type == KEYDOWN:
- if event.key == K_ESCAPE:
- running = False
- pygame.display.update()
- mainClock.tick(60)
- main_menu()
Advertisement
Add Comment
Please, Sign In to add comment