Exemple #1
0
    def __init__(self, position):

        self.pos = position
        self.generate_control_enables()

        self.dash_mode = 0
        self.jump_mode = 0
        self.push_mode = 0

        idle_sprite = SpriteSheet(fp("keith.png"), (8, 1), 8)
        idle_sprite_left = SpriteSheet(fp("keith.png"), (8, 1), 8)
        idle_sprite_left.reverse(1, 0)
        self.sprite = Sprite(12)
        self.sprite.scale = TILE_WIDTH * 1.0 / 48
        self.sprite.add_animation({
            "right_idle": idle_sprite,
            "left_idle": idle_sprite_left
        })
        self.sprite.start_animation("right_idle")

        self.sprite.x_pos = position[0] * TILE_WIDTH
        self.sprite.y_pos = position[1] * TILE_WIDTH - TILE_WIDTH

        self.hop_amp = TILE_WIDTH * 1.0 * .4
        self.hop_height = 0
        self.hop_enable = 0
        self.hop_time = 0
        self.hop_duration = 0.15

        self.r = 1
Exemple #2
0
    def __init__(self, key):

        self.key = key

        path_dict = {
            UP: "up.png",
            DOWN: "down.png",
            LEFT: "left.png",
            RIGHT: "right.png",
            JUMP: "c.png",
            DASH: "z.png",
            PUSH: "x.png"
        }
        self.surf = pygame.image.load(fp(path_dict[key]))
        surf_aspect = self.surf.get_height() * 1.0 / self.surf.get_width()
        self.surf = pygame.transform.scale(self.surf,
                                           (HUD_KEY_WIDTH, HUD_KEY_HEIGHT))

        self.y = HUD_KEY_Y
        if key == UP:
            self.y -= UP_OFFSET
        self.start_y = self.y
        self.x = -100

        self.target_x, self.target_y = self.x, self.y

        self.enabled = True
        self.hover = False

        self.width = HUD_KEY_WIDTH
        self.height = HUD_KEY_HEIGHT
        self.scale = 1.0
        self.target_scale = 1.0
Exemple #3
0
    def __init__(self):
        pygame.init()
        pygame.font.init()
        self.screen_commit = pygame.display.set_mode(WINDOW_SIZE)
        pygame.display.set_caption("Master Key - LD43")
        self.screen = pygame.Surface(MAX_FRAME_SIZE)

        pygame.mixer.pre_init(44100, -16, 1, 512)
        self.mus = pygame.mixer.Sound(fp("LD43.wav"))
        self.mus.play(-1)

        self.box_slide = pygame.mixer.Sound(fp("box_slide.wav"))
        self.box_slide.set_volume(0.12)
        self.box_fall = pygame.mixer.Sound(fp("box_fall.wav"))
        self.box_fall.set_volume(0.35)
        self.prompt_continue = pygame.mixer.Sound(fp("prompt_continue.wav"))
        self.prompt_continue.set_volume(0.3)
        self.collect_gem = pygame.mixer.Sound(fp("collect_gem.wav"))
        self.collect_gem.set_volume(0.5)
        self.altar_place = pygame.mixer.Sound(fp("altar_place.wav"))
        self.altar_place.set_volume(0.4)
        self.reset_noise = pygame.mixer.Sound(fp("reset.wav"))
        self.reset_noise.set_volume(0.15)
        self.dash_sound = pygame.mixer.Sound(fp("dash.wav"))
        self.dash_sound.set_volume(0.05)
        self.key_select = pygame.mixer.Sound(fp("key_select.wav"))
        self.key_select.set_volume(0.15)

        self.cam = Camera(self.screen_commit)
        self.cam.set_pan_pid(6, 2, -0.2)

        self.notice_frame = pygame.image.load(fp("notice.png"))

        self.levels = [
            Level("level_1.txt"),
            Level("level_2.txt"),
            Level("level_3.txt"),
            Level("level_3.5.txt"),
            Level("level_4.txt"),
            Level("level_5.txt"),
            Level("level_6.txt"),
            Level("level_7.txt")
        ]

        self.main()
Exemple #4
0
    def __init__(self, pos, shrine):

        self.shrine = shrine
        self.pos = pos

        self.width = TILE_WIDTH
        self.height = TILE_WIDTH

        self.active_sheet = SpriteSheet(fp("gate.png"), (2, 3), 6)
        self.inactive_sheet = SpriteSheet(fp("gate_inactive.png"), (2, 3), 6)
        self.sprite = Sprite(8)
        self.sprite.scale = TILE_WIDTH * 1.0 / 48
        self.sprite.add_animation({
            "active": self.active_sheet,
            "inactive": self.inactive_sheet
        })
        self.sprite.start_animation("active")

        self.active_trigger = 0
Exemple #5
0
    def __init__(self, pos):
        self.pos = pos

        self.pushable_sheet = SpriteSheet(fp("block.png"), (1, 1), (1))
        self.sink_sheet = SpriteSheet(fp("block_sink.png"), (4, 1), 4)
        self.sink_sheet.repeat = False
        self.sunk_sheet = SpriteSheet(fp("block_sunken.png"), (1, 1), 1)
        self.sprite = Sprite(12)
        self.sprite.add_animation({
            "idle": self.pushable_sheet,
            "sink": self.sink_sheet,
            "sunk": self.sunk_sheet
        })
        self.sprite.start_animation("idle")
        self.sprite.scale = TILE_WIDTH * 1.0 / 48

        self.fell = 0

        self.inset_offset = 0
Exemple #6
0
    def __init__(self, pos, num=0):
        self.pos = pos

        self.num = num

        self.width = TILE_WIDTH
        self.height = TILE_WIDTH

        self.captured_key = []

        self.inactive_sheet = SpriteSheet(fp("inactive_altar.png"), (1, 1), 1)
        self.active_sheet = SpriteSheet(fp("active_altar.png"), (8, 1), 8)
        self.sprite = Sprite(8)
        self.sprite.add_animation({
            "active": self.active_sheet,
            "inactive": self.inactive_sheet
        })
        self.sprite.start_animation("active")
        self.sprite.scale = TILE_WIDTH * 1.0 / 48

        self.mode = "active"
Exemple #7
0
    def __init__(self):

        reset_font = pygame.font.Font(fp("Myriad.otf"), 18)

        self.reset_font_render = reset_font.render(
            "Press R to reset level. Press H for a hint.", 1, (180, 180, 180))

        self.keys = [UP, DOWN, LEFT, RIGHT, JUMP, PUSH, DASH]
        self.hud_keys = []
        for item in self.keys:
            self.hud_keys.append(HudKey(item))
        self.full_list = self.hud_keys

        self.set_xs()
        self.set_ys()

        for item in self.hud_keys:
            item.x = item.target_x
            item.y = item.target_y

        self.hud_surfs = [item.surf for item in self.hud_keys]
        self.hud_surf_poses = [(item.x, item.y) for item in self.hud_keys]
Exemple #8
0
    def __init__(self):
        pygame.init()
        pygame.font.init()
        self.screen_commit = pygame.display.set_mode(WINDOW_SIZE)
        self.screen = pygame.Surface(MAX_FRAME_SIZE)

        self.cam = Camera(self.screen_commit)
        self.cam.set_pan_pid(6, 2, -0.2)

        self.notice_frame = pygame.image.load(fp("notice.png"))

        self.levels = [Level("level_1.txt"),
            Level("level_2.txt"),
            Level("level_3.txt"),
            Level("level_3.5.txt"),
            Level("level_4.txt"),
            Level("level_5.txt"),
            Level("level_6.txt"),
            Level("level_7.txt"),
            Level("level_8.txt")]

        self.main()
Exemple #9
0
    def tooltip(self, str):
        self.mus.set_volume(0.4)
        self.press_enable = False
        frame = self.notice_frame.copy().convert_alpha()
        cur_state = self.screen_commit.copy()

        myfont = pygame.font.Font(fp("Myriad.otf"), 30)
        tsplit = str.split("\n")
        l = len(tsplit)
        any_button = pygame.font.Font(fp("Myriad.otf"), 20)
        any_button_text = any_button.render("Press any button to continue.", 1,
                                            (0, 0, 0))

        tool_shadow_alpha = 0
        tool_shadow = pygame.Surface(WINDOW_SIZE)
        tool_shadow.fill((0, 0, 0))
        tool_shadow.set_alpha(tool_shadow_alpha)
        tool_shadow_rate = 300
        tool_shadow_max = 150
        tool_shadow_multiplier = 1.0

        for i2, i in enumerate(tsplit):
            a = myfont.render(i, 1, (0, 0, 0))
            frame.blit(a,
                       (frame.get_width() / 2 - a.get_width() / 2,
                        frame.get_height() / 2 - a.get_height() / 2 -
                        a.get_height() * 0.6 * l + a.get_height() * 1.2 * i2))
        frame.blit(
            any_button_text,
            (frame.get_width() / 2 - any_button_text.get_width() / 2, 240))

        then = time.time()
        pause_time = time.time()
        paused = True
        to_break = False

        while not to_break:
            now = time.time()
            dt = now - then
            then = now

            tsm = tool_shadow_multiplier

            events = pygame.event.get()
            for event in events:
                if event.type == pygame.QUIT:
                    pygame.quit()
                    sys.exit()
                elif event.type == pygame.KEYDOWN:
                    if time.time() - pause_time > 0.5:
                        if paused:
                            self.prompt_continue.play()
                            self.mus.set_volume(1.0)
                        paused = False

            tool_shadow_alpha = min(
                tool_shadow_max,
                int((time.time() - pause_time) * tool_shadow_rate))
            tool_shadow.set_alpha(tool_shadow_alpha * tool_shadow_multiplier)

            self.screen_commit.fill((0, 0, 0))
            self.screen_commit.blit(cur_state, (0, 0))
            self.screen_commit.blit(tool_shadow, (0, 0))
            x = WINDOW_WIDTH / 2 - self.notice_frame.get_width() / 2
            y = WINDOW_HEIGHT / 2 - self.notice_frame.get_height() / 2
            self.screen_commit.blit(
                frame,
                (x, int(y *
                        (3 * tsm - 2) - 200 * math.sin(2 * math.pi * tsm))))
            pygame.display.flip()

            if paused == False:
                tool_shadow_multiplier -= dt * 3
                if tool_shadow_multiplier < 0:
                    to_break = True

        pass