def update():
    # map
    # 현재 스테이지 리스트를 딕셔너리에서 가져옴
    currentmaplist = totalmap.get(currentmap)
    # list loop
    for map in currentmaplist:
        erase = map.update(currentmaplist)
        if erase == True:
            currentmaplist.remove(map)

    # stage
    updateStage()

    # collider Check
    collision_manager.collide_update()

    # end check
    if len(game_world.get_layer(PLAYER)) == 0:
        mainframe.change_state(result_scene)

    # update game obj
    for game_object in game_world.all_objects():
        erase = game_object.update()
        if erase == True:
            game_world.remove_object(game_object)
Example #2
0
    def update(self):
        self.cur_state.do(self)
        if len(self.event_que) > 0:
            event = self.event_que.pop()
            self.cur_state.exit(self, event)
            self.cur_state = next_state_table[self.cur_state][event]
            self.cur_state.enter(self, event)

        if (self.hp < 0):
            self.dead_sound.play()
            dead_anime = Dead_anime(self.x, self.y)
            game_world.add_object(dead_anime, 1)
            self.life -= 1
            self.hp = 1
            self.x = 300
            self.y = 50
            self.lifcount = 1
            self.special_count = 3

        if (self.lifcount == 1):
            self.hp = 1000
            if (self.lifetime == 0):
                self.lifetime = get_time()
                #self.hp = 1000

            if (get_time() - self.lifetime > 3):
                self.hp = 1
                self.lifetime = 0
                self.lifcount = 0

            if (self.life < 0):
                game_world.remove_object(self)
Example #3
0
    def update(self):
        if self.stopTimer > 0:
            elapsed = get_time() - self.stopTimer
            if elapsed > 3.0:
                game_world.remove_object(self)
            return

        self.x += self.dx
        self.y += self.dy

        self.dx *= WIND_RESISTANCE
        self.dy -= GRAVITY

        height = self.y - BOUNCING_GROUND
        if height < 0:
            self.y -= height
            self.dy *= -BOUNCE_RESISTANCE

        if math.fabs(height) < MIN_MOVE and \
         math.fabs(self.dx) < MIN_MOVE and \
         math.fabs(self.dy) < MIN_MOVE:
            self.dx = self.dy = 0
            self.y = BOUNCING_GROUND
            self.stopTimer = get_time()

        if self.x < -DEL_MARGIN or \
         self.x > self.canvas_width + DEL_MARGIN or \
         self.y < -DEL_MARGIN or \
         self.y > self.canvas_height + DEL_MARGIN:
            game_world.remove_object(self)
Example #4
0
 def update(self):
     self.timer -= 1
     if (self.timer == 0):
         game_world.remove_object(self)
         global boy_death_motions
         boy_death_motions = Death_Motion(self.x, self.y)
         game_world.add_object(boy_death_motions, 4)
Example #5
0
def update():
    for game_object in game_world.all_objects():
        game_object.update()

    if collide(enemy, fire_ball):
        print("collide")
        game_world.remove_object(enemy)
Example #6
0
 def update(self):
     self.cx, self.cy = self.x - (self.bg.window_left * 32) - 16, self.y - (
         self.bg.window_bottom * 32)
     self.tileX, self.tileY = (self.x - 16) // 32, (self.y - 16) // 32
     if self.turn == 1:
         self.bt.run()
     # print("monster : ", (self.y - 16) // 32, (self.x - 16) // 32, map.MapLi[self.tileY][self.tileX])
     if self.state == 0:
         self.timer = (self.timer + 1) % 1000
         if self.timer > 800:
             self.idl = 1
         else:
             self.idl = 0
     if self.state == 1:
         self.deadTimer += 1
         if self.deadTimer == 96:
             warrior = main_state.get_warrior()
             game_world.remove_object(self)
             warrior.gameWon = 1
             warrior.score += 50
             game_framework.push_state(game_over)
     if self.state == 2:
         self.atkTimer = (self.atkTimer + FRAMES_PER_ACTION *
                          ACTION_PER_TIME * game_framework.frame_time)
         if self.atkTimer < 7:  # 조정해.
             if self.atkTimer < 3:
                 self.atkPose = 1
             elif self.atkTimer < 5:
                 self.atkPose = 2
             else:
                 self.atkPose = 3
         else:
             self.atkTimer = 0
             self.atkPose = 0
             self.state = 0
def update():
    global boy
    for game_object in game_world.all_objects():
        game_object.update()
    for ball in balls:
        if collide(boy, ball):
            balls.remove(ball)
            game_world.remove_object(ball)
    for ball in balls:
        if collide(grass, ball):
            ball.stop()
    for ball in balls:
        if collide(brick, ball):
            ball.stop()
            ball.x -= brick.move_speed * game_framework.frame_time
    if boy.is_collide == False:
        if collide(boy, brick):
            boy.stop()
            boy.y = brick.y + 50
            boy.x -= brick.move_speed * game_framework.frame_time
            boy.is_collide = True
    if boy.is_collide == True:
        if not collide(boy, brick):
            boy.jump_speed = -1
            boy.is_collide = False
Example #8
0
def handle_events():
    global see_right, skeletons, items, click, bonfire_ready, background, bonfire, light, stone, wood
    events = get_events()
    for event in events:
        if event.type == SDL_QUIT:
            game_framework.quit()
        elif event.type == SDL_MOUSEMOTION:
            mousecursor.position(x=event.x, y=VIEW_HEIGHT - 1 - event.y)
        elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE:
            del (skeletons)
            del (items)
            del light
            game_framework.change_state(title_state)
        elif event.type == SDL_KEYDOWN and event.key == SDLK_p:
            game_framework.push_state(pause_state)
        elif event.type == SDL_MOUSEBUTTONDOWN and event.button == SDL_BUTTON_RIGHT:
            if collision(ui, mousecursor):
                if stone >= 2 and wood >= 2:
                    game_world.remove_object(bonfire)
                    game_world.remove_object(light)
                    bonfire = Bonfire(player.x, player.y)
                    game_world.add_object(bonfire, 3)
                    bonfire.set_background(background)
                    light = Light(bonfire.x, bonfire.y)
                    game_world.add_object(light, 3)
                    light.set_background(background)
                    stone -= 2
                    wood -= 2
        else:
            player.handle_event(event)
Example #9
0
    def update(self):
        self.frame = (self.frame + boy.FRAMES_PER_ACTION *
                      boy.ACTION_PER_TIME * game_framework.frame_time) % 8
        if (self.state == 0):
            self.r += boy.RUN_SPEED_PPS * game_framework.frame_time
            self.x_cos = self.x + math.cos(
                math.pi / 180 * self.rotate) * self.r
            self.y_sin = self.y + math.sin(
                math.pi / 180 * self.rotate) * self.r
            if (self.r >= 100):
                self.r = 100
                self.state = 1

        if (self.state == 1):
            boy.real_time += game_framework.frame_time
            self.rotate += 720 * game_framework.frame_time
            self.x_cos = self.x + math.cos(
                math.pi / 180 * self.rotate) * self.r
            self.y_sin = self.y + math.sin(
                math.pi / 180 * self.rotate) * self.r

        if (boy.real_time >= 1.0):
            boy.real_time = boy.real_time % 1

        if (main_state.boy.cur_state != boy.SleepState):
            game_world.remove_object(self)
Example #10
0
    def update(self):
        if self.type == 1:  #직선
            self.x += BasicShooter(self, 'x')
            self.y += BasicShooter(self, 'y')

        elif self.type == 2:  #가속
            self.speed += 3 * game_framework.frame_time
            self.x += BasicShooter(self, 'x')
            self.y += BasicShooter(self, 'y')

        elif self.type == 3:  #회전
            self.speed += 3 * game_framework.frame_time
            self.x += BasicShooter(self, 'x')
            self.y += BasicShooter(self, 'y')
            self.x += math.cos((self.angle + 45) * 3.14 /
                               180) * 0.7 * game_framework.frame_time
            self.y += math.sin((self.angle + 45) * 3.14 /
                               180) * 0.7 * game_framework.frame_time
            self.angle += 180 * game_framework.frame_time

        elif self.type == 4:  #폭죽
            self.speed -= 5 * game_framework.frame_time
            self.x += BasicShooter(self, 'x')
            self.y += BasicShooter(self, 'y')
            if (self.speed < 0):
                game_world.remove_object(self)
        elif self.type == 5:  #후진
            self.speed -= 2 * game_framework.frame_time
            self.x += BasicShooter(self, 'x')
            self.y += BasicShooter(self, 'y')

        if self.x < 0 or self.x > 1000 or self.y < 0 or self.y > 600:
            game_world.remove_object(self)
        pass
Example #11
0
    def update(self):
        if self.rest_attack_time != 0:
            self.rest_attack_time -= app.elapsed_time
            if self.rest_attack_time < 0:
                self.rest_attack_time = 0
        for game_object in game_world.all_objects():
            if isinstance(game_object, monster.Monster):
                if app.collide(self, game_object):
                    if game_object.cur_state == monster.BubbleState:
                        app.score += 1000
                        game_object.add_event(monster.DIE)
                    elif game_object.cur_state == monster.DieState:
                        pass
                    else:
                        game_framework.change_state(scene_state_score)
            elif isinstance(game_object, Bubble):
                if app.collide(self, game_object
                               ) and game_object.cur_state == bubble.MoveState:
                    app.score += 10
                    game_object.add_event(bubble.DISAPPEAR)
            elif isinstance(game_object, Item):
                if app.collide(self, game_object):
                    app.score += game_object.type_score
                    game_world.remove_object(game_object)

        self.cur_state.do(self)
        if len(self.event_que) > 0:
            event = self.event_que.pop()
            self.cur_state.exit(self, event)
            self.cur_state = next_state_table[self.cur_state][event]
            self.cur_state.enter(self, event)
Example #12
0
    def update(self):
        self.x_acceleration = 0        # 던진 후 가속도

        if self.dir == 1:
            self.x += self.x_throwvelocity * game_framework.frame_Time
        elif self.dir == -1:
            self.x -= self.x_throwvelocity * game_framework.frame_Time
        self.x_throwvelocity -= self.frictional_force

        if self.x_throwvelocity > 0:
            self.x_throwvelocity += self.u
        elif self.x_throwvelocity < 0:
            self.x_throwvelocity = 0

        if self.y_init - self.y < 16:
            self.y -= self.y_throwvelocity * game_framework.frame_Time
            self.y_throwvelocity += self.y_acceleration
        else:
            self.x_throwvelocity *= -1

        if self.y < 0 + 64 + 4:
            self.y_throwvelocity *= -0.5
            self.x_velocity = 0
        self.end_timer = get_time()
        self.elapsed_time = self.end_timer - self.start_timer

        if self.elapsed_time > 1:
            game_world.remove_object(self)
Example #13
0
def update():
    for game_object in game_world.all_objects():
        game_object.update()
        for fiser in fish:
            if fiser.HP<=0:
                fish.remove(fiser)
                number[fiser.y//50][fiser.x//50]=0
                game_world.remove_object(fiser)
                tiles.lock -=1
        for birds in bird:
            if birds.HP<=0:
                bird.remove(birds)
                number[birds.y//50][birds.x//50]=0
                game_world.remove_object(birds)
                tiles.lock -= 1
    if number[int(hero.y // 50)][int(hero.x // 50)] is 5:
        game_framework.push_state(game_end_state)
    if hero.HP < 0 + 1:
        game_framework.push_state(game_over_state)
    if tiles.lock<=0:
        for i in range(0, 45):
            for j in range(0, 60):
                if number[i][j] is 6:
                    number[i][j]=5
                    open_lock.play(1)
Example #14
0
    def update(self):
        if self.y > 220:
            self.y -= self.speed * 0.02

        if self.x > 600:
            self.dir = -1
        if self.x < 100:
            self.dir = 1
        self.x += self.dir * 3
        #self.y-=self.dir*5

        self.timer -= 1
        if (self.timer == 0):
            game_world.remove_object(self)
            global enemy_bubble_destroys
            enemy_bubble_destroys = Bubble_destroy(self.x, self.y)
            game_world.add_object(enemy_bubble_destroys, 3)
            enemy_bubble_destroysList = game_world.get_layer(3)
            boyList = game_world.get_layer(3)
            game_world.remove_object(self)

            for i in range(len(enemy_bubble_destroysList)):
                if self.collide(boyList[0], enemy_bubble_destroysList[i]):
                    print("collide_enemy")
                    break
Example #15
0
 def update(self):
     self.cx, self.cy = self.x - (self.bg.window_left *
                                  32), self.y - (self.bg.window_bottom * 32)
     self.tileX, self.tileY = (self.x - 16) // 32, (self.y - 16) // 32
     if self.turn == 1:
         self.bt.run()
     # print("monster : ", (self.y - 16) // 32, (self.x - 16) // 32, map.MapLi[self.tileY][self.tileX])
     if self.state == 0:
         self.timer = (self.timer + 1) % 1000
         if self.timer > 800:
             self.idl = 1
         else:
             self.idl = 0
     if self.state == 1:
         self.deadTimer += 1
         if self.deadTimer == 96:
             main_state.make_item(self.x, self.y)
             main_state.lvl_up()
             game_world.remove_object(self)
     if self.state == 2:
         self.atkTimer = (self.atkTimer + FRAMES_PER_ACTION *
                          ACTION_PER_TIME * game_framework.frame_time)
         if self.atkTimer < 5:  # 조정해.
             if self.atkTimer < 3:
                 self.atkPose = 1
             else:
                 self.atkPose = 2
         else:
             self.atkTimer = 0
             self.atkPose = 0
             self.state = 0
Example #16
0
    def body_update(self):
        if self.state == 1:
            boss_pattern.pattern_head_1(self.fire_time, self.x, self.y, 2)

        elif self.state == 2:
            boss_pattern.pattern_head_2(self.fire_time,self.x,self.y,2, self.degree)

        elif self.state == 3:
            boss_pattern.pattern_head_3(self.fire_time,self.x, self.y, 6, self.degree)


        if self.state != 0:
            if self.HP < 2000:
                boss_pattern.pattern_tentacle(self.fire_time, self.x + 250, self.y + 50, 0)
                boss_pattern.pattern_tentacle(self.fire_time, self.x + 250, self.y - 50, 0)
                boss_pattern.pattern_tentacle(self.fire_time, self.x - 250, self.y + 50, 0)
                boss_pattern.pattern_tentacle(self.fire_time, self.x - 250, self.y - 50, 0)
            for hero_bullet in game_world.get_objects(2):
                if ((hero_bullet.x - self.x)**2 + (hero_bullet.y - (self.y + 50))**2 ) < (PIXEL_PER_METER*2)**2 or \
                        ((hero_bullet.x - self.x)**2 + (hero_bullet.y - (self.y - 100))**2 ) < (PIXEL_PER_METER*2)**2 or \
                    ((hero_bullet.x - self.x) ** 2 + (hero_bullet.y - (self.y)) ** 2) < (PIXEL_PER_METER * 2) ** 2:
                    #라이플은 단순한 데미지
                    if hero_bullet.state == 1 or hero_bullet.state == 2:
                        self.HP -= hero_bullet.damage
                    #바주카는 스플래시 데미지
                    elif hero_bullet.state == 3:
                        self.HP -= hero_bullet.damage
                        explosion = Explosion(hero_bullet.x, hero_bullet.y)
                        game_world.add_object(explosion, 4)
                    game_world.remove_object(hero_bullet)
Example #17
0
def update():
    global hit_sound
    for game_object in game_world.all_objects():
        game_object.update()
    game_framework.player.update()
    for monster in monsters:
        for arrow in game_framework.player.arrow_list:
            if collide(monster, arrow):
                game_framework.player.arrow_list.remove(arrow)
                monster.life -= game_framework.player.atk
                hit_sound.play()
                if monster.life <= 0:
                    monsters.remove(monster)
                    game_world.remove_object(monster)
                    game_framework.player.money += monster.money
    if not game_framework.player.Isinvincible:
        for monster in monsters:
            if collide(monster, game_framework.player):
                game_framework.player.invincible_time = get_time()
                game_framework.player.life -= monster.atk
                game_framework.player.Isinvincible = True
    if len(monsters) == 0:
        game_framework.change_state(boss_stage)
    if game_framework.player.life <= 0:
        game_framework.change_state(dead_state)
    pass
def update():
    for game_object in game_world.all_objects():
        game_object.update()
    # fill here for collision check
    for ball in balls:
        if collide(boy, ball):
            balls.remove(ball)
            game_world.remove_object(ball)

    #for ball in balls:
    #    if collide(boy,ball):
    #        boy.velocity2=0
    if collide(boy, brick):
        #boy.y = brick.y + 60
        #boy.velocity2 = 0
        if boy.y - brick.y > 55:
            boy.stop_fall()
        boy.x += brick.velocity * game_framework.frame_time

    for ball in balls:
        if collide(grass, ball):
            ball.stop()

    for ball in balls:
        if collide(
                brick, ball
        ):  # and not(ball.x+20 > brick.x-90 and ball.x-20 < brick.x+90):
            ball.x += brick.velocity * game_framework.frame_time
            if ball.y - brick.y > 39:
                ball.stop()
Example #19
0
 def enter(Slime):
     Slime.timer = 0
     if Slime.damage != 0:
         Slime.HP -= Slime.damage
         Slime.damage = 0
     if Slime.HP <= 0:
         game_world.remove_object(Slime)
Example #20
0
def update():
    for game_object in game_world.all_objects():
        game_object.update()
    for P_Bullet in game_world.objects[1]:
        for Enemy_1 in game_world.objects[1]:
            if collide(
                    Enemy_1,
                    P_Bullet) and Enemy_1.state == 2 and P_Bullet.state == 1:
                game_world.remove_object(P_Bullet)
                if Enemy_1.Hp > 0:
                    Enemy_1.Hp -= 1
                if Enemy_1.Hp == 0:
                    Enemy_1.state = 3
                    map_counter.counter += 1
                    if Enemy_1.type == 1:
                        map_counter.type1_counter -= 1
                    if Enemy_1.type == 2:
                        map_counter.type2_counter -= 1
                    if Enemy_1.type == 3:
                        map_counter.type3_counter -= 1
                    if Enemy_1.type == 4:
                        map_counter.type4_counter -= 1
            if collide(
                    Enemy_1,
                    P_Bullet) and Enemy_1.state == 5 and P_Bullet.state == 0:
                game_world.remove_object(Enemy_1)
                player.state = 8
    if map_counter.stage == 1:
        Mapcounter.stage1(map_counter)
    if map_counter.stage == 2:
        Mapcounter.stage2(map_counter)
Example #21
0
def update():
    for game_object in game_world.all_objects():
        game_object.update()

    for ball in balls:
        if collide(boy, ball):
            balls.remove(ball)
            game_world.remove_object(ball)

    for ball in balls:
        if collide(grass, ball):
            ball.stop()
        if collide(brick, ball):
            ball.stop_brick()
    if collide(grass, boy):
        boy.check_grass = True

    if collide(brick, boy):
        boy.check_brick = True
        boy.stop()
    else:
        #boy.check_brick = False
        boy.reset()



    print(boy.check_grass, boy.check_brick)
Example #22
0
 def update(self):
     self.y -= RUN_SPEED_PPS * 0.05
     if self.y < 25:
         game_world.remove_object(self)
     if main_state.collide(main_state.heroine, self):
         main_state.heroine.special_count += 1
         game_world.remove_object(self)
Example #23
0
    def update(self):
        #self.y += self.velocity
        self.y += RUN_SPEED_PPS * 0.2

        if self.y < 25 or self.y > 800 - 25:
            game_world.remove_object(self)

        if main_state.collide(main_state.blue_enemy, self):
            main_state.blue_enemy.hp -= 1
            #game_world.remove_object(main_state.blue_enemy)

        for i in range(0, 3):
            if main_state.collide(main_state.blue_enemys1[i], self):
                main_state.blue_enemys1[i].hp -= 1
                #game_world.remove_object(main_state.blue_enemys1[i])

        if main_state.collide(main_state.bose_enemy, self):
            main_state.bose_enemy.hp -= 1
            #game_world.remove_object(main_state.bose_enemy)

        for i in range(0, 3):
            if main_state.collide(main_state.black_enemys1[i], self):
                main_state.black_enemys1[i].hp -= 1
                #game_world.remove_object(main_state.black_enemys1[i])

        if main_state.collide(main_state.red_enemy, self):
            main_state.red_enemy.hp -= 1

        if main_state.collide(main_state.green_enemy, self):
            main_state.green_enemy.hp -= 1

        if main_state.collide(main_state.special_enemy, self):
            main_state.special_enemy.hp -= 1
Example #24
0
def update():
    for game_object in game_world.all_objects():
        game_object.update()

    # 마리오가 점프로 적을 죽이면 적 없어짐
    if collide(mario, enemy):
        if mario.y >= enemy.y + 30:
            #print("c1")
            game_world.remove_object(enemy)

        else:
            #print("c2")
            game_world.remove_object(mario_life)

    # 마리오 & 아이템박스 충돌체크
    # 충돌하면 아이템이 나옴
    global item
    if collide(mario, item_box):
        item_box.collide_to_mario = True
        item = Item()
        game_world.add_object(item, 0)

    # 마리오 & 벽돌 충돌체크
    if collide(mario, brick):
        mario.is_collide_brick = True
Example #25
0
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)
Example #26
0
def update():
    for game_object in game_world.all_objects():
        game_object.update()

    # fill here for collision check
    for ball in balls:
        if collide(boy, ball):
            balls.remove(ball)
            game_world.remove_object(ball)
    for ball in balls:
        if collide(grass, ball):
            ball.stop()
    for ball in balls:
        if collide(tile, ball) and ball.y > tile.y + 20:
            ball.stop()
            speed, dir = tile.get_info()
            ball.get_tile_inf(speed, dir)
            ball.change_collide_with_tile()
    if collide(boy, grass):
        boy.collide = True
        boy.fall_velocity = 0
        boy.tile_collide = False
    elif collide(boy, tile):
        boy.collide = True
        boy.tile_collide = True
        boy.fall_velocity = 0
        boy.tile_dir = tile.dir
        boy.move_degree = tile.move_velocity
    else:
        boy.collide = False
        boy.tile_collide = False
Example #27
0
    def draw(self):
        if self.state == 2:
            self.image.clip_draw(355, 419, 120, 45, self.x, self.y,250, 170)
        elif self.state == 3:
            if int(self.frame) < 4:
                self.image.clip_draw(137, 393, 114, 100, self.x, self.y, 350, 270)
                self.image.clip_draw(137, 393, 114, 100, self.x-100, self.y+100, 350, 270)
                self.image.clip_draw(137, 393, 114, 100, self.x + 100, self.y - 100, 350, 270)
                if int(self.frame) == 0:
                    Enemy_6.sound.play()
            elif int(self.frame) < 8:
                self.image.clip_draw(137, 313, 114, 77, self.x, self.y, 350, 270)
                self.image.clip_draw(137, 313, 114, 77, self.x - 100, self.y + 100, 350, 270)
                self.image.clip_draw(137, 313, 114, 77, self.x + 100, self.y - 100, 350, 270)
            elif int(self.frame) < 12:
                self.image.clip_draw(137, 240, 114, 57, self.x, self.y, 350, 270)
                self.image.clip_draw(137, 240, 114, 57, self.x - 100, self.y + 100, 350, 270)
                self.image.clip_draw(137, 240, 114, 57, self.x + 100, self.y - 100, 350, 270)
                if int(self.frame) == 8:
                    Enemy_6.sound.play()
            elif int(self.frame) < 16:
                self.image.clip_draw(137, 80, 114, 80, self.x, self.y, 350, 270)
                self.image.clip_draw(137, 80, 114, 80, self.x - 100, self.y + 100, 350, 270)
                self.image.clip_draw(137, 80, 114, 80, self.x + 100, self.y - 100, 350, 270)
            elif int(self.frame) < 20:
                self.image.clip_draw(137, 80, 114, 80, self.x, self.y, 170, 130)
                self.image.clip_draw(137, 80, 114, 80, self.x - 50, self.y + 50, 170, 130)
                self.image.clip_draw(137, 80, 114, 80, self.x + 50, self.y - 50, 170, 130)
            elif int(self.frame) >= 20:
                main_state.map_counter.bossturn = 1
                game_world.remove_object(self)

            self.frame = (self.frame + player.FRAMES_PER_ACTION * player.ACTION_PER_TIME * game_framework.frame_time) % 21
        if main_state.player.rect == 0:
            draw_rectangle(*self.get_bb())
Example #28
0
    def update(self):
        self.x += self.velocity_x * 1.5
        self.y += self.velocity_y * 1.5
        self.frame += 1

        if self.frame > 7:
            game_world.remove_object(self)
Example #29
0
def update():
    for game_object in game_world.all_objects():
        game_object.update()

    # 마리오가 점프로 적을 죽이면 적 없어짐
    if collide(mario, enemy):
        if mario.y >= enemy.y + 30:
            #print("c1")
            game_world.remove_object(enemy)

        else:
            #print("c2")
            game_world.remove_object(mario_life)

    # 마리오 & 아이템박스
    global item
    if collide(mario, item_box):
        item_box.collide_to_mario = True
        mario.is_collide_item_box = True
        # 충돌하면 아이템이 나옴
        item = Item()
        game_world.add_object(item, 0)

    # 마리오 & 벽돌
    if collide(mario, brick):
        mario.is_collide_brick = True

    # 마리오 & 벽돌 아래
    if collide_down(brick, mario):
        mario.is_jump = False

    # 마리오 & 땅
    if collide(mario, map):
        mario.y = 130
def update():
    for game_object in game_world.all_objects():
        game_object.update()
    for ball in balls:

        if collide(terrain, ball):
            ball.stop()
            ball.set_x(int(terrain.dir * terrain.velocity))

        else:
            ball.start()

        if collide(grass, ball):
            ball.stop()

        if collide(boy, ball):
            balls.remove(ball)
            game_world.remove_object(ball)

    if boy:

        if collide(terrain, boy):
            boy.is_ground = True
            boy.x += int(terrain.dir * terrain.velocity)
        elif collide(grass, boy):
            boy.is_ground = True
            #boy.x += int(terrain.dir * terrain.velocity);
        else:
            boy.is_ground = False