def draw(self): self.screen.blit(self.Slime, (450, 300)) self.screen.blit(self.Title_Title, (100,100)) #self.screen.fill((255,255,255)) for Title_Menu_Item in self.Title_Menu_Items: self.Title_Menu = self.Title_Menu_Font.render(Title_Menu_Item, 1, self.red) if self.Title_Menu.get_rect(topleft = (self.Title_Menu_Items[Title_Menu_Item])).collidepoint(pygame.mouse.get_pos()): self.Title_Menu = self.Title_Menu_Font.render(Title_Menu_Item, 1, self.blue) if pygame.mouse.get_pressed()[0]: if Title_Menu_Item == "Quit": pygame.quit() sys.exit() elif Title_Menu_Item == "Continue": print("Continue") elif Title_Menu_Item == "New Game": self.case.update(ch.updateDict(self.case, 'Game Core')) elif Title_Menu_Item == "Map Editor": self.case.update(ch.updateDict(self.case, 'Map Editor')) elif Title_Menu_Item == "Options": options_menu() self.screen.blit(self.Title_Menu, self.Title_Menu_Items[Title_Menu_Item])
def draw(self): self.Game_Menu_back_width = 160 self.Game_Menu_back_height = 75 pygame.draw.rect(self.screen, self.white, (20, 20, self.Game_Menu_back_width, self.Game_Menu_back_height)) self.Game_Menu_back = pygame.draw.rect(self.screen, self.blue, (30, 30, self.Game_Menu_back_width - 20, self.Game_Menu_back_height - 20)) for Game_Menu_Item in self.Game_Menu_Items: self.Game_Menu = self.Game_Menu_Font.render(Game_Menu_Item, 1, self.white) if self.Game_Menu.get_rect(topleft = (self.Game_Menu_Items[Game_Menu_Item])).collidepoint(pygame.mouse.get_pos()): self.Game_Menu = self.Game_Menu_Font.render("▶" + Game_Menu_Item[1:], 1, self.white) if pygame.mouse.get_pressed()[0]: if Game_Menu_Item == " Quit": self.case.update(ch.updateDict(self.case, 'Game Menu')) elif Game_Menu_Item == " Options": print("Options") self.screen.blit(self.Game_Menu, self.Game_Menu_Items[Game_Menu_Item])
while running: clock.tick(60) screen.fill((255,255,255)) #print(ch.currentCase(case)) if case['Title Menu'] == True: Title_Menu.draw() if case['Game Menu'] == True: Game_Menu.draw() if case['Map Editor'] == True: Map_Editor.main() case.update(ch.updateDict(case, 'Title Menu')) #Mob_Slime.draw("L") if case['Game Core'] == True: Game_Core.main() case.update(ch.updateDict(case, 'Title Menu')) for event in pygame.event.get(): if event.type == pygame.QUIT: running = False elif event.type == pygame.KEYDOWN and event.key == K_ESCAPE: running = False pygame.display.flip()