当前位置: 首页>>代码示例>>Python>>正文


Python GameState.add_animation方法代码示例

本文整理汇总了Python中GameState.add_animation方法的典型用法代码示例。如果您正苦于以下问题:Python GameState.add_animation方法的具体用法?Python GameState.add_animation怎么用?Python GameState.add_animation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameState的用法示例。


在下文中一共展示了GameState.add_animation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: explosive_death

# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import add_animation [as 别名]
def explosive_death(monster):
    # transform it into a nasty corpse! it doesn't block, can't be
    # attacked and doesn't move
    # TODO: String build this message more inteligently
    Utils.message('The ' + monster.name + ' EXPLODES!!!!! You gain ' + str(monster.fighter.xp) + ' experience points.',
                  libtcod.orange)
    monster.char = ' '
    monster.color = None
    monster.blocks = False
    monster.fighter = None
    monster.ai = None
    monster.name = ''
    GameState.schedule.release(monster)

    animation_params = {}
    animation_params['origin'] = (monster.x, monster.y)
    animation_params['target'] = (monster.x, monster.y)
    GameState.add_animation('Burst', animation_params)

    # TODO: Damage surrounding things.....

    ranged_component = Ranged(0, aoe=3)
    # TODO: BORKED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    UI.target_mode(monster, target=monster.pos, ranged_componenet=ranged_component)

    monster.send_to_back()
开发者ID:joekane,项目名称:DeepFriedSuperNova,代码行数:28,代码来源:Components.py

示例2: process_mouse_clicks

# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import add_animation [as 别名]
    def process_mouse_clicks(self, mouse):
        (map_x, map_y) = Utils.to_map_coordinates(mouse.cx, mouse.cy)
        if map_x is not None and map_y is not None:
            # walk to target tile

            if mouse.lbutton_pressed and GameState.continue_walking:
                GameState.continue_walking = False
                self.owner.clear_path()
                return 0
            if mouse.lbutton_pressed and GameState.current_level.is_explored(map_x, map_y):
                self.owner.clear_path()
                GameState.continue_walking = self.owner.move_astar_xy(map_x, map_y, True)
                return self.end_turn(Constants.TURN_COST)
            if mouse.rbutton_pressed:
                GameState.continue_walking = False
                self.owner.clear_path()
                GameState.current_level.require_recompute()

                animation_params = {}
                animation_params['origin'] = (self.owner.x, self.owner.y)
                animation_params['target'] = (self.owner.x, self.owner.y)
                animation_params['target_angle'] = 0
                GameState.add_animation('Teleport', animation_params)

                self.owner.x, self.owner.y = Utils.to_map_coordinates(mouse.cx, mouse.cy)

                animation_params = {}
                animation_params['origin'] = (self.owner.x, self.owner.y)
                animation_params['target'] = (self.owner.x, self.owner.y)
                animation_params['target_angle'] = 0
                GameState.add_animation('Teleport', animation_params)

                return 1
        return 0
开发者ID:joekane,项目名称:DeepFriedSuperNova,代码行数:36,代码来源:Components.py

示例3: play_animation

# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import add_animation [as 别名]
    def play_animation(self, animation_name, source, target_x, target_y):
        animation_params = {}
        animation_params['origin'] = (source.x, source.y)
        animation_params['target'] = (target_x, target_y)
        animation_params['target_angle'] = Utils.get_angle(source.x, source.y, target_x, target_y)

        GameState.add_animation(animation_name, animation_params)
开发者ID:joekane,项目名称:DeepFriedSuperNova,代码行数:9,代码来源:Components.py

示例4: take_turn

# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import add_animation [as 别名]

#.........这里部分代码省略.........

            # TODO: Make movement cost relative to terrain. (add terrain cost to TILE)  WATER / TAR / OIL / SAND = Slower, Road / Trail = Fsater
            # TODO: Make turns not pass as you bumb into walls.

            # TODO: Add 'Auto-Explore' --- Search for Not self.Explored, path to it as if you right clicked.

            if key == terminal.TK_KP_8 or key == terminal.TK_UP:
                GameState.player_move_or_interact(0, -1)
                return self.end_turn(Constants.TURN_COST)
            elif key == terminal.TK_KP_2 or key == terminal.TK_DOWN:
                GameState.player_move_or_interact(0, 1)
                return self.end_turn(Constants.TURN_COST)
            elif key == terminal.TK_KP_4 or key == terminal.TK_LEFT:
                GameState.player_move_or_interact(-1, 0)
                return self.end_turn(Constants.TURN_COST)
            elif key == terminal.TK_KP_6 or key == terminal.TK_RIGHT:
                GameState.player_move_or_interact(1, 0)
                return self.end_turn(Constants.TURN_COST)
            elif key == terminal.TK_KP_7: # or (terminal.TK_LEFT and terminal.TK_UP):
                GameState.player_move_or_interact(-1, -1)
                return self.end_turn(Constants.TURN_COST)
            elif key == terminal.TK_KP_9:
                GameState.player_move_or_interact(1, -1)
                return self.end_turn(Constants.TURN_COST)
            elif key == terminal.TK_KP_1:
                GameState.player_move_or_interact(-1, 1)
                return self.end_turn(Constants.TURN_COST)
            elif key == terminal.TK_KP_3:
                GameState.player_move_or_interact(1, 1)
                return self.end_turn(Constants.TURN_COST)
            elif key == terminal.TK_KP_5:
                return self.end_turn(Constants.TURN_COST)
            elif key == terminal.TK_X:
                GameState.current_level.require_recompute()
                Constants.DEBUG = not Constants.DEBUG
                GameState.render_all()
            elif key == terminal.TK_G:
                # pick up an item
                for object in GameState.current_level.get_all_objects():  # look for an item in the player's tile
                    if object.x == self.owner.x and object.y == self.owner.y and object.item:
                        object.item.pick_up()
                        break
            elif key == terminal.TK_F:
                for obj in GameState.get_all_equipped(self.owner):
                    if obj.owner.ranged:
                        outcome = obj.owner.ranged.fire()
                        if outcome == 'cancelled':
                            return 0
                        else:
                            return self.end_turn(Constants.TURN_COST)
            elif key == terminal.TK_B:
                title = "Beastiary"

                text = '\n\nDrag Header to move window\n\n'

                pal = UI.Palette(width=20, height=20, title='Title', text=text)

                pal.draw()
            elif key == terminal.TK_COMMA and terminal.check(terminal.TK_SHIFT):
                # go down stairs, if the player is on them
                stairs = GameState.current_level.get_stairs()
                if stairs.x == self.owner.x and stairs.y == self.owner.y:
                    GameState.next_level()
                    return 1
            elif key == terminal.TK_ESCAPE:
                GameState.save_game()
                UI.display_mainMenu()
            elif key == terminal.TK_L:
                GameState.load_game()
                return 1
            elif key == terminal.TK_T:
                GameState.add_animation('FadeText', {'origin': (self.owner.x, self.owner.y),
                                                     'target': (self.owner.x, self.owner.y-1)})

            elif key == terminal.TK_O:
                print GameState.current_level.fov_map
            elif key == terminal.TK_RBRACKET:
                equipped_ranged = [equip.name for equip in GameState.inventory if equip.equipment.is_equipped and equip.ranged]

                if equipped_ranged[0] == "pistol":
                    new_weapon = [equip for equip in GameState.inventory if
                                       equip.name == 'laser']
                    new_weapon[0].equipment.equip()
                elif equipped_ranged[0] == "laser":
                    new_weapon = [equip for equip in GameState.inventory if
                                  equip.name == 'rpg']
                    new_weapon[0].equipment.equip()
                elif equipped_ranged[0] == "rpg":
                    new_weapon = [equip for equip in GameState.inventory if
                                  equip.name == 'ice wand']
                    new_weapon[0].equipment.equip()
                elif equipped_ranged[0] == "ice wand":
                    new_weapon = [equip for equip in GameState.inventory if
                                  equip.name == 'pistol']
                    new_weapon[0].equipment.equip()

            elif key == terminal.TK_LBRACKET:
                pass

                '''
开发者ID:joekane,项目名称:DeepFriedSuperNova,代码行数:104,代码来源:Components.py

示例5: target_mode

# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import add_animation [as 别名]

#.........这里部分代码省略.........
                             bk_color=terminal.color_from_name('transparent'),
                             title="Targeting Mode - Right Click/ESC to Cancel")
            # """

            ''' Get Inputs '''
            Input.update()
            key = Input.key

            ''' determine if mouse moved, otherwise use auto-target '''
            if mouse.cx != mouse_last_x or mouse.cy != mouse_last_y:
                mouse_moved = True
                moues_last_x, mouse_last_y = mouse.cx, mouse.cy
            if mouse_moved:
                target_x, target_y = Utils.to_map_coordinates(mouse.cx, mouse.cy)
            elif target:
                target_x, target_y = target.x, target.y
            else:
                target_x, target_y = source.x, source.y

            ''' determine line of fire (You may not be able to hit every enemy you see) '''
            line = Utils.get_line((source.x, source.y),
                                  (target_x, target_y),
                                  walkable=True,
                                  ignore_mobs=True,
                                  max_length=ranged_componenet.max_range)
            for point in line:
                if point == (None, None):
                    break
                point = Utils.to_camera_coordinates(point[0], point[1])
                #libtcod.console_set_char_background(0, point[0], point[1], libtcod.lighter_blue, libtcod.BKGND_SET)
                Render.draw_char(layers['overlay_console'], point[0], point[1], 0x2588, terminal.color_from_argb(128, 64, 64, 255))

            if len(line) > 0:
                index = Utils.find_element_in_list((None, None), line)

                if index is None:
                    point = line[-1]
                else:
                    point = line[index - 1]

                circle = Utils.get_circle_points(point[0], point[1], ranged_componenet.aoe)
                if circle:
                    tile_effected = set(circle)

                    for points in circle:
                        points = Utils.to_camera_coordinates(points[0], points[1])
                        Render.draw_char(layers['overlay_console'], points[0], points[1], 0x2588, terminal.color_from_argb(128, 200, 32, 32))
                        Render.draw_char(layers['overlay_console'], points[0], points[1], 0xE000, terminal.color_from_argb(128, 255, 0, 0))

            if mouse.lbutton_pressed or key == terminal.TK_SPACE:
                # target_tile = (target_x, target_y)
                # print tile_effected
                for target in tile_effected:
                    # target = Map.to_map_coordinates(target[0], target[1])
                    monster = GameState.current_level.get_monster_at((target[0], target[1]))
                    if monster is not None:
                        print "Monster: " + str(monster) + " at " + str(target)
                        targets.append(monster)
                break

            if mouse.rbutton_pressed or key == terminal.TK_ESCAPE:
                break

            if key == terminal.TK_F:
                if target_list:
                    target = next(target_list)[0]

            GameState.render_ui()

        if not targets:  # no enemy found within maximum range
            Utils.message('Cancelled.', Color('red'))
            Render.clear_layer(layers['overlay_console'])
            return 'cancelled'
        else:
            targets = GameState.current_level.get_monsters_in_range_at(target, ranged_componenet.aoe)
    Render.clear_layer(layers['overlay_console'])

    # TODO: Allow targeting Empty tiles

    # zap it!
    if ranged_componenet.animation:
        ranged_componenet.animation_params['origin'] = (source.x, source.y)
        ranged_componenet.animation_params['target'] = (target_x, target_y)
        ranged_componenet.animation_params['target_angle'] = Utils.get_angle(source.x, source.y, target_x, target_y)

        GameState.add_animation(ranged_componenet.animation, ranged_componenet.animation_params)

    for target in targets:
        if target.fighter:
            # TODO: Combat should handle all messages......

            Utils.message('[color={1}]{2} [color={0}]takes [color={3}]{4} damage[color={0}].'
                          ''.format(Constants.COMBAT_MESSAGE_DEFAULT_COLOR,
                                    Constants.COMBAT_MESSAGE_MONSTER_NAME_COLOR,
                                    target.name,
                                    Constants.COMBAT_MESSAGE_DAMAGE_COLOR,
                                    ranged_componenet.owner.equipment.power_bonus))
            target.fighter.take_damage(ranged_componenet.owner.equipment.power_bonus)
    Render.clear_layer(5)
    return 'fired'
开发者ID:joekane,项目名称:DeepFriedSuperNova,代码行数:104,代码来源:UI.py


注:本文中的GameState.add_animation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。