Exemple #1
0
def handle_event(e):
    if e.type == SDL_QUIT:
        gfw.quit()
    elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE):
        gfw.quit()
    elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_SPACE):
        gfw.change(select_state)
Exemple #2
0
def update():
    global loading_time
    global first_index, second_index, third_index, fourth_index
    global time

    loading_time -= gfw.delta_time

    if loading_time < 4:
        if first_index < 7:
            time += 1
            if time % 5 == 1:
                first_index += 1

    if loading_time < 3:
        if second_index < 3:
            time += 1
            if time % 5 == 1:
                second_index += 1

    if loading_time < 2:
        if third_index < 3:
            time += 1
            if time % 5 == 1:
                third_index += 1

    if loading_time < 1:
        if fourth_index < 3:
            time += 1
            if time % 5 == 1:
                fourth_index += 1

    if loading_time <= 0:
        gfw.change(stage)
def handle_event(e):
    global target_pos ,ButtonSound ,CheckGame
    if e.type == SDL_QUIT:
        gfw.quit()
    elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE):
        gfw.quit()
    if e.type == SDL_MOUSEMOTION:
        target_pos = (e.x ,get_canvas_height() - e.y - 1)
        x, y = target_pos
        if x > 500 and x < 720 and y >390 and y < 410:
            ButtonSound.play()
        elif x > 500 and x < 720 and y >320 and y < 340:
            ButtonSound.play()
        elif x > 500 and x < 720 and y >250 and y < 270:
            ButtonSound.play()
    if e.type == SDL_MOUSEBUTTONDOWN:
        x, y = target_pos
        if x > 500 and x < 720 and y >390 and y < 410:
            CheckGame = True
            gfw.change(game_state)
        elif x > 500 and x < 720 and y >320 and y < 340:
            CheckGame = False
            gfw.change(ranking_state)
        elif x > 500 and x < 720 and y >250 and y < 270:
            gfw.quit()
Exemple #4
0
def update():
    global logo_time, bgm

    logo_time += gfw.delta_time

    if logo_time > 3.0:
        gfw.change(title)
Exemple #5
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()
Exemple #6
0
def handle_event(e):
    # prev_dx = boy.dx
    if e.type == SDL_QUIT:
        gfw.quit()
        return
    elif e.type == SDL_KEYDOWN:
        if e.key == SDLK_ESCAPE:
            Scene_Result.set_score(score)
            gfw.change(Scene_Result, player.select)
            return
        elif e.key == SDLK_RETURN:
            effect_s.play(1)
        elif e.key == SDLK_SPACE:
            effect_j.play(1)
        elif e.key == SDLK_a:
            # player.pos = 150,650
            # for x, y in [(100,400),(400,300),(650,250),(900,200)]:
            for i in range(10):
                x = random.randint(100, 900)
                y = random.randint(200, 400)
                pf = Platform(Platform.T_3x1, x, y)
                gfw.world.add(gfw.layer.platform, pf)
        elif e.key == SDLK_p:
            global paused
            paused = not paused

    if player.handle_event(e):
        return
Exemple #7
0
def is_win() -> bool:
    for platform in gfw.world.objects_at(gfw.layer.platform):
        if platform.type != Platformer.GOAL:
            continue
        if gobj.collides_box(player, platform):
            gfw.change(score_state)
            score_state.set_attempt(player.n_die)
Exemple #8
0
    def update(self):
        x, y = self.x, self.y
        dx, dy = self.delta

        if self.dir == 'w':
            x -= dx * gfw.delta_time
        elif self.dir == 'h':
            x += dx * gfw.delta_time
        y += dy * gfw.delta_time
        gravity = 3
        dy -= gravity
        print(y)
        self.x = x
        self.y = y
        self.delta = dx, dy

        if x < -10 or x > get_canvas_width() + 10 or y <= 90:
            gfw.world.remove(self)
            print('bullet count - %d' % len(ZombieBullet.bullets))

        if player.isCreate == True:
            if gobj.collides_box(self, self.player):
                gfw.world.remove(self)
                gfw.world.remove(self.player)
                player.isCreate = False
                gfw.change(menu_state)
Exemple #9
0
def handle_event(e):
    if e.type == SDL_QUIT:
        gfw.quit()
        return
    elif e.type == SDL_KEYDOWN:
        if e.key == SDLK_ESCAPE:
            gfw.pop()
            return
        elif e.key == SDLK_p:
            global paused
            paused = not paused
        elif e.key == SDLK_RETURN:
            if not paused:
                return
            global prito_cooldown
            prito_cooldown = random.uniform(5, 10)
            paused = False
            bgm.repeat_play()
        elif e.key == SDLK_s:
            gfw.change(score_state)
            score_state.set_attempt(player.n_die)
        elif e.key == SDLK_d:
            global disabled
            disabled = not disabled

    player.handle_event(e)
    if not prito.handle_event(e):
        player.die()
Exemple #10
0
def update():
    global start_time, loading_x, previous_time, speed
    current = get_time()
    loading_x += speed * (current - previous_time)
    if current - previous_time >= 2.7:
        gfw.change(Scene_Menu, None)
    pass
Exemple #11
0
 def handle_event(self, e):
     global answer, ask, p_key, me_shout_time, me_shout_randidx, frame, answer_time
     if e.type == SDL_KEYDOWN:
         if e.key == SDLK_q and frame != 1600:  #프레임이 1600일때는 키보드 입력 안됨
             p_key = 1
             me_shout_randidx = random.randint(0, 2)
             self.Correct_Check()
             me_shout_time = get_time()
         elif e.key == SDLK_w and frame != 1600:  #프레임이 1600일때는 키보드 입력 안됨
             p_key = 2
             me_shout_randidx = random.randint(0, 2)
             self.Correct_Check()
             me_shout_time = get_time()
         elif e.key == SDLK_e and frame != 1600:  #프레임이 1600일때는 키보드 입력 안됨
             p_key = 3
             me_shout_randidx = random.randint(0, 2)
             self.Correct_Check()
             me_shout_time = get_time()
         elif e.key == SDLK_r and frame != 1600:  #프레임이 1600일때는 키보드 입력 안됨
             p_key = 4
             me_shout_randidx = random.randint(0, 2)
             self.Correct_Check()
             me_shout_time = get_time()
         elif e.key == SDLK_RETURN:
             self.health -= 10
             gfw.push(game_state, 2, self.health)
             if ask == True:
                 answer = True
             if ask_ == True:
                 answer_time = get_time()
         elif e.key == SDLK_SPACE:
             gfw.change(game_state, 2, self.health)
Exemple #12
0
def handle_event(e):
    if e.type == SDL_QUIT:
        gfw.quit()
    elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE):
        gfw.change(title_state)
    elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_p):
        gfw.pop()
def end_game():
    global state, Sound, score
    state = STATE_GAME_OVER
    Sound.bgm1.stop()
    Sound.bgm2.repeat_play()
    Highscore.add(score)
    gfw.world.clear()
    gfw.change(game_over_state)
Exemple #14
0
def update():
    gfw.world.update()
    global loading_on
    if loading_on:
        gfw.change(loading_state)
        loading_on = False
        gobj.effect1_on = False
        gobj.effect2_on = False
def handle_event(e):
    global image, state
    if e.type == SDL_QUIT:
        gfw.quit()
    elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE):
        gfw.quit()
    if e.type == SDL_MOUSEBUTTONDOWN:
        gfw.change(logo_state)
Exemple #16
0
def handle_event(e):
    global player
    if e.type == SDL_QUIT:
        gfw.quit()
    elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE):
        gfw.change(main_state)

    player.handle_event(e)
Exemple #17
0
def handle_event(e):
    if e.type == SDL_QUIT:
        gfw.quit()
    elif e.type == SDL_KEYDOWN:
        if e.key == SDLK_ESCAPE:
            gfw.pop()
        if e.key == SDLK_RETURN or e.key == SDLK_KP_ENTER:
            gfw.change(main_state)
Exemple #18
0
def handle_event(e):
    global end_time, change
    if end_time > 2.0:
        if change == False:
            if e.type == SDL_KEYDOWN or e.type == SDL_MOUSEBUTTONDOWN:
                change = True
                gfw.change(title_state)
            elif e.type == SDL_QUIT:
                gfw.quit()
Exemple #19
0
def handle_event(e):
    if e.type == SDL_QUIT:
        gfw.quit()
    elif e.type == SDL_KEYDOWN:
        if e.key == SDLK_RETURN:
            #gfw.world.clear()
            gfw.change(Scene_Menu, 0)
        elif e.key == SDLK_ESCAPE:
            gfw.quit()
Exemple #20
0
def check_game_over():
    fall = player.get_fall()
    hp_over = False
    if ui.width < 67:
        player.state = 6
        global die_time
        die_time = get_time()
    if fall:
        Scene_Result.set_score(score)
        gfw.change(Scene_Result, player.select)
 def handle_events(self, event):
     for e in event:
         if e.type == SDL_KEYDOWN:
             if e.type == SDLK_KP_ENTER:
                 if self.bSelect:
                     gfw.change(self.state_name)
             elif e.type == SDLK_UP or e.type == SDLK_DOWN:
                 if self.bSelect:
                     self.dx = 1
                 else:
                     self.dx = 0
Exemple #22
0
def update():
    image_count = len(IMAGE_FILES)
    global index, time
    if index < image_count:
        file = IMAGE_FILES[index]
        gfw.image.load(file)
    else:
        gfw.change(main_state)
        return
    index += 1
    time += gfw.delta_time
Exemple #23
0
def handle_event(e):
	if e.type == SDL_QUIT:
        gfw.quit()
    elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE):
        gfw.quit()
    elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_SPACE):
        gfw.change(game_state)

def exit():
    global image
    del image
Exemple #24
0
def handle_event(e):
    global player, state
    # prev_dx = boy.dx
    if e.type == SDL_QUIT:
        gfw.quit()
    elif e.type == SDL_KEYDOWN:
        if e.key == SDLK_ESCAPE:
            if state == STATE_GAME_OVER:
                gfw.change(title_state)

    player.handle_event(e)
Exemple #25
0
def update():
    global speed, sound, END, check_start, play_speed, PAUSE_TILE, collision_count, title_font
    if Tile.start:
        if check_start == False:
            gfw.world.clear_at(gfw.layer.ui)
            sound.play()
            check_start = True
    if END:
        sound.stop()
        gfw.change(result)
    else:

        for obj in gfw.world.objects_at(gfw.layer.tile):
            if obj.miss_tile == True:
                obj.image = gfw.image.load(gobj.res('놓친타일.png'))
                END = True

        gfw.world.update()
        if Tile.start:
            if PAUSE_TILE == False:
                dy = -TILE_SPEED * gfw.delta_time
        else:
            dy = 0

        global last_mouse_pos
        last_mouse_pos = last_mouse_pos[0], last_mouse_pos[1] + dy

        for obj in gfw.world.objects_at(gfw.layer.tile):
            if PAUSE_TILE == False:
                obj.move(dy)

        for obj in gfw.world.objects_at(gfw.layer.tile):
            if obj.sound_time > gfw.delta_time * play_speed:
                sound.pause()

            if obj.success_tile:
                check_start = True
                obj.sound_time += gfw.delta_time

        for obj in gfw.world.objects_at(gfw.layer.tile):
            if obj.check_disappearing_tile(
            ) == True and obj.success_tile == True:
                gfw.world.remove(obj)
            if obj.check_disappearing_tile(
            ) == True and obj.success_tile == False:
                obj.image = gfw.image.load(gobj.res('놓친타일.png'))
                obj.miss_tile = True
                END = True

        if PAUSE_TILE == False:
            stage_gen.update(dy)
Exemple #26
0
def update():
    if player.end:
        result_state.IsWin = False
        gfw.change(result_state)
    gfw.world.update()

    global score
    score += gfw.delta_time

    # stage1 playetime
    global stage_playtime
    stage_playtime += gfw.delta_time

    # boss 출현
    if stage_playtime > go_boss:
        if gfw.world.count_at(gfw.layer.boss) == 0:
            gfw.world.add(gfw.layer.boss, boss)

    else:
        # enemy 생성 시간
        global enemy_time
        enemy_time -= gfw.delta_time
        if enemy_time <= 0:
            gfw.world.add(gfw.layer.enemy, Enemy())
            if stage_playtime >= 0 and stage_playtime < 20:
                enemy_time = 2
            elif stage_playtime >= 20 and stage_playtime < 40:
                enemy_time = 1.5
            else:
                enemy_time = 1

    for e in gfw.world.objects_at(gfw.layer.enemy):
        check_collision_enemy(e)

    for eb in gfw.world.objects_at(gfw.layer.enemy_bullet):
        check_collision_enemybullet(eb)

    for s in gfw.world.objects_at(gfw.layer.skill):
        check_collision_playerskill(s)

    # Item 생성
    global item_gen_time
    item_gen_time -= gfw.delta_time

    if item_gen_time <= 0:
        gfw.world.add(gfw.layer.item, Item())
        item_gen_time = 15

    check_collision_item()
    check_collision_boss()
Exemple #27
0
def update():
    global isPaused
    global stage
    global timer
    if isPaused:
        return

    gfw.world.update()
    if player.get_goal() and stage < 12:
        gfw.world.cleartime_add(stage, timer.get_time())
        gfw.push(result_state)
    elif player.get_goal() and stage == 12:
        gfw.world.cleartime_add(stage, timer.get_time())
        gfw.change(ending_state)
Exemple #28
0
 def handle_event(self, e):
     pair = (e.type, e.key)
     if pair in Player.KEY_MAP:
         if self.target is not None:
             if e.type == SDL_KEYUP: return
             self.updateAction(0, -self.delta[0])
             self.target = None
             self.delta = 0, 0
             self.targets = []
             self.speed = 0
         self.updateDelta(*Player.KEY_MAP[pair])
     elif pair == Player.KEYDOWN_G:
         self.fire()
     elif pair == Player.KEYDOWN_R:
         gfw.change(title_state)
def handle_event(e):
    global player, stage
    # prev_dx = boy.dx
    if e.type == SDL_QUIT:
        gfw.quit()
    elif e.type == SDL_KEYDOWN:
        if e.key == SDLK_ESCAPE:
            gfw.pop()
        if e.key == SDLK_RETURN and gameover:
            gfw.world.clear()
            gfw.change(ranking_state)
    if e.type == SDL_MOUSEMOTION:
        global target_pos
        target_pos = (e.x ,get_canvas_height() - e.y - 1)
    player.handle_event(e)
Exemple #30
0
def handle_event(e):
    global mouse, select
    if e.type == SDL_QUIT:
        gfw.quit()
        return
    elif e.type == SDL_KEYDOWN:
        if e.key == SDLK_ESCAPE:
            gfw.quit()
            return
        elif e.key == SDLK_RETURN:
            gfw.change(test_state, select)
    elif e.type == SDL_MOUSEBUTTONDOWN:
        print(e.x, e.y)
        mouse = (e.x, e.y)
    pass