Example #1
0
def load_stage_data():
    global entrance, exit

    load_count = 0
    map_x = 0
    map_y = 0
    while load_count < 16:
        if (map_x, map_y) in room_shape:
            file_fmt = 'stages/stage_type%d.txt'
            fn = file_fmt % room_shape[(map_x, map_y)]
            stage_gen.load(gobj.res(fn), map_x, map_y)
            stage_gen.update()
        else:
            file_fmt = 'stages/stage_type%d.txt'
            fn = file_fmt % random.randint(0, 3)
            stage_gen.load(gobj.res(fn), map_x, map_y)
            stage_gen.update()

        if (map_x, map_y) == entrance:
            fn = 'stages/entrance.txt'
            stage_gen.load_door(gobj.res(fn), map_x, map_y)
            stage_gen.update()
        elif (map_x, map_y) == exit:
            fn = 'stages/exit.txt'
            stage_gen.load_door(gobj.res(fn), map_x, map_y)
            stage_gen.update()

        map_x += 1
        map_x = map_x % 4
        load_count += 1
        map_y = load_count // 4
Example #2
0
def enter():
    gfw.world.init([
        'bg', 'enemy', 'throwing', 'platform', 'meso', 'item', 'player', 'ui'
    ])

    bg = Background('background/stage1_bg_far.png')
    bg.speed = 10
    gfw.world.add(gfw.layer.bg, bg)

    bg = Background('background/stage1_bg_near.png')
    bg.speed = 100
    bg.y_scale = 1.75
    gfw.world.add(gfw.layer.bg, bg)

    global player
    player = Player()
    gfw.world.add(gfw.layer.player, player)

    global font
    font = gfw.font.load(gobj.res('font/Maplestory Bold.ttf'), FONT_SIZE)

    global font_meso
    font_meso = gfw.font.load(gobj.res('font/morris9.ttf'), 20)

    stage_gen.load(gobj.res('stage_01.txt'))
Example #3
0
def enter():
    print('horz_state enter()')
    #global bg_music
    #bg_music = load_wav(gobj.res('sound/InGameMusic.wav'))
    #bg_music.set_volume(20)
    # bg_music.repeat_play()
    gfw.world.init(['bg', 'platform', 'enemy', 'item', 'player', 'ui'])

    center = get_canvas_width() // 2, get_canvas_height() // 2

    # GameController
    for n, speed in [(1, 10), (2, 100), (3, 150)]:
        bg = HorzScrollBackground('cookie_run_bg_%d.png' % n)
        bg.speed = speed
        gfw.world.add(gfw.layer.bg, bg)

    global player
    player = Player()
    player.bg = bg
    gfw.world.add(gfw.layer.player, player)

    score = 0
    heart = 10

    stage_gen.load(gobj.res('stage_01.txt'))
Example #4
0
def update():
    global player, stage_num, bgm
    x, y = player.pos

    gfw.world.update()

    if x > get_canvas_width():
        x = 14
        player.pos = x, y
        stage_num += 1
        stage_gen.remove()
        bgm = music.mp3(resSE('stage_%d.mp3' % stage_num), True)
        stage_gen.load(resBM('../stage_%d.txt' % stage_num), True)

        if stage_num == 3:
            bgm.set_volume(128)
        else:
            bgm.set_volume(64)

    if player.saved:
        save()
        player.saved = False

    if y < -10:
        bgm.stop()
        gfw.change(end)

    stage_gen.update()
Example #5
0
def load():
    global background, tile, player, stage_num, bgm

    temp_stage = stage_num

    try:
        with open(FILENAME, "rb") as file:
            stage_num = pickle.load(file)
            background.pos = pickle.load(file)
            tile.scroll_x = pickle.load(file)
            player.pos = pickle.load(file)
            player.state = pickle.load(file)
            player.action = pickle.load(file)
            player.width = pickle.load(file)
            player.imageType = pickle.load(file)

        player.delta = 0
        player.frame = 0
    except:
        print("No save file")

    if temp_stage != stage_num:
        stage_gen.remove()
        bgm = music.mp3(resSE('stage_%d.mp3' % stage_num), True)
        stage_gen.load(resBM('../stage_%d.txt' % stage_num))

    if stage_num == 3:
        bgm.set_volume(80)
Example #6
0
def enter():
    gfw.world.init(['bg', 'platform', 'spike', 'player', 'ui'])

    bg = HorzScrollBackground('game_background.png')
    bg.speed = 50
    gfw.world.add(gfw.layer.bg, bg)

    global bgm
    bgm = load_music('Assets/LetsMarch.ogg')
    bgm.set_volume(50)
    bgm.repeat_play()

    global player
    player = Player()
    gfw.world.add(gfw.layer.player, player)

    global font
    font = gfw.font.load('Assets/Maplestory Bold.ttf', 25)

    stage_gen.load(gobj.res('stage_01.txt'))

    prito.init()
    prito.reset()
    gfw.world.add(gfw.layer.ui, prito)
    global prito_cooldown
    prito_cooldown = random.uniform(10, 15)

    progress.init()
    gfw.world.add(gfw.layer.ui, progress)
Example #7
0
def enter():
    gfw.world.init([
        'background', 'bullet', 'save', 'platform', 'spike', 'player', 'clear'
    ])

    global background, clear, bgm, victory, player, victory_time, play_bgm, play_clear

    play_bgm = 0
    play_clear = 0
    victory_time = 0

    player = Player()
    player.pos = 335, get_canvas_height()
    player.state = 5
    player.action = 1
    gfw.world.add(gfw.layer.player, player)

    background = Background('ending.png', player)
    gfw.world.add(gfw.layer.background, background)

    clear = Background('game_clear.png', player)
    clear.ch = 200
    clear.draw_pos = 0, 200

    stage_gen.load(game_object.resBM('../ending.txt'), True)
Example #8
0
def enter():
    global sound, check_start, font, title_font, sound2, sound3

    gfw.world.init(['bg', 'tile', 'ui'])
    center = get_canvas_width() // 2, get_canvas_height() // 2
    gfw.world.add(gfw.layer.bg, gobj.ImageObject('메인배경.png', center))
    gfw.world.add(gfw.layer.ui, gobj.ImageObject('시작 제목.png', (200, 100)))
    stage_gen.load(gobj.res('tile.txt'))
    sound = load_music(gobj.res('반짝반짝작은별.mp3'))
    sound2 = load_music(gobj.res('반짝반짝작은별2.mp3'))
    sound3 = load_music(gobj.res('반짝반짝작은별3.mp3'))
    font = gfw.font.load(gobj.res('NanumGothic.TTF'), FONT_SIZE + 20)
    title_font = gfw.font.load(gobj.res('NanumGothic.TTF'), FONT_SIZE)
    highscore.load(FONT_SIZE)

    global END, check_start, play_speed, collision_count
    END = False
    check_start = False
    play_sound_time = 0
    collision_count = 0
    Tile.start = False
    Tile.SCORE = 0

    evts = get_events()
    for e in evts:
        handle_event(e)
Example #9
0
def enter(select=None):
    gfw.world.init(['bg', 'cloud', 'tile', 'spike', 'item', 'player', 'enemy'])

    global START_TIME, END_TIME
    START_TIME = get_time()
    END_TIME = START_TIME

    for n in range(1, 4):
        bg = Background('forest0%d.png' % n)
        gfw.world.add(gfw.layer.bg, bg)

    cloud = HorzScrollBackground('cloud.png', 20, 130)
    gfw.world.add(gfw.layer.cloud, cloud)

    global player, imageName
    if select == 1:
        imageName = 'soldier_animation_sheet.png'
    elif select == 2:
        imageName = 'princess_animation_sheet.png'
    player = Player(200, 200, imageName)
    gfw.world.add(gfw.layer.player, player)

    # tiles
    stage_gen.load(res('stage_01.txt'))

    # heart
    global heart
    heart = ImageObject('item/heart.png', (32, get_canvas_height() - 32), 64)

    color = [(255, 255, 255), (255, 0, 0), (0, 0, 0), (255, 255, 255)]
    init = [(140, -290, 100, "game over"), (140, -300, 110, "game over"),
            (50, -180, -75, "restart to enter"),
            (50, -185, -70, "restart to enter")]

    global MENU
    MENU = []
    for n, (size, pos_x, pos_y, sent) in zip(range(4), init):
        menu = Menu('ThaleahFat.ttf', size, color[n], sent, pos_x, pos_y)
        MENU.append(menu)

    global TIME_STR
    TIME_STR = [
        Menu('ThaleahFat.ttf', 50, (0, 0, 0), "", 425, -335),
        Menu('ThaleahFat.ttf', 50, (255, 255, 255), "", 420, -330)
    ]

    stage_gen.update(-250 * gfw.delta_time)

    global game_clear
    game_clear = False
Example #10
0
def enter():
    gfw.world.init(['bg', 'cloud', 'tile', 'item', 'player', 'enemy', 'ui'])

    for n in range(1, 4):
        bg = Background('forest0%d.png' % n)
        gfw.world.add(gfw.layer.bg, bg)

    cloud = HorzScrollBackground('cloud.png', 20, 130)
    gfw.world.add(gfw.layer.cloud, cloud)

    global player
    player = Player()
    gfw.world.add(gfw.layer.player, player)

    stage_gen.load(res('stage_01.txt'))
Example #11
0
def enter():
    gfw.world.init(['bg', 'platform', 'enemy', 'item', 'player'])

    center = get_canvas_width() // 2, get_canvas_height() // 2

    for n, speed in [(1, 10), (2, 100), (3, 150)]:
        bg = HorzScrollBackground('cookie_run_bg_%d.png' % n)
        bg.speed = speed
        gfw.world.add(gfw.layer.bg, bg)

    global player
    player = Player()
    player.bg = bg
    gfw.world.add(gfw.layer.player, player)

    stage_gen.load(gobj.res('stage_01.txt'))
Example #12
0
def build_world():
    gfw.world.init([
        'bg', 'platform', 'enemy', 'boss', 'item', 'player', 'life', 'score',
        'ui', 'menu'
    ])
    Player.load_all_images()
    Jelly.load_all_images()

    center = get_canvas_width() // 2, get_canvas_height() // 2

    for n, speed in [(1, 10), (2, 100), (3, 150)]:
        bg = HorzScrollBackground('map_bg/bg_%d.png' % n, 'sound/main.mp3')
        bg.speed = speed
        gfw.world.add(gfw.layer.bg, bg)

    global font
    font = load_font(gobj.RES_DIR + 'font/CookieRun Regular.ttf', 30)

    global life
    life = Life()
    gfw.world.add(gfw.layer.life, life)

    global score
    score = Score(canvas_width / 2 - 30, canvas_height - 65, (0, 0, 0), 30)
    gfw.world.add(gfw.layer.score, score)

    stage_gen.load(gobj.res('stage_boss.txt'))

    global obs_sound, crash_sound
    obs_sound = load_wav(gobj.RES_DIR + 'sound/obs.wav')
    obs_sound.set_volume(50)
    crash_sound = load_wav(gobj.RES_DIR + 'sound/crash.wav')
    crash_sound.set_volume(30)

    global player
    player = Player(name)
    gfw.world.add(gfw.layer.player, player)

    l, b, w, h = get_canvas_width() - 100, get_canvas_height() - 100, 50, 50
    btn = Button("pause_", l, b, w, h, font, "", lambda: pause_set())
    gfw.world.add(gfw.layer.ui, btn)

    global paused, open
    paused = False
    open = False
Example #13
0
def enter():
    gfw.world.init([
        'background', 'tile', 'bullet', 'save', 'platform', 'spike', 'player'
    ])

    global background, tile, player, stage_num, bgm
    stage_num = 1
    bgm = music.mp3(resSE('stage_%d.mp3' % stage_num), True)

    player = Player()
    gfw.world.add(gfw.layer.player, player)

    background = Background('background.png', player)
    gfw.world.add(gfw.layer.background, background)

    tile = Tile('res/tile_background.json', 'res/bitmap/tileset.png', player)
    gfw.world.add(gfw.layer.tile, tile)

    stage_gen.load(resBM('../stage_%d.txt' % stage_num), False)
    save()
Example #14
0
def enter():
    gfw.world.init(['bg', 'platform', 'enemy', 'boss', 'item', 'player'])
    Player.load_all_images()
    Jelly.load_all_images()

    center = get_canvas_width() // 2, get_canvas_height() // 2

    for n, speed in [(1, 10), (2, 100), (3, 150)]:
        bg = HorzScrollBackground('map_bg/bg_%d.png' % n)
        bg.speed = speed
        gfw.world.add(gfw.layer.bg, bg)

    global player
    player = Player()
    #    player.bg = bg
    gfw.world.add(gfw.layer.player, player)

    global font
    font = load_font(gobj.RES_DIR + 'font/CookieRun Regular.ttf', 40)

    stage_gen.load(gobj.res('stage_boss.txt'))
Example #15
0
def enter(select):
    gfw.world.init(['bg', 'platform', 'enemy', 'item', 'player', 'ui'])
    global bgm, effect_j, effect_s, effect_jelly, effect_hp, effect_obs
    bgm = load_music('./res/Cookie Run Ovenbreak - Theme Song Breakout 1.mp3')
    if select == -1:
        effect_j = load_wav('res/ch02jump.wav')
        effect_s = load_wav('res/ch01slide.wav')
    elif select == 0:
        effect_j = load_wav('res/ch02jump.wav')
        effect_s = load_wav('res/ch02slide.wav')
    elif select == 5:
        effect_j = load_wav('res/ch07jump.wav')
        effect_s = load_wav('res/ch07slide.wav ')
    elif select == 14:
        effect_j = load_wav('res/ch02jump.wav')
        effect_s = load_wav('res/ch01slide.wav')
    elif select == 3:
        effect_j = load_wav('res/ch05jump.wav')
        effect_s = load_wav('res/ch05slide.wav')
    effect_jelly = load_wav('res/g_jelly.wav')
    effect_hp = load_wav('res/i_small_energy.wav')
    effect_obs = load_wav('res/g_obs1.wav')

    effect_s.get_volume()
    effect_j.get_volume()
    effect_jelly.get_volume()
    effect_hp.get_volume()
    effect_obs.get_volume()
    bgm.get_volume()

    bgm.repeat_play()

    center = get_canvas_width() // 2, get_canvas_height() // 2

    for n, speed in [(1, 10), (2, 100)]:
        bg = HorzScrollBackground('Episode01_bg_0%d.png' % n)
        bg.speed = speed
        gfw.world.add(gfw.layer.bg, bg)

    global player
    player = Player(select)
    player.bg = bg
    gfw.world.add(gfw.layer.player, player)

    global ui
    ui = HPui.Hpui(0.05)
    if player.select == 3:
        ui.set_dwidth(1, 0.05)
    gfw.world.add(gfw.layer.ui, ui)

    stage_gen.load(gobj.res('stage_01.txt'))
    global font, score, targetscore
    font = gfw.font.load('res/CookieRun Regular.ttf', 35)
    score = 0
    targetscore = 0

    global runfast, fast_time
    runfast = False
    fast_time = None

    global die_time