def collision_trigger_and_player(): for object in map.trigger_layer.objects: object_rect = map.to_object_rect(object) player_rect = finn.to_rect() if object.name == 'Warp-A': if collision.rect_in_rect(*(player_rect + object_rect)): effects.add_effect(warp_effect.WarpEffect(finn.x, finn.y)) portalB = map.to_trigger('Warp-B') portalB_rect = map.to_object_rect(portalB) effects.add_effect(warp_effect.WarpEffect(portalB_rect[0], portalB_rect[1])) finn.x, finn.y = portalB_rect[0], portalB_rect[1] warp_effect.WarpEffect.sound.play() elif object.name == 'Home': if collision.rect_in_rect(*(player_rect + object_rect)): global game_play, game_clear game_play = False game_clear = True background_music.stop() game_clear_music.repeat_play()
def is_tile_on_object(self,x,y): tile_x = self.mapoffsetx + ( ((y+1) % 2) * self.tilewidth // 2 ) + (x * self.tilewidth) - (self.tilewidth // 2) tile_y = self.mapoffsety + ( y * (self.tileheight // 2)) tile_rect = ( tile_x, tile_y - (self.tileheight // 4), tile_x + self.tilewidth, tile_y + (self.tileheight // 2) ) for object in self.collision_layer.objects: object_rect = self.to_object_rect(object) if collision.rect_in_rect(*(object_rect+tile_rect)): return True for object in self.trigger_layer.objects: object_rect = self.to_object_rect(object) if collision.rect_in_rect(*(object_rect+tile_rect)): return True return False
def collision_trigger_and_player(): global tutorial_str global cubchooes, cubchoo_respone_start for object in map.trigger_layer.objects: object_rect = map.to_object_rect(object) player_rect = finn.to_rect() if object.name == 'Warp-A': if collision.rect_in_rect(*(player_rect + object_rect)): effects.add_effect(warp_effect.WarpEffect(finn.x, finn.y)) portalB = map.to_trigger('Warp-B') portalB_rect = map.to_object_rect(portalB) effects.add_effect(warp_effect.WarpEffect(portalB_rect[0], portalB_rect[1])) finn.x, finn.y = portalB_rect[0], portalB_rect[1] warp_effect.WarpEffect.sound.play() if object.name == 'Warp-C': if collision.rect_in_rect(*(player_rect + object_rect)): effects.add_effect(warp_effect.WarpEffect(finn.x, finn.y)) portalD = map.to_trigger('Warp-D') portalD_rect = map.to_object_rect(portalD) effects.add_effect(warp_effect.WarpEffect(portalD_rect[0], portalD_rect[1])) finn.x, finn.y = portalD_rect[0], portalD_rect[1] warp_effect.WarpEffect.sound.play() cubchoo_respone_start = False cubchooes.clear() global terrorlight_respone_start terrorlight_respone_start = True tutorial_str = '거의 다 왔어!' elif object.name == 'Home': if collision.rect_in_rect(*(player_rect + object_rect)): global game_play, game_clear game_play = False game_clear = True background_music.stop() game_clear_music.repeat_play() elif object.name == 'Tutorial-0': if collision.rect_in_rect(*(player_rect + object_rect)): tutorial_str = "방향키로 날 움직여봐!" elif object.name == 'Tutorial-1': if collision.rect_in_rect(*(player_rect + object_rect)): tutorial_str = '이제부터 블록이 점점 사라질꺼야!' elif object.name == 'Tutorial-2': if collision.rect_in_rect(*(player_rect + object_rect)): tutorial_str = '지형물이 있는 블록은 사라지지 않아!' elif object.name == 'Tutorial-2-1': if collision.rect_in_rect(*(player_rect + object_rect)): tutorial_str = '지형물을 잘 이용하면 좋을거 같애!' elif object.name == 'Tutorial-3': if collision.rect_in_rect(*(player_rect + object_rect)): tutorial_str = '회색 블록까지 가보자!' elif object.name == 'Tutorial-4': if collision.rect_in_rect(*(player_rect + object_rect)): tutorial_str = '회색 블록에 가면 순간이동해!' elif object.name == 'Tutorial-5': if collision.rect_in_rect(*(player_rect + object_rect)): tutorial_str = '몬스터다! 부딪히지않게 조심해!' cubchoo_respone_start = True elif object.name == 'Tutorial-6': if collision.rect_in_rect(*(player_rect + object_rect)): tutorial_str = '몬스터를 만나면, 방향키로 연타해서 밀어버리자!' elif object.name == 'Tutorial-7': if collision.rect_in_rect(*(player_rect + object_rect)): tutorial_str = '날아다니는 몬스터를 피해서 지나가자!' elif object.name == 'Tutorial-8': if collision.rect_in_rect(*(player_rect + object_rect)): tutorial_str = '얼른 집으로 가자!'
def collision_trigger_and_player(): for object in map.trigger_layer.objects: object_rect = map.to_object_rect(object) player_rect = finn.to_rect() if object.name == 'Warp-A': if collision.rect_in_rect(*(player_rect + object_rect)): effects.add_effect(warp_effect.WarpEffect(finn.x, finn.y)) warp = map.to_trigger('Warp-B') warp_rect = map.to_object_rect(warp) effects.add_effect(warp_effect.WarpEffect(warp_rect[0], warp_rect[1])) finn.x, finn.y = warp_rect[0], warp_rect[1] warp_effect.WarpEffect.sound.play() elif object.name == 'Warp-C': if collision.rect_in_rect(*(player_rect + object_rect)): effects.add_effect(warp_effect.WarpEffect(finn.x, finn.y)) warp = map.to_trigger('Warp-D') warp_rect = map.to_object_rect(warp) effects.add_effect(warp_effect.WarpEffect(warp_rect[0], warp_rect[1])) finn.x, finn.y = warp_rect[0], warp_rect[1] warp_effect.WarpEffect.sound.play() elif object.name == 'Warp-E': if collision.rect_in_rect(*(player_rect + object_rect)): effects.add_effect(warp_effect.WarpEffect(finn.x, finn.y)) warp = map.to_trigger('Warp-F') warp_rect = map.to_object_rect(warp) effects.add_effect(warp_effect.WarpEffect(warp_rect[0], warp_rect[1])) finn.x, finn.y = warp_rect[0], warp_rect[1] warp_effect.WarpEffect.sound.play() elif object.name == 'Warp-G': if collision.rect_in_rect(*(player_rect + object_rect)): effects.add_effect(warp_effect.WarpEffect(finn.x, finn.y)) warp = map.to_trigger('Warp-I') warp_rect = map.to_object_rect(warp) effects.add_effect(warp_effect.WarpEffect(warp_rect[0], warp_rect[1])) finn.x, finn.y = warp_rect[0], warp_rect[1] warp_effect.WarpEffect.sound.play() elif object.name == 'Warp-J': if collision.rect_in_rect(*(player_rect + object_rect)): effects.add_effect(warp_effect.WarpEffect(finn.x, finn.y)) warp = map.to_trigger('Warp-K') warp_rect = map.to_object_rect(warp) effects.add_effect(warp_effect.WarpEffect(warp_rect[0], warp_rect[1])) finn.x, finn.y = warp_rect[0], warp_rect[1] warp_effect.WarpEffect.sound.play() elif object.name == 'Warp-L': if collision.rect_in_rect(*(player_rect + object_rect)): effects.add_effect(warp_effect.WarpEffect(finn.x, finn.y)) warp = map.to_trigger('Warp-F') warp_rect = map.to_object_rect(warp) effects.add_effect(warp_effect.WarpEffect(warp_rect[0], warp_rect[1])) finn.x, finn.y = warp_rect[0], warp_rect[1] warp_effect.WarpEffect.sound.play() elif object.name == 'Warp-M': if collision.rect_in_rect(*(player_rect + object_rect)): effects.add_effect(warp_effect.WarpEffect(finn.x, finn.y)) warp = map.to_trigger('Warp-N') warp_rect = map.to_object_rect(warp) effects.add_effect(warp_effect.WarpEffect(warp_rect[0], warp_rect[1])) finn.x, finn.y = warp_rect[0], warp_rect[1] warp_effect.WarpEffect.sound.play() elif object.name == 'Home': if collision.rect_in_rect(*(player_rect + object_rect)): global game_play, game_clear game_play = False game_clear = True background_music.stop() game_clear_music.repeat_play()