Beispiel #1
0
def update(frame_time):

    for cubchoo in cubchooes:
        cubchoo.update(frame_time)
        collision.collision_object_and_character(map, cubchoo, frame_time)
        collision.collision_tile_and_character(map, cubchoo, frame_time)        
        if not cubchoo.life:
            cubchooes.remove(cubchoo)
    
    for terrorlight in terrorlights:
        terrorlight.update(frame_time)
        collision.collision_map_and_character(map, terrorlight, frame_time)
        collision.collision_object_and_character(map, terrorlight, frame_time)
        #collision.collision_tile_and_character(map, terrorlight, frame_time) 

    #map.update(frame_time)

    for maple in maples:
        maple.update(frame_time)

    '''
    for snow in snows:
        snow.update(frame_time)
    '''

    for cloud in clouds:
        cloud.update(frame_time)

    effects.update(frame_time)
def update(frame_time):
    global game_play, game_over, game_clear
    if not game_play:
        return
        
    if finn.life:
        finn.update(frame_time)
        collision.collision_tile_and_character(map, finn, frame_time)
        collision.collision_object_and_character(map, finn, frame_time)
    else:
        background_music.stop()
        game_over_music.repeat_play()
        game_play = False
        game_over = True
        
        
    for terrorlight in terrorlights:
        terrorlight.update(frame_time)
        
        if collision.collision_player_and_character(finn, terrorlight):
            effect_x = min(finn.x, terrorlight.x) + abs(finn.x - terrorlight.x) // 2
            effect_y = min(finn.y, terrorlight.y) + abs(finn.y - terrorlight.y) // 2
            effects.add_effect(damage_effect.DamageEffect(effect_x, effect_y))
            finn.play_hit_sound()
            if finn.speed > 30:
                finn.speed -= 10
                
        collision.collision_map_and_character(map, terrorlight, frame_time) 
        collision.collision_object_and_character(map, terrorlight, frame_time)
    

    if len(terrorlights) <= 5:
        global terrorlight_respone_time
        terrorlight_respone_time -= frame_time
        if terrorlight_respone_time < 0:
            object = map.to_trigger('Respone-C')
            terrorlight = terrorlight_character.Terrorlight()
            terrorlight.x, terrorlight.y = object.x, map.mapoffsety + map.mapheight - object.y
            terrorlights.append(terrorlight)
            terrorlight_respone_time = 7.0

    for cubchoo in cubchooes:
        cubchoo.update(frame_time) 
        
        if finn.frame_stop:
            if collision.collision_player_and_character(finn, cubchoo):
                effect_x = min(finn.x, cubchoo.x) + abs(finn.x - cubchoo.x) // 2
                effect_y = min(finn.y, cubchoo.y) + abs(finn.y - cubchoo.y) // 2
                effects.add_effect(damage_effect.DamageEffect(effect_x, effect_y))
                finn.play_hit_sound()
        else:
            if collision.collision_player_and_character(cubchoo, finn):
                effect_x = min(finn.x, cubchoo.x) + abs(finn.x - cubchoo.x) // 2
                effect_y = min(finn.y, cubchoo.y) + abs(finn.y - cubchoo.y) // 2
                effects.add_effect(push_effect.PushEffect(effect_x, effect_y))
                cubchoo_character.Cubchoo.hit_sound.play()
                finn.frame_stop = True
                
        collision.collision_object_and_character(map, cubchoo, frame_time) 
        collision.collision_tile_and_character(map, cubchoo, frame_time)
        if cubchoo.opacify < 0:
            cubchooes.remove(cubchoo)
    
    if len(cubchooes) <= 10:
        global cubchoo_respone_time_A
        cubchoo_respone_time_A -= frame_time
        if cubchoo_respone_time_A < 0:
            object = map.to_trigger('Respone-A')
            cubchoo = cubchoo_character.Cubchoo()
            cubchoo.x, cubchoo.y = object.x, map.mapoffsety + map.mapheight - object.y
            cubchooes.append(cubchoo)
            cubchoo_character.Cubchoo.respone_sound.play()
            cubchoo_respone_time_A = 3.0

        global cubchoo_respone_time_B
        cubchoo_respone_time_B -= frame_time
        if cubchoo_respone_time_B < 0:
            object = map.to_trigger('Respone-B')
            cubchoo = cubchoo_character.Cubchoo()
            cubchoo.x, cubchoo.y = object.x, map.mapoffsety + map.mapheight - object.y
            cubchooes.append(cubchoo)
            cubchoo_character.Cubchoo.respone_sound.play()
            cubchoo_respone_time_B = 5.0

    effects.update(frame_time)

    map.update(finn, frame_time)

    for maple in maples:
        maple.update(frame_time)

    '''
    for snow in snows:
        snow.update(frame_time)
    '''

    for cloud in clouds:
        cloud.update(frame_time)

    collision_trigger_and_player()