def update(frame_time): global regen_time, monster_count, death_time frame_time += get_frame_time() regen_time += frame_time character.update(frame_time) state_2.update(frame_time) if monster_count != 0: if regen_time > Pig.REGEN_TIME: pig = Pig() monster_list.append(pig) regen_time = 0 monster_count -= 1 for pig in monster_list: pig.update(frame_time) if pig.attack_time == 4: if collision(character,pig) and character.state != character.DIE_STATE: character.now_hp -= pig.pig_attack pig.attack_time -= 1 if pig.attack_time != 4: pig.attack_time -= 1 if pig.attack_time == 0: pig.attack_time = 4 if character.state == character.SKILL_HOLLY_STATE: if collision_skill(character, pig): pig.hit(character.skill_holly_damage) if character.state == character.SKILL_LAST_STATE: if collision_skill_last(character, pig): pig.hit(character.skill_last_damage) if pig.pig_nowhp <= 0: death_time += frame_time if monster_list.count(pig) > 0 and death_time > 0.5: monster_list.remove(pig) death_time = 0 character.now_exp += pig.pig_exp for bullet in bullets: bullet.update(frame_time) for pig in monster_list: if collision(pig, bullet): pig.hit(character.damage) if bullets.count(bullet) > 0: bullets.remove(bullet) # if bullet.sx > 900: # bullets.remove(bullet) if character.now_hp <= 0: sound.stop() game_framework.change_state(GameOver)
def update(frame_time): global regen_time, monster_count frame_time += get_frame_time() regen_time += frame_time character.update(frame_time) state_2.update(frame_time) if monster_count != 0: if regen_time > Pig.REGEN_TIME: pig = Pig() monster_list.append(pig) regen_time = 0 monster_count -= 1 for pig in monster_list: pig.update(frame_time) if pig.attack_time == 4: if collision(character,pig): character.now_hp -= pig.pig_attack pig.attack_time -= 1 if pig.attack_time != 4: pig.attack_time -= 1 if pig.attack_time == 0: pig.attack_time = 4 if character.state == character.SKILL_HOLLY_STATE: if collision_skill(character, pig): pig.pig_nowhp -= character.skill_holly_damage if pig.pig_nowhp <= 0: character.now_exp += pig.pig_exp if monster_list.count(pig) > 0: monster_list.remove(pig) for bullet in bullets: bullet.update(frame_time) for pig in monster_list: if collision(pig, bullet): pig.pig_nowhp -= character.damage if bullets.count(bullet) > 0: bullets.remove(bullet) if bullet.sx > 900: bullets.remove(bullet)