def confirm_delete(self):
     stuff_rect = pygame.Rect(0, 0, 300, 400)
     stuff_rect.center = self.display.get_rect().center
     options = ["No", "Yes"]
     sel = 0
     done = False
     while not done:
         for event in pygame.event.get():
             joystick.Update(event)
             if event.type == pygame.KEYDOWN or joystick.WasEvent():
                 if not hasattr(event, "key"):
                     event.key = None
                 if event.key in (pygame.K_UP, pygame.K_w) or joystick.JustWentUp():
                     sel = 0
                 if event.key in (pygame.K_DOWN, pygame.K_s, pygame.K_x) or joystick.JustWentDown():
                     sel = 1
                 if event.key == pygame.K_TAB:
                     sel = not sel
                 if event.key == pygame.K_RETURN or joystick.JustPressedA():
                     if sel:
                         os.remove(fix_path(get_file(f"data/profile{self.profile_selected}")))
                         self.profiles[self.profile_selected] = f"New Profile #{self.profile_selected + 1}"
                     self.pause_motion = True
                     done = True
         if not self.options_lock:
             self.draw_stars()
         self.draw_menu_box(stuff_rect)
         self.draw_items(options, sel, stuff_rect)
         retro_text(stuff_rect.move(0, 5).midtop, self.display, 14, "Are you sure you want", anchor="midtop")
         retro_text(stuff_rect.move(0, 20).midtop, self.display, 14, f"to erase Profile #{self.profile_selected + 1}?", anchor="midtop")
         pygame.display.update()
Exemplo n.º 2
0
 def draw_menu(self):
     self.display.fill(0)
     self.draw_stars()
     logo = pygame.transform.scale(self.images[f"logo{self.frame}"],
                                   LOGO_SIZE)
     lrect = logo.get_rect()
     lrect.midtop = (400, 0)
     self.display.blit(logo, lrect)
     stuff_rect = pygame.Rect((0, 0), (400, 550 - LOGO_SIZE[1]))
     stuff_rect.midtop = (400, LOGO_SIZE[1])
     if self.finished:
         self.draw_menu_box(stuff_rect)
         self.draw_items(self.items, self.item_selected, stuff_rect)
         retro_text(stuff_rect.move(0, 2).bottomright,
                    self.display,
                    14,
                    f"V{__version__}",
                    anchor="bottomright",
                    color=(10, 10, 10))
         retro_text(stuff_rect.bottomright,
                    self.display,
                    14,
                    f"V{__version__}",
                    anchor="bottomright",
                    color=(220, 220, 220))
Exemplo n.º 3
0
def build_bar(surf,
              pos,
              linepos,
              subticks=8,
              width=100,
              height=25,
              startmark="OFF",
              endmark="ON"):
    startmark += " "
    endmark = " " + endmark
    rect = pygame.Rect(pos, (width, height))
    pygame.draw.line(surf, (255, 255, 255), rect.midleft, rect.midright, 2)
    pygame.draw.line(surf, (255, 255, 255), rect.topleft, rect.bottomleft, 2)
    pygame.draw.line(surf, (255, 255, 255), rect.topright, rect.bottomright, 2)
    retro_text(rect.midleft, surf, 12, startmark, anchor="midright")
    retro_text(rect.midright, surf, 12, endmark, anchor="midleft")
    for z in range(1, subticks + 1):
        x = pos[0] + width * (z / (subticks + 1))
        top = pos[1] + height * 0.2
        bottom = pos[1] + height * 0.8
        pygame.draw.line(surf, (255, 255, 255), (x, top), (x, bottom))
    for z in range(9):
        x = pos[0] + width * linepos
        top = pos[1] + height * 0.2
        bottom = pos[1] + height * 0.8
        v1 = 255 - (abs(z - 4) / 4) * 255
        v2 = z - 4
        pygame.draw.line(surf, (v1, v1, v1), (x + v2, top), (x + v2, bottom))
    cx = pos[0] + width * linepos
    cy = rect.centery + 10
    pygame.draw.polygon(surf, (255, 255, 255), [(cx - 4, cy + 6), (cx, cy + 1),
                                                (cx + 4, cy + 6)])
 def draw_play(self):
     self.display.fill(0)
     self.draw_stars()
     stuff_rect = pygame.Rect((0, 0), (self.display.get_size()))
     stuff_rect.w *= .5
     stuff_rect.h *= .7
     stuff_rect.center = self.display.get_rect().center
     self.draw_menu_box(stuff_rect)
     self.draw_items(self.profiles, self.profile_selected, stuff_rect, x_off = 30)
     retro_text(stuff_rect.move(0, -50).midbottom, self.display, 15, "Press <x> to erase", anchor="center")
Exemplo n.º 5
0
    def drawOverlays(self):
        self.Display.blit(self.images["backarrow"], (0, 0))
        rect = pygame.Rect(0, 0, 32, 32)
        rect.midright = self.Display.get_rect().midright
        self.Display.blit(self.images["recenter"], rect)
        build_bar(self.Display, (400, 30), self.speed / 2, startmark = "0x", endmark = "2x")
        retro_text(self.Display.get_rect().topright, self.Display, 20, f"Cash: {humanize.intcomma(int(self.money))}", font = "impact", anchor = "topright")
        if self.overlay_pos != None and self.overlay_pos[2].draw:
            tpos = list(self.overlay_pos[1])
            tpos[1] -= 50
            retro_text(tpos, self.Display, 20, self.overlay_pos[2].name, font = "Sans")
        if not self.focused in ("theSun", None) and self.zoom >= 1.25:
            planet = self.planets[self.focused]
            if planet in self.unlocked_planets:
                rect2 = pygame.Rect((0, 0), (205, 50))
                rect2.midtop = planet.center[1][0], planet.center[1][1] + 35
                color = (100, 100, 100)
                if pygame.key.get_pressed()[pygame.K_RETURN] or rect2.collidepoint(pygame.mouse.get_pos()):
                    color = (70, 70, 70)
                pygame.draw.rect(self.Display, (0, 0, 0), rect2.move(3, 3))
                pygame.draw.rect(self.Display, color, rect2)
                color = (255, 255, 255)
                if self.text_yellow:
                     color = (255, 255, 0)
                retro_text(rect2.center, self.Display, 14, f"Go To {planet.name}", color=color, anchor="center")
            rect = pygame.Rect((0, 0), (250, 300))
            rect.midright = self.Display.get_rect().midright
            if self.zoom < 1.5:
                rect.x += rect.w * ((1.5 - self.zoom) / .25)
            pygame.draw.rect(self.Display, (25, 25, 25), rect)
            retro_text(rect.midtop, self.Display, 20, planet.name, font = "Sans", anchor = "midtop")
            pos = [rect.left + 10, rect.top + 25]
            height = 12
            pressure = planet.surface_pressure
            if pressure == None:
                pressure = "Unknown"
            ml = ""
            rot_per = planet.rotational_period
            if not rot_per:
                rot_per = "Synchronous"
            if planet.name in self.missions_left:
                ml = f"Missions: {self.missions_left[planet.name]}"
            text = f"""Gravity: {planet.gravity} G
Rotational Period: {rot_per} hours
Year Length: {planet.orbital_period} days
AvgDistFromSun: {planet.distance * 1000000} mi.
Rotation: {round(planet.rotation % 360, 2)}
Surface Pressure: {pressure} {'atm.' if pressure != 'Unknown' else ''}
{ml}
Targetable Moons: {planet.moons}"""
            if not planet in self.unlocked_planets:
                text = "LOCKED"
            for line in text.split("\n"):
                retro_text(pos, self.Display, height, line, font = "Sans", anchor = "topleft", res = 10, smooth = True)
                pos[1] += height
 def draw_items(self, items, selected, stuff_rect, x_off = 100):
     for n, x in enumerate(items):
         color = (255, 255, 255)
         bold = False
         size = 20
         if n == selected:
             self.display.blit(self.images["bullet"], (stuff_rect.left + x_off, stuff_rect.top + 50 + n * 40))
             color = (255, 255, 175)
             bold = True
             size = 18
         retro_text((stuff_rect.left + x_off, stuff_rect.top + 50 + n * 40), self.display, 18, " " + x, color=color, bold=bold)
Exemplo n.º 7
0
def update(surf):
    if save_for_later:
        retro_text((400, 200),
                   surf,
                   20,
                   "Saving your cached screenshots",
                   anchor="center")
        retro_text((400, 220),
                   surf,
                   15,
                   "To disable this feature go to the options menu",
                   anchor="center")
        pygame.display.update()
    for x in save_for_later:
        save(save_for_later[x], x)
    save_for_later.clear()
Exemplo n.º 8
0
 def write_stars(self):
     print("\n", colorize("Generating Star Data...", "bold"), "\n", sep="")
     background = self.display.copy()
     self.display.fill((0, 0, 0))
     retro_text(
         (self.display.get_width() // 2, self.display.get_height() // 2),
         self.display,
         30,
         "Please Wait...",
         anchor="center")
     fade_in(self.display, 3, background)
     for x in range(300):
         stars.main()
     with shelve.open(fix_path(get_file("data/menuStarsCache"))) as data:
         data["stars"] = stars.stars
         data["version"] = __version__
Exemplo n.º 9
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()
Exemplo n.º 11
0
def run_credits(display, images):
#    pygame.mixer.music.stop()
    pygame.mixer.music.load(get_file(fix_path("audio/music/Credits.ogg")))
    pygame.mixer.music.play(-1)
    clock = pygame.time.Clock()
    done = False
    text = []
    time_passed = 0
    for e, x in enumerate(credits_text.split("\n")):
        text.append(list(retro_text((400, 24 * e + 10), display, 14, x, font = "sans", anchor = "midtop", res = 11)))
    scroll = -600
    scroll_rate = 55
    total_length = 1400
    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:
                if event.key in (pygame.K_RETURN, pygame.K_ESCAPE):
                    done = True
            if joystick.BackEvent() or joystick.JustPressedA():
                done = True
        if scroll > total_length:
            done = True
        display.blit(images["background"], (0, 0))
        for line in text:
            if line[1][1] - scroll < 100:
                if line[0].get_width() <= 3:
                    text.remove(line)
                    continue
                s1 = line[0].get_width()
                if line[1][1] - scroll > 90:
                    s1 *= 1.025
                else:
                    s1 /= 1.03
                line[0] = pygame.transform.scale(line[0], (round(s1), line[0].get_height()))
                r2 = pygame.Rect((0, 0), line[0].get_size())
                r2.center = line[1].center
                line[1] = r2
            display.blit(line[0], (line[1][0], line[1][1] - scroll))
        img = images["nachomonkeylogo"]
        img_rect = img.get_rect()
        img_rect.centerx = display.get_width() // 2
        img_rect.top = total_length - img_rect.height - scroll - 10
        display.blit(img, img_rect)
        scroll += scroll_rate * time_passed
        pygame.display.update()
        time_passed = clock.tick(60) / 1000
    pygame.mixer.music.stop()
Exemplo n.º 12
0
def fetch_images(display):
    """Collect images from the IMAGE_PATH and return dictionary
with pygame.Surface objects as values and their names as keys"""
    names = []
    images = []
    num = 0
    print("Loading... \n")
    mx = 0
    display.fill((0, 0, 0))
    retro_text(display.get_rect().move(0, -30).center,
               display,
               18,
               "LOADING...",
               anchor="center")
    for x in range(10):
        g = 255 * x / 10
        retro_text(display.get_rect().move(0, 60 - x).midtop,
                   display,
                   22,
                   "INTERPLANETARY INVADERS",
                   anchor="center",
                   bold=True,
                   color=(g, g, g))
        retro_text(display.get_rect().move(0, 85 - x).midtop,
                   display,
                   18,
                   f"V{__version__}",
                   anchor="center",
                   bold=True,
                   color=(g, g, g))
    if joystick.hasJoystick:
        retro_text(display.get_rect().move(0, 200).center,
                   display,
                   18,
                   "Detected Joystick:",
                   anchor="center",
                   bold=True)
        retro_text(display.get_rect().move(0, 225).center,
                   display,
                   20,
                   '"' + joystick.name + '"',
                   anchor="center")
        if not joystick.IsSupported():
            retro_text(display.get_rect().move(0, 240).center,
                       display,
                       20,
                       "Unsupported Joystick",
                       anchor="center",
                       bold=True,
                       color=(255, 0, 0))
    borderRect = pygame.Rect(0, 0, BAR_WIDTH + 10, BAR_HEIGHT + 5)
    borderRect.center = display.get_rect().center
    barRect = borderRect.copy()
    barRect.h = BAR_HEIGHT
    barRect.center = borderRect.center
    LastRefresh = 0
    pygame.display.update()
    for data in os.walk(IMAGE_PATH):
        for collect_file in data[2]:
            if not collect_file.startswith("."):
                mx += 1
    for data in os.walk(IMAGE_PATH):
        root = data[0]
        files = data[2]
        for collect_file in files:
            if not collect_file.startswith("."):
                num += 1
                name = remove_extension(collect_file)
                img = pygame.image.load(root + os.sep + collect_file)
                if (name.startswith("spinning") and not "RGBA" in name):
                    img = img.convert()
                    img.set_colorkey((0, 0, 0))
                else:
                    if not "animation" in root:
                        if name.startswith("map_"):
                            img = img.convert()
                        else:
                            img = img.convert_alpha()
                    if name.startswith("ROT_"):
                        name = name[4:]
                        x = 0
                        for r in range(-90, 91):
                            x += 1
                            names.append(name + str(int(r % 360)))
                            images.append(pygame.transform.rotate(img, r))
                names.append(name)
                images.append(img)
                print(
                    f"\rLoaded {colorize(num, 'blue' if num!=mx else 'green')} / {colorize(mx, 'green')} images   %s"
                    % colorize(collect_file +
                               (" " * (40 - len(collect_file))), 'bold'),
                    flush=True,
                    end="")
            if time.time() - LastRefresh >= .1:
                LastRefresh = time.time()
                barRect.w = int((BAR_WIDTH * (num / mx)) * 10) / 10
                g = 255 * (num / mx)
                b = 255 - g
                pygame.draw.rect(display, (0, g, b), barRect)
                for x in range(0, BAR_WIDTH, BAR_WIDTH // 10):
                    X_Val = barRect.x + x
                    pygame.draw.line(display, (0, 0, 0), (X_Val, borderRect.y),
                                     (X_Val, borderRect.y + borderRect.h), 2)
                pygame.draw.rect(display, (25, 25, 25), borderRect, 1)
                text, text_rect = retro_text(display.get_rect().move(
                    0, 30).center,
                                             display,
                                             18,
                                             f"{round(num/mx*100)}%",
                                             anchor="center",
                                             eraseColor=(0, 0, 0))
                pygame.display.update([barRect, text_rect])
    print()
    return dict(zip(names, images)), num
Exemplo n.º 13
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
Exemplo n.º 14
0
 def draw(self):
     if f"map_{self.planet.name}" in self.images:
         self.display.blit(self.images[f"map_{self.planet.name}"], (0, 0))
     else:
         self.display.fill(self.planet.color)
     self.display.blit(self.images["backarrow"], (0, 0))
     dark = False
     d1 = self.images["empty"].copy()
     d2 = self.images["empty"].copy()
     pygame.draw.rect(self.display, (25, 25, 25), self.base_rect)
     retro_text(self.base_rect.center, self.display, 15, f'Loot: {self.profile["money"]}', anchor="center")
     for n, point in enumerate(self.map):
         circle = self.images["nothing16"]
         circle_rect = circle.get_rect()
         circle_rect.center = point.pos
         circle_rect2 = pygame.Rect(0, 0, 64, 80)
         circle_rect2.midbottom = circle_rect.midbottom
         hover = circle_rect2.collidepoint(pygame.mouse.get_pos())
         color = (255, 0, 0)
         if hover:
             color = (255, 150, 0)
         name = "alien"
         if not point.alien_flag:
             color = (0, 125, 255)
             if hover:
                 color = (255, 255, 255)
             name = "tank"
         if point.type == "spaceport":
             color = (125, 125, 125)
             if hover:
                 color = (125, 255, 255)
             name = "spaceport"
         if point.type == "info":
             color = (0, 0, 255)
             if hover:
                 color = (0, 255, 255)
             name = "info"
         if point.type == "store":
             color = (255, 200, 0)
             if hover:
                 color = (255, 255, 0)
             name = "store"
         try:
             if point.bonus and point.alien_flag:
                 name = "bonus"
         except AttributeError:
             pass
         pygame.draw.ellipse(circle, color, pygame.Rect(circle.get_rect().topleft, (point.rect.w // 4, point.rect.h // 4 * .8)), 2)
         if n > 0:
             if self.map[n - 1].alien_flag:
                 dark = True
             color = (255, 255, 0)
             if dark:
                 color = (150, 150, 20)
             pygame.draw.line(d1, color, point.pos, self.map[n - 1].pos, 2)
         d2.blit(circle, circle_rect)
         d2.blit(self.images[f"{name}_flag{point.frame}"], point.rect)
         if hover and self.click:
             R = []
             if n < self.selected_point:
                 R = reversed(range(self.selected_point))
             if n > self.selected_point:
                 R = range(self.selected_point, len(self.map))
             x = 0
             self.waypoints = []
             for x in R:
                 self.waypoints.append(x)
                 if self.map[x].alien_flag or x == n:
                     break
             self.selected_point = x
             if self.waypoints:
                 self.target_pos = self.get_point(self.waypoints[0])
                 self.changed = True
             self.click = False
     self.display.blit(d1, (0, 0))
     self.display.blit(d2, (0, 0))
     name = ''
     frame = self.avatar_idle_frame
     if self.avatar_pos != self.target_pos:
         name = "_moving"
         frame = self.avatar_frame
     flip = False
     if self.velocity[0] > 0:
         flip = True
     sel = self.selected_point
     self.display.blit(pygame.transform.flip(pygame.transform.scale(self.images[f"tank{name}{frame}"], (32, 32)), flip, False), Vector2(self.avatar_pos) - Vector2(0, 20))
     if self.avatar_pos == self.target_pos and self.old_selected_point == self.selected_point:
             add = ""
             try:
                 if self.map[sel].bonus:
                     add = "Bonus Mission: "
             except AttributeError:
                 pass
             t, tr = retro_text((self.map[sel].pos), self.display, 15, add + self.map[sel].name, anchor="midtop", render=False, color=(230, 230, 230))
             tr = tr.clamp(self.display.get_rect())
             retro_text(tr.move(0, 2).center, self.display, 15, add + self.map[sel].name, anchor="center", color=(0, 0, 0))
             self.display.blit(t, tr)
             if self.map[sel].type in ("spaceport", "mission", "store"):
                 text = "Complete Mission"
                 if self.map[sel].type == "spaceport":
                     text = "Go To Space"
                 if self.map[sel].type == "store":
                     text = "Go To Store"
                 rect = pygame.Rect((0, 0), (235, 50))
                 rect.midtop = self.map[sel].pos[0], self.map[sel].pos[1] + 35
                 rect = rect.clamp(self.display.get_rect())
                 color = (100, 100, 100)
                 if pygame.key.get_pressed()[pygame.K_RETURN] or rect.collidepoint(pygame.mouse.get_pos()):
                     color = (70, 70, 70)
                 pygame.draw.rect(self.display, (0, 0, 0), rect.move(3, 3))
                 pygame.draw.rect(self.display, color, rect)
                 color = (255, 255, 255)
                 if self.text_yellow:
                     color = (255, 255, 0)
                 retro_text(rect.center, self.display, 14, text, color=color, anchor="center")
def fetch_images(display):
    """Collect images from the IMAGE_PATH and return dictionary
with pygame.Surface objects as values and their names as keys"""
    names = []
    images = []
    num = 0
    mx = 0
    display.fill((0, 0, 0))
    retro_text(display.get_rect().move(0, -30).center,
               display,
               18,
               "LOADING...",
               anchor="center")
    for x in range(10):
        g = 255 * x / 10
        retro_text(display.get_rect().move(0, 60 - x).midtop,
                   display,
                   22,
                   "INTERPLANETARY INVADERS",
                   anchor="center",
                   bold=True,
                   color=(0, g, 0))
        retro_text(display.get_rect().move(0, 85 - x).midtop,
                   display,
                   18,
                   f"V{__version__}",
                   anchor="center",
                   bold=True,
                   color=(0, g * .75, 0))
    if joystick.hasJoystick:
        retro_text(display.get_rect().move(0, 200).center,
                   display,
                   18,
                   "Detected Joystick:",
                   anchor="center",
                   bold=True)
        retro_text(display.get_rect().move(0, 225).center,
                   display,
                   20,
                   '"' + joystick.name + '"',
                   anchor="center")
        if not joystick.IsSupported():
            retro_text(display.get_rect().move(0, 240).center,
                       display,
                       20,
                       "Unsupported Joystick",
                       anchor="center",
                       bold=True,
                       color=(255, 0, 0))
    borderRect = pygame.Rect(0, 0, BAR_WIDTH + 10, BAR_HEIGHT + 5)
    borderRect.center = display.get_rect().center
    pygame.draw.rect(display, (100, 100, 100), borderRect, 1)
    barRect = borderRect.copy()
    barRect.h = BAR_HEIGHT
    barRect.center = borderRect.center
    barRect.x += 2
    LastRefresh = 0
    pygame.display.update()
    for data in os.walk(IMAGE_PATH):
        for collect_file in data[2]:
            if not collect_file.startswith("."):
                mx += 1
    for data in os.walk(IMAGE_PATH):
        root = data[0]
        files = data[2]
        for collect_file in files:
            if not collect_file.startswith("."):
                num += 1
                name = remove_extension(collect_file)
                img = pygame.image.load(root + os.sep + collect_file)
                store_img = True
                print(
                    f"\rLoading image {colorize(num, 'blue' if num!=mx else 'green')} of {colorize(mx, 'green')}  %s"
                    % colorize(collect_file +
                               (" " * (40 - len(collect_file))), 'bold'),
                    flush=True,
                    end="")
                if name.startswith("NoA_"):
                    name = name.split("NoA_")[1]
                    img = img.convert()
                elif (name.startswith("spinning") and not "RGBA" in name):
                    img = img.convert()
                    img.set_colorkey((0, 0, 0))
                else:
                    if not "animation" in root:
                        if name.startswith("map_"):
                            img = img.convert()
                        else:
                            img = img.convert_alpha()
                if name.startswith("ROT_"):
                    name = name[4:]
                    x = 0
                    for r in range(-90, 91):
                        x += 1
                        names.append(name + str(int(r % 360)))
                        images.append(pygame.transform.rotate(img, r))
                if name.endswith("_sheet"):
                    name = name.split("_sheet")[0]
                    for e, surf in enumerate(extract_sprites(img)):
                        names.append(name + str(e + 1))
                        images.append(surf)
                    store_img = False
                if store_img:
                    names.append(name)
                    images.append(img)
            if time.time() - LastRefresh >= .025:
                LastRefresh = time.time()
                barRect.w = int((BAR_WIDTH * (num / mx)) * 10) / 10
                color = pygame.color.Color(0)
                hue = lerp(HUE_BLUE, HUE_CYAN, num / mx)
                color.hsva = (hue, 100, 100, 100)
                pygame.draw.rect(display, color, barRect)
                for x in range(0, BAR_WIDTH, BAR_WIDTH // 10)[1:]:
                    X_Val = barRect.x + x
                    pygame.draw.line(display, (0, 0, 0), (X_Val, borderRect.y),
                                     (X_Val, borderRect.y + borderRect.h), 1)
                text, text_rect = retro_text(display.get_rect().move(
                    0, 30).center,
                                             display,
                                             18,
                                             f"{round(num/mx*100)}%",
                                             anchor="center",
                                             eraseColor=(0, 0, 0))
                pygame.display.update([barRect, text_rect])

                # This makes pygame rerender the screen when the window is brought up
                for event in pygame.event.get():
                    pass
    print()
    return dict(zip(names, images)), num
Exemplo n.º 16
0
    def draw(self):
        self.display.blit(self.images["background"], (0, 0))
        pygame.draw.rect(self.display, (100, 100, 100), self.main_rect)

        pygame.draw.rect(self.display, (0, 0, 0), self.data_rect.move(2, 2))
        pygame.draw.rect(self.display, (75, 75, 75), self.data_rect)
        pygame.draw.rect(self.display, (0, 0, 0), self.data_rect, 1)

        pygame.draw.rect(self.display, (0, 0, 0), self.list_rect.move(2, 2))
        pygame.draw.rect(self.display, (75, 75, 75), self.list_rect)
        pygame.draw.rect(self.display, (0, 0, 0), self.list_rect, 1)

        for rect in self.item_rects:
            pygame.draw.rect(self.display, (0, 0, 0), rect.move(2, 2))
            pygame.draw.rect(self.display, (40, 40, 40), rect)
            retro_text(rect.midtop,
                       self.display,
                       15,
                       "Available for purchase"
                       if rect == self.buy_rect else "Your Inventory",
                       anchor="midtop")

        pygame.draw.rect(self.display, (0, 0, 0), self.money_rect.move(2, 2))
        pygame.draw.rect(self.display, (75, 75, 75), self.money_rect)
        pygame.draw.rect(self.display, (0, 0, 0), self.money_rect, 1)
        retro_text(self.money_rect.center,
                   self.display,
                   15,
                   f"{self.profile['money']} Loot",
                   color=(255, 255, 175),
                   anchor="center")

        for e, rect in enumerate(self.rects):
            color = (125, 125, 125)
            tcolor = (200, 200, 200)
            if e == self.rect_sel:
                color = (75, 75, 75)
                tcolor = (255, 255, 175)
                pygame.draw.rect(self.display, (0, 0, 0), rect.move(2, 2))
            pygame.draw.rect(self.display, color, rect)
            pygame.draw.rect(self.display, (0, 0, 0), rect, 1)
            retro_text(rect.center,
                       self.display,
                       20,
                       self.rect_names[e],
                       color=tcolor,
                       anchor="center")

        cat = self.catagories[self.rect_sel]
        for y, row in enumerate(divide_list(cat, MAX_STORE_ITEM_LENGTH)):
            for x, obj in enumerate(row):
                rect = pygame.Rect(0, 0, 50, 50)
                rect.topleft = self.buy_rect.move(5 + x * 55,
                                                  15 + y * 55).topleft
                trect = pygame.Rect(0, 0, 15, 15)
                c1, c2 = (50, 50, 50), (0, 0, 0)
                if y * MAX_STORE_ITEM_LENGTH + x == self.sel_num[
                        self.rect_sel]:
                    c1, c2 = (50, 0, 0), (255, 0, 0)
                trect.bottomright = rect.bottomright
                pygame.draw.rect(self.display, c1, rect)
                self.display.blit(
                    pygame.transform.scale(self.images[obj.icon], (50, 50)),
                    rect)
                if not obj.type in ("License", "Vehicle"):
                    pygame.draw.rect(self.display, (150, 0, 0), trect)
                    pygame.draw.rect(self.display, (0, 0, 0), trect, 1)
                    retro_text(trect.center,
                               self.display,
                               15,
                               cat[obj],
                               anchor="center")
                pygame.draw.rect(self.display, c2, rect, 1)

        cat2 = self.profile["inventory"][self.rect_sel]
        for y, row in enumerate(divide_list(cat2, MAX_STORE_ITEM_LENGTH)):
            for x, obj in enumerate(row):
                rect = pygame.Rect(0, 0, 50, 50)
                rect.topleft = self.inv_rect.move(5 + x * 55,
                                                  15 + y * 55).topleft
                trect = pygame.Rect(0, 0, 15, 15)
                trect.bottomright = rect.bottomright
                pygame.draw.rect(self.display, (50, 50, 50), rect)
                self.display.blit(
                    pygame.transform.scale(self.images[obj.icon], (50, 50)),
                    rect)
                if not obj.type in ("License", "Vehicle"):
                    pygame.draw.rect(self.display, (150, 0, 0), trect)
                    pygame.draw.rect(self.display, (0, 0, 0), trect, 1)
                    retro_text(trect.center,
                               self.display,
                               15,
                               cat2[obj],
                               anchor="center")
                pygame.draw.rect(self.display, (0, 0, 0), rect, 1)
        if cat:
            selected = list(cat.keys())[self.sel_num[self.rect_sel]]
            pic_rect = pygame.Rect(0, 0, 100, 100)
            pic_rect.topleft = self.data_rect.move(5, 5).topleft
            pygame.draw.rect(self.display, (50, 50, 50), pic_rect)
            self.display.blit(
                pygame.transform.scale(self.images[selected.icon], (100, 100)),
                pic_rect)
            pygame.draw.rect(self.display, (0, 0, 0), pic_rect, 1)
            retro_text(pic_rect.move(225, 0).midtop,
                       self.display,
                       14,
                       selected.title,
                       anchor="midtop",
                       bold=True)
            retro_text(pic_rect.move(225, 20).midtop,
                       self.display,
                       15,
                       f"Cost: {humanize.intcomma(selected.cost)} Loot",
                       anchor="midtop",
                       bold=True)
            for e, l in enumerate(selected.description.split("\n")):
                retro_text(pic_rect.move(230, 35 + e * 12).midtop,
                           self.display,
                           12,
                           l,
                           anchor="midtop")
            retro_text(self.data_rect.midbottom,
                       self.display,
                       15,
                       "Press Y for info",
                       anchor="midbottom")

            color = (0, 175, 0)
            if self.purchase_rect.collidepoint(pygame.mouse.get_pos()):
                color = (0, 225, 0)
            if self.profile["money"] < selected.cost:
                color = (0, 10, 0)
            pygame.draw.rect(self.display, color, self.purchase_rect)
            pygame.draw.rect(self.display, (0, 0, 0), self.purchase_rect, 1)
            retro_text(self.purchase_rect.move(1, 1).center,
                       self.display,
                       19,
                       "Purchase",
                       bold=True,
                       anchor="center",
                       color=(0, 0, 0))
            retro_text(self.purchase_rect.center,
                       self.display,
                       19,
                       "Purchase",
                       bold=True,
                       anchor="center",
                       color=(100, 0, 255))
        color = (100, 0, 0)
        if self.exit_rect.collidepoint(pygame.mouse.get_pos()):
            color = (150, 0, 0)
        pygame.draw.rect(self.display, color, self.exit_rect)
        pygame.draw.rect(self.display, (0, 0, 0), self.exit_rect, 1)
        retro_text(self.exit_rect.move(1, 1).center,
                   self.display,
                   15,
                   "Press ESC to Exit",
                   anchor="center",
                   color=(0, 0, 0),
                   font="sans")
        retro_text(self.exit_rect.center,
                   self.display,
                   15,
                   "Press ESC to Exit",
                   anchor="center",
                   font="sans")
Exemplo n.º 17
0
 def retro_text(self, *args, **kwargs):
     args = list(args)
     pos = list(args.pop(0))
     pos[0] -= self.offset[0]
     pos[1] -= self.offset[1]
     retro_text(pos, *args, **kwargs)
 def draw(self):
     self.display.blit(self.images["background"], (0, 0))
     rect = pygame.Rect(0, 0, 400, 200)
     rect.center = self.display.get_rect().center
     self.display.blit(
         pygame.transform.scale(self.images[f"you_{self.mode}{self.frame}"],
                                (400, 200)), rect)
     rect.move_ip(50, 0)
     pos = rect.left - 20, rect.bottom
     colors = [(255, 255, 175), (255, 255, 255)]
     if not self.top_selected:
         pos = rect.left - 20, rect.bottom + 20
         colors.reverse()
     self.display.blit(self.images["bullet"], pos)
     retro_text(rect.bottomleft,
                self.display,
                14,
                self.text[0],
                anchor="topleft",
                color=colors[0])
     retro_text((rect.left, rect.bottom + 20),
                self.display,
                14,
                self.text[1],
                anchor="topleft",
                color=colors[1])
     if self.mode == "won":
         retro_text((400, 25), self.display, 14, "Loot:", anchor="center")
         retro_text((400, 50),
                    self.display,
                    14,
                    round(self.money_old),
                    anchor="center")
         retro_text((400, 75),
                    self.display,
                    14,
                    "Fast Victory Bonus",
                    anchor="center")
         retro_text((400, 100),
                    self.display,
                    14,
                    round(self.bonus),
                    anchor="center")
         retro_text((400, 125),
                    self.display,
                    14,
                    "Accuracy Bonus",
                    anchor="center")
         retro_text((400, 150),
                    self.display,
                    14,
                    round(self.bonus1 * self.acc_per),
                    anchor="center")
     retro_text((400, 165),
                self.display,
                14,
                "Press <Y> for more info",
                anchor="center")
Exemplo n.º 19
0
 def draw(self):
     self.display.blit(self.images["background"], (0, 0))
     pygame.draw.rect(self.display, (100, 100, 100), self.main_rect)
     cat = self.catagories[self.selected]
     sel = self.sel_num[self.selected]
     for e, rect in enumerate(self.rects):
         try:
             list(self.catagories[e])[self.sel_num[e]]
         except IndexError:
             self.sel_num[e] -= 1
         bcolor = (0, 0, 0)
         color = (50, 50, 50)
         thickness = 1
         if e == self.selected and not self.button_selected:
             bcolor = (255, 0, 0)
             color = (125, 125, 125)
             thickness = 2
         pygame.draw.rect(self.display, (0, 0, 0), rect.move(2, 2))
         pygame.draw.rect(self.display, color, rect)
         pygame.draw.rect(self.display, bcolor, rect, thickness)
         retro_text(rect.move(0, -18).midtop,
                    self.display,
                    15,
                    self.captions[e],
                    anchor="midbottom",
                    color=(0, 0, 0))
         retro_text(rect.move(0, -20).midtop,
                    self.display,
                    15,
                    self.captions[e],
                    anchor="midbottom")
         if self.catagories[e]:
             if self.captions[e] == "Items and Drones Brought":
                 title = copy(list(self.catagories[e])[self.sel_num[e]][1])
                 if title != None:
                     title = copy(title.title)
             else:
                 title = copy(
                     list(self.catagories[e])[self.sel_num[e]].title)
             plus = ""
             if title:
                 #                    title += " (press <Y> for info)"
                 retro_text(rect.move(0, -3).midtop,
                            self.display,
                            17,
                            title,
                            anchor="midbottom",
                            color=(0, 0, 0),
                            font="sans",
                            bold=True)
                 retro_text(rect.move(0, -5).midtop,
                            self.display,
                            17,
                            title,
                            anchor="midbottom",
                            color=(0, 200, 255),
                            font="sans",
                            bold=True)
         arrowrect = pygame.Rect(0, 0, 32, 32)
         arrowrect.midtop = self.inv_rect.move(0, 10).midbottom
         arrow = "down"
         if self.selected == 2:
             arrow = "up"
         self.display.blit(
             pygame.transform.scale(self.images[f"{arrow}arrow"], (32, 32)),
             arrowrect)
         for c in range(len(self.catagories)):
             for e, v in enumerate(self.catagories[c]):
                 msel = c == self.selected
                 if c == 2:
                     rect = v[0]
                     if v[1] == None:
                         v = None
                     else:
                         v = v[1]
                 else:
                     rect = pygame.Rect(0, 0, 50, 50)
                     rect.left = self.rects[c].left + 5 + e * 60
                     rect.centery = self.rects[c].centery
                 bcolor = (0, 0, 0)
                 color = (75, 75, 75)
                 thickness = 1
                 if msel and not self.button_selected:
                     color = (100, 100, 100)
                 if e == self.sel_num[c]:
                     bcolor = (255, 255, 0)
                     thickness = 2
                     if not msel or self.button_selected:
                         thickness = 1
                         bcolor = (0, 200, 0)
                 pygame.draw.rect(self.display, (0, 0, 0), rect.move(2, 2))
                 pygame.draw.rect(self.display, color, rect)
                 if v:
                     self.display.blit(
                         pygame.transform.scale(self.images[v.icon],
                                                (50, 50)), rect)
                     if c == 0:
                         if self.getIfLocked(v):
                             self.display.blit(self.images["nope"], rect)
                             if e == self.sel_num[c]:
                                 retro_text(
                                     (400, 50),
                                     self.display,
                                     15,
                                     "Higher Space Transport License level needed for this  vehicle",
                                     anchor="center",
                                     font="impact")
                                 retro_text(
                                     (400, 65),
                                     self.display,
                                     15,
                                     f"to be transported from {self.catagories[c][v]}",
                                     anchor="center",
                                     font="impact")
                 pygame.draw.rect(self.display, bcolor, rect, thickness)
                 if self.captions[c] == "Your Items and Drones":
                     trect = pygame.Rect(0, 0, 15, 15)
                     trect.bottomright = rect.bottomright
                     pygame.draw.rect(self.display, (150, 0, 0), trect)
                     retro_text(trect.center,
                                self.display,
                                15,
                                self.catagories[c][v],
                                anchor="center")
                     pygame.draw.rect(self.display, (0, 0, 0), trect, 1)
         color = (0, 100, 0)
         if self.button_selected or self.button_rect.collidepoint(
                 pygame.mouse.get_pos()):
             color = (0, 230, 0)
         if self.cannotContinue():
             color = (100, 0, 0)
             if self.button_selected or self.button_rect.collidepoint(
                     pygame.mouse.get_pos()):
                 color = (150, 0, 0)
         pygame.draw.rect(self.display, color, self.button_rect)
         retro_text(self.button_rect.move(0, 2).center,
                    self.display,
                    15,
                    "Continue Mission",
                    anchor="center",
                    color=(0, 0, 0))
         retro_text(self.button_rect.center,
                    self.display,
                    15,
                    "Continue Mission",
                    anchor="center")
Exemplo n.º 20
0
def congrats(display, images, mode, data, profile=None):
    """Display a screen for awarding achievements / unlocking planets"""
    done = False
    pf = 1
    pt = 0
    pfr = 1 / 25
    time_passed = 0
    total_time_passed = 0
    clock = pygame.time.Clock()
    if profile and mode == "ach":
        Sound(fix_path("audio/cashRegister.wav")).play()
        profile["money"] += data[2]
        profile["achievements"].append(data[0])
    while not done:
        for event in pygame.event.get():
            joystick.Update(event)
            if not hasattr(event, "key"):
                event.key = None
            if event.type == pygame.KEYDOWN or joystick.WasEvent():
                if event.key in (pygame.K_RETURN,
                                 pygame.K_ESCAPE) or joystick.GoEvent(
                                 ) or joystick.BackEvent():
                    done = True
                if event.key == pygame.K_F2 or joystick.JustPressedLB():
                    screenshot.capture("_congrats", display)
        display.blit(images["background"], (0, 0))
        if not mode == "store":
            retro_text((400, 100),
                       display,
                       24,
                       "Congratulations!",
                       font="impact",
                       anchor="center")
        stuff_rect = pygame.Rect(0, 0, 450, 350)
        if mode == "ach":
            stuff_rect.w *= 1.5
        stuff_rect.midtop = (400, 90)
        stuff_surf = pygame.Surface(stuff_rect.size)
        stuff_surf.fill((255, 0, 255))
        stuff_surf.set_alpha(50)
        display.blit(stuff_surf, stuff_rect)
        if mode == "planet" or mode == "store":
            rgba = ""
            if data.rgba:
                rgba = "RGBA"
            name = f"spinning{data.name}{rgba}{pf}"
            if not name in images:
                name = f"still_{data.name.lower()}"
            image = images[name]
            rect = pygame.Rect(0, 0, 100, 100)
            rect.center = (400, 200)
            display.blit(pygame.transform.scale(image, (100, 100)), rect)
            text = ""
            if not mode == "store":
                retro_text((400, 300),
                           display,
                           14,
                           f"You have unlocked Planet {data.name}",
                           anchor="center")
            else:
                retro_text((400, 300),
                           display,
                           14,
                           f"Restocked Store on {data.name}",
                           anchor="center")
            pt += time_passed
            if pt >= pfr:
                pf += 1
                pt = 0
            if pf > 25:
                pf = 1
        if mode == "ach":  # Short for achievement
            retro_text((400, 250),
                       display,
                       17,
                       f"{data[0]} Achievement Unlocked!",
                       anchor="center",
                       font="Sans")
            retro_text((400, 280),
                       display,
                       15,
                       data[1],
                       anchor="center",
                       bold=True,
                       font="Sans")
            retro_text((400, 300),
                       display,
                       15,
                       f"Money Earned: {data[2]}",
                       bold=True,
                       font="Sans",
                       anchor="center")
        if total_time_passed >= 15:
            done = True
        pygame.display.update()
        time_passed = clock.tick(60) / 1000
        total_time_passed += time_passed
Exemplo n.º 21
0
def confirmExit(display, profile, num):
    button_selected = 0
    buttons = ["Save + Exit", "Exit", "Cancel"]
    rect = pygame.Rect(0, 0, 150, 50)
    points = [(150, 400), (400, 400), (650, 400)]
    rect1, rect2, rect3 = rect.copy(), rect.copy(), rect.copy()
    rect1.midleft = points[0]
    rect2.center = points[1]
    rect3.midright = points[2]
    rects = [rect1, rect2, rect3]
    old_display = display.copy()
    surf2 = old_display.copy()
    surf2.fill((30, 30, 30))
    surf2.set_alpha(150)
    old_display.blit(surf2, (0, 0))
    while True:
        click = False
        for event in pygame.event.get():
            mpos = pygame.mouse.get_pos()
            joystick.Update(event)
            if not hasattr(event, 'key'):
                event.key = None
            if event.type == pygame.KEYDOWN or joystick.WasEvent():
                if event.key == pygame.K_F2 or joystick.JustPressedLB():
                    screenshot.capture(num, display)
            if event.type == pygame.MOUSEMOTION:
                for rect in rects:
                    if rect.collidepoint(mpos):
                        button_selected = rects.index(rect)
                        break
            if event.type == pygame.MOUSEBUTTONDOWN:
                for rect in rects:
                    if rect.collidepoint(mpos):
                        click = True
            if event.type == pygame.KEYUP or joystick.WasEvent():
                if event.key == pygame.K_ESCAPE or joystick.BackEvent():
                    return
                if event.key == pygame.K_LEFT or joystick.JustWentLeft():
                    button_selected -= 1
                if event.key == pygame.K_RIGHT or joystick.JustWentRight():
                    button_selected += 1
                if button_selected < 0:
                    button_selected = 0
                if button_selected > 2:
                    button_selected = 2
                if event.key == pygame.K_RETURN or joystick.JustPressedA():
                    click = True
        display.blit(old_display, (0, 0))
        retro_text((400, 302), display, 30, "Exit?", anchor="midbottom", bold=True, color=(0, 0, 0))
        retro_text((400, 300), display, 30, "Exit?", anchor="midbottom", bold=True)
        for n, rect in enumerate(rects):
            color = (75, 75, 75)
            tcolor = (255, 255, 255)
            if n == button_selected:
                color = (50, 50, 50)
                tcolor = (255, 255, 255)
            pygame.draw.rect(display, (0, 0, 0), rect.move(2, 2))
            pygame.draw.rect(display, color, rect)
            retro_text(rect.move(0, 2).center, display, 12, buttons[n], color = (0, 0, 0), anchor="center")
            retro_text(rect.center, display, 12, buttons[n], color = tcolor, anchor="center")
        pygame.display.update()
        clock.tick(10)
        if click:
            name = buttons[button_selected]
            if name == "Cancel":
                return
            if name == "Save + Exit":
                saves.save_data(num, profile)
                pygame.quit()
                sys.exit()
            if name == "Exit":
                transition(display, 5)
                pygame.quit()
                sys.exit()
Exemplo n.º 22
0
 def draw(self):
     self.display.blit(self.images["background"], (0, 0))
     rect = pygame.Rect(0, 0, 400, 200)
     rect.center = self.display.get_rect().center
     self.display.blit(
         pygame.transform.scale(self.images[f"you_{self.mode}{self.frame}"],
                                (400, 200)), rect)
     rect.move_ip(50, 0)
     for e, text in enumerate(self.text):
         color = (255, 255, 255)
         if e == self.selected_option:
             color = (255, 255, 175)
         retro_text(rect.move(0, 20 * e).bottomleft,
                    self.display,
                    14,
                    text,
                    anchor="topleft",
                    color=color)
     self.display.blit(
         self.images["bullet"],
         (rect.left - 20, rect.bottom + 20 * self.selected_option))
     if self.mode == "won":
         retro_text((400, 25), self.display, 14, "Loot:", anchor="center")
         retro_text((400, 50),
                    self.display,
                    14,
                    round(self.money_old),
                    anchor="center")
         retro_text((400, 75),
                    self.display,
                    14,
                    "Fast Victory Bonus",
                    anchor="center")
         retro_text((400, 100),
                    self.display,
                    14,
                    round(self.bonus),
                    anchor="center")
         retro_text((400, 125),
                    self.display,
                    14,
                    "Accuracy Bonus",
                    anchor="center")
         retro_text((400, 150),
                    self.display,
                    14,
                    round(self.bonus1 * self.acc_per),
                    anchor="center")
     retro_text((400, 165),
                self.display,
                14,
                "Press Y for more info",
                anchor="center")