예제 #1
0
 def main(self):
     joystick.Reset()
     while not self.done:
         self.events()
         self.draw()
         self.update()
     transition(self.display, 5)
     joystick.Reset()
     return self.map[self.selected_point].mission, self.selected_point
예제 #2
0
 def main(self):
     joystick.Reset()
     while not self.done:
         self.events()
         self.draw()
         self.update()
     pygame.mixer.music.fadeout(1000)
     transition(self.Display, 5)
     joystick.Reset()
     return self.profile
 def main(self):
     self.fade_in()
     joystick.Reset()
     while not self.done:
         self.events()
         self.draw()
         self.update()
     black_out(self.display, 5)
     joystick.Reset()
     pygame.mixer.music.fadeout(500)
     return self.map[self.selected_point].mission, self.selected_point
 def main(self):
     pygame.event.set_grab(True)
     joystick.Reset()
     while not self.done:
         self.events()
         self.draw()
         self.update()
     pygame.mixer.music.fadeout(1000)
     black_out(self.Display, 5)
     joystick.Reset()
     pygame.event.set_grab(False)
     return self.profile
예제 #5
0
def display_info(display, images, item):
    clock = pygame.time.Clock()
    background = display.copy()
    done = False
    stuff_rect = pygame.Rect(0, 0, 500, 500)
    stuff_rect.center = display.get_rect().center
    icon_rect = pygame.Rect(0, 0, 100, 100)
    icon_rect.topleft = stuff_rect.move(5, 5).topleft
    data_rect = pygame.Rect(0, 0, 375, 480)
    data_rect.midtop = stuff_rect.move(50, 5).midtop
    while not done:
        for event in pygame.event.get():
            joystick.Update(event)
            if not hasattr(event, "key"):
                event.key = None
            if event.type == pygame.QUIT:
                done = True
            if event.type == pygame.KEYUP or joystick.WasEvent():
                if event.key in (pygame.K_ESCAPE, pygame.K_RETURN, pygame.K_q,
                                 pygame.K_SPACE, pygame.K_BACKSPACE,
                                 pygame.K_y) or joystick.GoEvent(
                                 ) or joystick.BackEvent():
                    done = True
        display.blit(background, (0, 0))
        pygame.draw.rect(display, (50, 50, 50), stuff_rect)
        pygame.draw.rect(display, (255, 255, 0), stuff_rect, 2)
        display.blit(pygame.transform.scale(images[item.icon], (100, 100)),
                     icon_rect)
        pygame.draw.rect(display, (0, 0, 0), icon_rect, 1)
        pygame.draw.rect(display, (0, 0, 0), data_rect, 1)
        retro_text(data_rect.move(0, 10).midtop,
                   display,
                   15,
                   f'Information for "{item.title}"',
                   anchor="midtop",
                   font="impact")
        for y, line in enumerate(format_info(item).split("\n")):
            retro_text(data_rect.move(5, 40 + 14 * y).topleft,
                       display,
                       14,
                       line,
                       font="Sans")
        retro_text(stuff_rect.move(0, 2).midbottom,
                   display,
                   14,
                   "Press Enter to exit",
                   anchor="midbottom",
                   color=(0, 0, 0))
        retro_text(stuff_rect.midbottom,
                   display,
                   14,
                   "Press Enter to exit",
                   anchor="midbottom")
        pygame.display.update()
        clock.tick(25)
    joystick.Reset()
    def info(self):
        display = self.display.copy()
        done = False
        rect = pygame.Rect(0, 0, 600, 400)
        rect.center = self.display.get_rect().center
        data = f"""
Shots fired: {len(self.acc)}
Shots hit: {self.acc.count(True)}
Shots missed: {self.acc.count(False)}
Accuracy: {self.acc_per2}%

Total attempts to beat this level:{self.lost}

Max Combo: {self.maxcombo}"""
        while not done:
            for event in pygame.event.get():
                joystick.Update(event)
                if not hasattr(event, "key"):
                    event.key = None
                if event.type == pygame.QUIT:
                    done = True
                if event.type == pygame.KEYUP or joystick.WasEvent():
                    if event.key == pygame.K_F2 or joystick.JustPressedLB():
                        screenshot.capture("WL_info", self.display)
                    if event.key in (pygame.K_q, pygame.K_ESCAPE,
                                     pygame.K_RETURN, pygame.K_SPACE,
                                     pygame.K_y) or joystick.BackEvent(
                                     ) or joystick.GoEvent():
                        done = True
            self.display.blit(display, (0, 0))
            pygame.draw.rect(self.display, (40, 40, 40), rect)
            pygame.draw.rect(self.display, (255, 255, 0), rect, 1)
            for index, line in enumerate(data.split("\n")):
                retro_text((121, 142 + index * 14),
                           self.display,
                           14,
                           line,
                           color=(0, 0, 0))
                retro_text((120, 140 + index * 14), self.display, 14, line)
            pygame.display.update()
        joystick.Reset()
예제 #7
0
def pause_menu(display, images, data, index, exit_lock=False):
    from interplanetary_invaders.scripts.menu import Menu
    from interplanetary_invaders.scripts.saves import save_data
    from interplanetary_invaders.scripts.retro_text import retro_text
    joystick.Reset()
    background = display.copy()
    done = False
    sel = 0
    items = ["Resume", "Options", "Exit to Main Menu", f"Exit to {platform}"]
    old_items = items[:]
    stuff_rect = pygame.Rect(0, 0, 300, 400)
    stuff_rect.center = display.get_rect().center
    toMainMenu = False
    confirm = False
    while not done:
        for event in pygame.event.get():
            joystick.Update(event)
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
            if event.type == pygame.KEYDOWN or joystick.WasEvent():
                if not hasattr(event, "key"):
                    event.key = None
                if event.key == pygame.K_ESCAPE or joystick.BackEvent():
                    done = True
                if event.key in (pygame.K_w,
                                 pygame.K_UP) or joystick.JustWentUp():
                    sel -= 1
                if event.key in (pygame.K_s,
                                 pygame.K_DOWN) or joystick.JustWentDown():
                    sel += 1
                if sel < 0:
                    sel = 0
                if sel >= len(items):
                    sel = len(items) - 1
                if event.key == pygame.K_RETURN or joystick.JustPressedA():
                    i = items[sel]
                    if confirm:
                        if i == "Save":
                            save_data(index, data)
                        if "Save" in i:
                            if not toMainMenu:
                                pygame.quit()
                                sys.exit()
                            done = True
                            return toMainMenu
                        if i == "Cancel":
                            confirm = False
                            toMainMenu = False
                            items = old_items
                    if i == "Resume":
                        done = True
                    if i == "Options":
                        m = Menu(display, images, True)
                        m.main()
                    if i == f"Exit to {platform}" and not exit_lock:
                        items = ["Cancel", "Save", "Don't Save"]
                        sel = 0
                        confirm = True
                    if i == "Exit to Main Menu" and not exit_lock:
                        toMainMenu = True
                        items = ["Cancel", "Save", "Don't Save"]
                        sel = 0
                        confirm = True
        display.blit(background, (0, 0))
        pygame.draw.rect(display, (0, 0, 0), stuff_rect)
        pygame.draw.rect(display, (255, 255, 0), stuff_rect, 1)
        for e, i in enumerate(items):
            color = (255, 255, 255)
            if e == sel:
                color = (255, 255, 175)
                display.blit(
                    images["bullet"],
                    (stuff_rect.left + 5, stuff_rect.top + 50 + e * 30))
            retro_text((stuff_rect.left + 10, stuff_rect.top + 50 + e * 30),
                       display,
                       15,
                       " " + i,
                       color=color)
        pygame.display.update()
    return toMainMenu