當前位置: 首頁>>代碼示例>>Python>>正文


Python GUI.message方法代碼示例

本文整理匯總了Python中GUI.message方法的典型用法代碼示例。如果您正苦於以下問題:Python GUI.message方法的具體用法?Python GUI.message怎麽用?Python GUI.message使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在GUI的用法示例。


在下文中一共展示了GUI.message方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: new_game

# 需要導入模塊: import GUI [as 別名]
# 或者: from GUI import message [as 別名]
def new_game():
    global player, inventory, game_msgs, game_state, dungeon_level

    #create object representing the player
    entity_component = Entity(5)
    GameState.player = Object(0, 0, '@', 'player', libtcod.white, blocks=True, entity=entity_component)

    GameState.player.level = 1

    #generate map (at this point it's not drawn to the screen)
    dungeon_level = 1
    Map.make_map()
    initialize_fov()

    game_state = 'playing'
    GameState.inventory = []

    #create the list of game messages and their colors, starts empty
    GameState.game_msgs = []

    #a warm welcoming message!
    GUI.message('Welcome stranger! Prepare to perish in the Tombs of the Ancient Kings.', libtcod.red)

    #initial equipment: a dagger
    equipment_component = Equipment(slot='right hand', power_bonus=2)
    obj = Object(0, 0, '-', 'dagger', libtcod.sky, equipment=equipment_component)
    GameState.inventory.append(obj)
    equipment_component.equip()
    obj.always_visible = True
開發者ID:edrobot,項目名稱:PythonRoguelike_Spring-2014,代碼行數:31,代碼來源:GameFlow.py

示例2: use

# 需要導入模塊: import GUI [as 別名]
# 或者: from GUI import message [as 別名]
 def use(self):
     if self.owner.equipment:
         self.owner.equipment.toggle_equip()
         return
     if(self.use_function != None):
         self.use_function()
     else:
         GUI.message("That doesn't do anything (yet)")
開發者ID:edrobot,項目名稱:PythonRoguelike_Spring-2014,代碼行數:10,代碼來源:Items.py

示例3: equip

# 需要導入模塊: import GUI [as 別名]
# 或者: from GUI import message [as 別名]
    def equip(self):
        #if the slot is already being used, dequip whatever is there first
        old_equipment = get_equipped_in_slot(self.slot)
        if old_equipment is not None:
            old_equipment.dequip()

        #equip object and show a message about it
        self.is_equipped = True
        GUI.message('Equipped ' + self.owner.name + ' on ' + self.slot + '.', libtcod.light_green)
開發者ID:edrobot,項目名稱:PythonRoguelike_Spring-2014,代碼行數:11,代碼來源:Equipment.py

示例4: Pick_Up

# 需要導入模塊: import GUI [as 別名]
# 或者: from GUI import message [as 別名]
 def Pick_Up(self,obj):
     if(len(self.owner.inventory) < 26):
         if(obj.item != None):
             obj.owner = self
             self.owner.inventory.append(obj)
             if(obj in GameState.objects):
                GameState.objects.remove(obj)
         else:
             raise NotAnItemException(obj.name +" is not an Item!")
     else:
         GUI.message("Your inventory is full!")
開發者ID:edrobot,項目名稱:PythonRoguelike_Spring-2014,代碼行數:13,代碼來源:Entity.py

示例5: die

# 需要導入模塊: import GUI [as 別名]
# 或者: from GUI import message [as 別名]
 def die(self):
     GUI.message(self.owner.name + " died!")
     self.owner.clearPath()
     GameState.objects.remove(self.owner)
     GameState.objects.insert(0,self.owner)
     self.owner.char = "%"
     self.owner.blocks = False
     self.owner.ai = None
     self.owner.entity = None
     if self == GameState.player.entity:
         GUI.message(self.owner.name + " died!")
         print "Game Over"
         sys.exit()
開發者ID:edrobot,項目名稱:PythonRoguelike_Spring-2014,代碼行數:15,代碼來源:Entity.py

示例6: next_level

# 需要導入模塊: import GUI [as 別名]
# 或者: from GUI import message [as 別名]
def next_level():
    #advance to the next level
    #global dungeon_level
    GUI.message('You take a moment to rest, and recover your strength.', libtcod.light_violet)
    #TODO: Make Fighter Component
    #GameState.player.fighter.heal(player.fighter.max_hp / 2)  #heal the player by 50%

    #dungeon_level += 1
    GUI.message('After a rare moment of peace, you descend deeper into the heart of the dungeon...', libtcod.red)

    #GameState.dungeon.floors()  #create a fresh new level!
    newFloor = Map.Floor()
    newFloor.make_map()
    GameState.dungeon.floors.append(newFloor)
    GameState.player.floor = newFloor
    initialize_fov()
開發者ID:edrobot,項目名稱:PythonRoguelike_Spring-2014,代碼行數:18,代碼來源:GameFlow.py

示例7: equip

# 需要導入模塊: import GUI [as 別名]
# 或者: from GUI import message [as 別名]
    def equip(self, equipPart = None):
        if (equipPart != None):
            if (isinstance(equipPart, self.slot) and equipPart.currentItem == None):
                equipPart.currentItem = self
                self.currentEquipptedPart = equipPart
                self.is_equipped = True
                GUI.message("You equippted something!")
                return True
            return False
        else:
            x = BodyParts.Part()

            for x in self.owner.owner.parts:
                if isinstance(x, BodyParts.Part):
                    if (isinstance(x, self.slot) and x.currentItem == None):
                        return self.equip(x)
            return False
開發者ID:edrobot,項目名稱:PythonRoguelike_Spring-2014,代碼行數:19,代碼來源:Equipment.py

示例8: unequip

# 需要導入模塊: import GUI [as 別名]
# 或者: from GUI import message [as 別名]
 def unequip(self):
     if(self.currentEquipptedPart != None):
         self.currentEquipptedPart.currentItem = None
         self.currentEquipptedPart = None
     self.is_equipped = False
     GUI.message("You unequippted something!")
開發者ID:edrobot,項目名稱:PythonRoguelike_Spring-2014,代碼行數:8,代碼來源:Equipment.py

示例9: melee_attack_entity

# 需要導入模塊: import GUI [as 別名]
# 或者: from GUI import message [as 別名]
    def melee_attack_entity(self, target):
        AttackingWeapons = []
        DefendingArmor = []

        AttackingTypes = []
        DefendingResistances = []

        x = BodyParts.Part()

        for x in self.parts:
            if (isinstance(x,BodyParts.Part)):
                if isinstance(x.currentItem, Equipment.Weapon):
                    AttackingWeapons.append(x.currentItem)

        for x in target.parts:
            if (isinstance(x,BodyParts.Part)):
                if isinstance(BodyParts.Part.currentItem, Equipment.Armor):
                    DefendingArmor.append(x.currentItem)

        """
        if(len(AttackingWeapons) > 0):
            AttackingTypes = [atk for elem in [r for r in [x.attackType for x in AttackingWeapons]] for atk in elem]
        else:
            AttackingTypes = self.unarmedAttackType
        """

        DefendingResistances = [res for elem in [r for r in [x.resistances for x in DefendingArmor]] for res in elem] + target.resistances

        damage = 0
        totalDamage = 0

        totalDefense = 0
        totalDeflectRank = 0
        totalResistanceRank = 0

        arm = Equipment.Armor()

        for arm in DefendingArmor:
            totalDefense += arm.baseDefense

        wep = Equipment.Weapon()
        #Attack with all weapons
        if(len(AttackingWeapons) > 0):
            for wep in AttackingWeapons:
                if(isinstance(wep,Equipment.Weapon)):
                    """
                    Normal Hit:
                    (Dexterity) + BaseHit + 1d100 > (EnemyDexterity + 50) * (1 * DEFLECTION_RANK) + 100
                    > (EnemyDexterity + 50) * (1 * DEFLECTION_RANK)
                    """
                    attackerHit = self.dexterity + wep.baseAttack + random.randrange(1,100)
                    enemyDefence = (target.dexterity + 50.0) * (1.0)

                    #Todo: Implement Weapon Proficency Feats
                    #Todo: Implement Weapon Deflection

                    """
                    Normal Damage:
                    ((STR_RANK*Strength + DEX_RANK*Dexterity) + BaseDamage
                    - MinimumZero(EnemyDefense - Penetration)) * (1 * RESISTANCE_RANK)
                    """

                    if(attackerHit > enemyDefence):
                        tempDamage = (wep.baseDamage + (self.strength * Equipment.StatisticScaleingRank.Get_Rank() + \
                                                                self.dexterity * Equipment.StatisticScaleingRank.Get_Rank()) - \
                                                                (totalDefense))
                        if tempDamage <= 0:
                            tempDamage = 1

                        damage += tempDamage

                        GUI.message(self.owner.name + " attacked " + target.owner.name + " for " + str(int(tempDamage)) + " damage!")
                    else:
                        GUI.message(self.owner.name + " missed the " + target.owner.name + "!")

        #Unarmed Attack
        else:
            attackerHit = self.dexterity + random.randrange(1,100)
            enemyDefence = (target.dexterity + 50.0) * (1.0)

            if(attackerHit > enemyDefence):
                tempDamage = self.strength

                if tempDamage <= 0:
                        tempDamage = 1

                damage += tempDamage
                GUI.message(self.owner.name + " attacked " + target.owner.name + " for " + str(int(tempDamage)) + " damage!")

            else:
                GUI.message(self.owner.name + " missed the " + target.owner.name + "!")

        target.hitPoints -= int(damage)

        if(damage > 0):
            GUI.message(str(int(damage)) + " total!")

        if(target.hitPoints < 0):
            target.die()
        return
開發者ID:edrobot,項目名稱:PythonRoguelike_Spring-2014,代碼行數:102,代碼來源:Entity.py

示例10: handle_keys

# 需要導入模塊: import GUI [as 別名]
# 或者: from GUI import message [as 別名]
def handle_keys():
    global key

    if GameState.game_state == 'playing':
        #movement keys
        if GameState.key.vk == libtcod.KEY_UP or GameState.key.vk == libtcod.KEY_KP8:
            player_move_or_attack(0, -1)
        elif GameState.key.vk == libtcod.KEY_DOWN or GameState.key.vk == libtcod.KEY_KP2:
            player_move_or_attack(0, 1)
        elif GameState.key.vk == libtcod.KEY_LEFT or GameState.key.vk == libtcod.KEY_KP4:
            player_move_or_attack(-1, 0)
        elif GameState.key.vk == libtcod.KEY_RIGHT or GameState.key.vk == libtcod.KEY_KP6:
            player_move_or_attack(1, 0)
        elif GameState.key.vk == libtcod.KEY_HOME or GameState.key.vk == libtcod.KEY_KP7:
            player_move_or_attack(-1, -1)
        elif GameState.key.vk == libtcod.KEY_PAGEUP or GameState.key.vk == libtcod.KEY_KP9:
            player_move_or_attack(1, -1)
        elif GameState.key.vk == libtcod.KEY_END or GameState.key.vk == libtcod.KEY_KP1:
            player_move_or_attack(-1, 1)
        elif GameState.key.vk == libtcod.KEY_PAGEDOWN or GameState.key.vk == libtcod.KEY_KP3:
            player_move_or_attack(1, 1)
        elif GameState.key.vk == libtcod.KEY_KP5 or GameState.key.vk == '.':
            pass  #do nothing ie wait for the monster to come to you
        else:
            #test for other keys
            key_char = chr(GameState.key.c)

            if key_char == 'g':
                #pick up an item
                for object in GameState.objects:  #look for an item in the player's tile
                    if object.x == GameState.player.x and object.y == GameState.player.y and GameState.player.floor == object.floor and object.item:
                        GameState.player.entity.Pick_Up(object)
                        break

            if key_char == 'f':
                #(F)ire your weapon.
                AttackingWeapons = []
                DefendingArmor = []

                AttackingTypes = []
                DefendingResistances = []

                x = BodyParts.Part()
                y = Equipment.RangedWeapon()

                for x in GameState.player.entity.parts:
                    if (isinstance(x,BodyParts.Part)):
                        y = x.currentItem
                        if isinstance(y, Equipment.RangedWeapon):
                            AttackingWeapons.append(x.currentItem)
                if len(AttackingWeapons) > 0:
                    GUI.message("Select a target to attack.")
                    target = target_monster(AttackingWeapons[0].weapon_Range)
                    if target != None:
                        GameState.player.entity.melee_attack_entity(target.entity)
                        GameState.player.move(0, 0)
                        GameState.fov_recompute = True
                else:
                    GUI.message("Cancelled")


            if key_char == 'i':
                #show the inventory; if an item is selected, use it
                chosen_item = GUI.inventory_menu('Press the key next to an item to use it, or any other to cancel.\n')
                if chosen_item is not None:
                    chosen_item.use()

            if key_char == 'd':
                #show the inventory; if an item is selected, drop it
                chosen_item = GUI.inventory_menu('Press the key next to an item to drop it, or any other to cancel.\n')
                if chosen_item is not None:
                    chosen_item.drop()

            if key_char == 'c':
                #show character information
                level_up_xp = cfg.LEVEL_UP_BASE + GameState.player.level * cfg.LEVEL_UP_FACTOR
                msgbox('Character Information\n\nLevel: ' + str(player.level) + '\nExperience: ' + str(GameState.player.fighter.xp) +
                       '\nExperience to level up: ' + str(level_up_xp) + '\n\nMaximum HP: ' + str(GameState.player.fighter.max_hp) +
                       '\nAttack: ' + str(GameState.player.fighter.power) + '\nDefense: ' + str(GameState.player.fighter.defense), cfg.CHARACTER_SCREEN_WIDTH)

            if key_char == '<':
                #go down stairs, if the player is on them
                if GameState.stairs.x == GameState.player.x and GameState.stairs.y == GameState.player.y:
                    next_level()

            return 'didnt-take-turn'
開發者ID:edrobot,項目名稱:PythonRoguelike_Spring-2014,代碼行數:88,代碼來源:GameFlow.py


注:本文中的GUI.message方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。