def update(): global player, gameState, wav_bomb, wav_item if gameState != GAMESTATE_INPLAY: delay(0.01) return ui.update() game_world.update() global wall, ball wall.didBounce(ball) player.didBounce(ball) global stage, stage_number for b in game_world.objects_at_layer(game_world.layer_obstacle): if b.didBounce(ball): if stage != None and 'scores' in stage: score = stage['scores'][b.type] # print(b.type, score) else: score = b.score if b.life == 0: player.score += score update_score() count = game_world.count_at_layer(game_world.layer_obstacle) if count == 0: goto_next_stage() break delay(0.01)
def update(): game_world.update() for ball in game_world.objects_at_layer(game_world.layer_obstacle): if collides(boy, ball): print("Collision:", ball) game_world.remove_object(ball) delay(0.03)
def update(): global time, Impcount, Holycount, Tumscount, Demoncount, size delay(0.03) time = (get_time() // 1) if (time < 60): if (time % 10 == 0 and Impcount == 0): game_world.add_object(Monster.Imp(), game_world.layer_monster) Impcount = 1 if (time % 10 == 9 and Impcount == 1): Impcount = 0 if (time % 20 == 0 and Holycount == 0): game_world.objects[0][1].pop() Holycount = 1 if (time % 20 == 19 and Holycount == 1): Holycount = 0 elif (time < 180): if (size == 0): resize_canvas(800, 600) size = 1 if (time % 5 == 0 and Impcount == 0): game_world.add_object(Monster.Imp(), game_world.layer_monster) Impcount = 1 if (time % 5 == 4 and Impcount == 1): Impcount = 0 if (time % 30 == 0 and Holycount == 0): game_world.objects[0][1].pop() Holycount = 1 if (time % 30 == 29 and Holycount == 1): Holycount = 0 if (time % 20 == 0 and Tumscount == 0): game_world.add_object(Monster.Tums(), game_world.layer_monster) Tumscount = 1 if (time % 20 == 19 and Tumscount == 1): Tumscount = 0 elif (time < 300): if (size == 1): resize_canvas(1000, 800) size = 2 if (time % 3 == 0 and Impcount == 0): game_world.add_object(Monster.Imp(), game_world.layer_monster) Impcount = 1 if (time % 3 == 2 and Impcount == 1): Impcount = 0 if (time % 30 == 0 and Holycount == 0): game_world.objects[0][1].pop() Holycount = 1 if (time % 30 == 29 and Holycount == 1): Holycount = 0 if (time % 10 == 0 and Tumscount == 0): game_world.add_object(Monster.Tums(), game_world.layer_monster) Tumscount = 1 if (time % 10 == 9 and Tumscount == 1): Tumscount = 0 if (time % 30 == 0 and Demoncount == 0): game_world.add_object(Monster.Demon(), game_world.layer_monster) Demoncount = 1 if (time % 30 == 29 and Demoncount == 1): Demoncount = 0 game_world.update()
def update(): global player, gameState, wav_bomb, wav_item ui.update() game_world.update() if gameState == GAMESTATE_INPLAY: if random.random() < 0.01: if (random.random() < 0.5): item = Item(*gen_random()) else: item = CoinItem(*gen_random()) game_world.add_object(item, game_world.layer_item) print("Items:", game_world.count_at_layer(game_world.layer_item)) for m in game_world.objects_at_layer(game_world.layer_obstacle): collides = collides_distance(player, m) if collides: wav_bomb.play() player.life -= 1 print("Player Life = ", player.life) if player.life > 0: game_world.remove_object(m) else: end_game() break for m in game_world.objects_at_layer(game_world.layer_item): collides = collides_distance(player, m) if collides: wav_item.play() game_world.remove_object(m) if player.life < Life.LIFE_AT_START: player.life += 1 else: player.score += m.score break player.score += game_framework.frame_time update_score() obstacle_count = game_world.count_at_layer(game_world.layer_obstacle) # print(obstacle_count) if obstacle_count < BULLETS_AT_START + player.score // 10: # print("Missiles:", (obstacle_count + 1)) createMissle() delay(0.03)
def update(): game_world.update() delay(0.03)
def update(): game_world.update()
def update(): create = random.randint(0, 100) TrapPattern = random.randint(0, 3) # 오브젝트 생성 if cookie.itemcount > 0.01: jelly = Jelly() # 젤리 (점수) game_world.add_object(jelly, game_world.layer_obstacle) # 0.01초마다 5% 확률로 포션 생성 if create < 5: potion = Potion() game_world.add_object(potion, game_world.layer_obstacle) cookie.itemcount = 0 # 함정의 경우 if cookie.count >= 1.0: if TrapPattern == 0: jtrap = jTrap() # 1단 점프 함정 game_world.add_object(jtrap, game_world.layer_obstacle) cookie.count = 0 elif TrapPattern == 1: djtrap = djTrap() # 2단 점프 함정 game_world.add_object(djtrap, game_world.layer_obstacle) cookie.count = 0 elif TrapPattern == 2: strap = sTrap() # 슬라이드 함정 game_world.add_object(strap, game_world.layer_obstacle) cookie.count = 0 # 게임월드 업데이트 game_world.update() # 충돌처리 for obj in game_world.all_objects(): if isinstance(obj, Jelly) and hp.HP_count >= 0: if collides(cookie, obj): cookie.score += 5 jelly_sound.play() game_world.remove_object(obj) if isinstance(obj, Potion): if collides(cookie, obj) and hp.HP_count >= 0: hp.HP_count += 30 item_sound.play() game_world.remove_object(obj) # 함정 if isinstance(obj, jTrap): if collides(cookie, obj) and hp.HP_count >= 0: game_world.remove_object(obj) collide_sound.play() cookie.fps = 0 cookie.state = cookie.COLLIDE hp.HP_count -= 50 if isinstance(obj, djTrap): if collides(cookie, obj) and hp.HP_count >= 0: game_world.remove_object(obj) collide_sound.play() cookie.fps = 0 cookie.state = cookie.COLLIDE hp.HP_count -= 50 if isinstance(obj, sTrap): if collides(cookie, obj) and hp.HP_count >= 0: game_world.remove_object(obj) collide_sound.play() cookie.fps = 0 cookie.state = cookie.COLLIDE hp.HP_count -= 50 update_score() if hp.HP_count <= 0: cookie.x -= 10 * game_framework.frame_time if cookie.x <= -500: game_framework.change_state(Score_state)
def update(): if mode=='AI': loadtimer.AI() imageloader.update() game_world.update()