本文整理汇总了Python中Player.getPosition方法的典型用法代码示例。如果您正苦于以下问题:Python Player.getPosition方法的具体用法?Python Player.getPosition怎么用?Python Player.getPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player.getPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pickList
# 需要导入模块: import Player [as 别名]
# 或者: from Player import getPosition [as 别名]
def pickList(): #Renvoie la liste des objets ramassables
global items, pick
items = Map.isItem(Player.getPosition())
if Map.isMonster(Player.getPosition()) == 0 :
if items == 0:
return "Il n'y a pas d'objets dans cette zone."
elif Player.isItem() == 6:
return "Vous n'avez plus de place dans votre inventaire."
else:
pick = 1
return "Quel objet voulez-vous ramasser? (Tapez le numero correspondant) ~~~~~~~~~~~~~~~~~~~~~~~~~~ " + Map.getItemList(Player.getPosition())
else :
return "Ramasser un objet qu'un adversaire garde n'est jamais une bonne idee. "
示例2: pickList
# 需要导入模块: import Player [as 别名]
# 或者: from Player import getPosition [as 别名]
def pickList(): #Renvoie la liste des objets ramassables
global items, pick
items = Map.isItem(Player.getPosition())
if Map.isMonster(Player.getPosition()) == 0 :
if items == 0:
return "There aren't any items in this area."
elif Player.isItem() == 6:
return "Your inventory is already full."
else:
pick = 1
return "Which item do you want to pick up? (Type in the corresponding number) ~~~~~~~~~~~~~~~~~~~~~~~~~~ " + Map.getItemList(Player.getPosition())
else :
return "Trying to take an items guarded by an opponent is never a clever idea. "
示例3: move
# 需要导入模块: import Player [as 别名]
# 或者: from Player import getPosition [as 别名]
def move(direction): # Deplace le joueur si possible
flee = random.randint(1,6)
if Map.isMonster(Player.getPosition()) == 0 or flee == 6:
answer = Map.check(Player.getPosition(),direction)
if answer == 0:
return 'Il y a un mur dans cette direction'
elif answer == 1 :
Player.move(direction)
Player.editTime(10)
return Map.getDescript(Player.getPosition())
else :
win()
exitGame()
else:
Player.editHealth(-1)
Player.editTime(1)
return "Votre adversaire vous attrappe par le col et frappe a l'estomac. Battez-vous que diable!"
示例4: move
# 需要导入模块: import Player [as 别名]
# 或者: from Player import getPosition [as 别名]
def move(direction): # Deplace le joueur si possible
flee = random.randint(1,6)
if Map.isMonster(Player.getPosition()) == 0 or flee == 6:
answer = Map.check(Player.getPosition(),direction)
if answer == 0:
return "You can't go this way. Unless, of course, you can walk through walls!"
elif answer == 1 :
Player.move(direction)
Player.editTime(10)
return Map.getDescript(Player.getPosition())
else :
win()
exitGame()
else:
Player.editHealth(-1)
Player.editTime(1)
return "Votre adversaire vous attrappe par le col et frappe a l'estomac. Battez-vous que diable!"
示例5: pickList
# 需要导入模块: import Player [as 别名]
# 或者: from Player import getPosition [as 别名]
def pickList(): #Renvoie la liste des objets ramassables
global items, pick
items = Map.isItem(Player.getPosition())
if items == 0:
return "Il n'y a pas d'objets dans cette zone."
elif Player.isItem() == 6:
return "Vous n'avez plus de place dans votre inventaire."
else:
pick = 1
return "Quel objet voulez-vous ramasser? (Tapez le numero correspondant) ~~~~~~~~~~~~~~~~~~~~~~~~~~ " + Map.getItemList(Player.getPosition())
示例6: attack
# 需要导入模块: import Player [as 别名]
# 或者: from Player import getPosition [as 别名]
def attack(): #Gestion du combat
if Map.isMonster(Player.getPosition()) == 0:
descript = "Qui voulez-vous attaquer dites-moi? Les murs?"
else :
playerPow = Player.getPower()
monsterPow = Map.getMonsterPower(Player.getPosition())
player1, player2, monster1, monster2 = random.randint(1,6),random.randint(1,6),random.randint(1,6),random.randint(1,6)
if Player.isEquip() == 1:
equipPow = Player.getEquipModifier()
else:
equipPow = 0
descript = "Vous chargez tous les deux."
if playerPow+player1+player2+equipPow >= monsterPow+monster1+monster2:
Map.editMonsterHealth(Player.getPosition(),-2)
descript += "Vous blessez votre adversaire."
else:
if random.randint(1,6) == 6:
Player.editHealth(-2)
else:
Player.editHealth(-1)
descript += "Votre adversaire vous blesse. "
if Map.getMonsterHealth(Player.getPosition()) <= 0:
descript += "CE coup lui est fatal. Son corps tombe tel un pantin desarticule et, quelques secondes plus tard, il se desintegre."
Player.editXp(Map.getMonsterXp(Player.getPosition()))
Map.removeMonster(Player.getPosition())
Player.editTime(1)
return descript
示例7: attack
# 需要导入模块: import Player [as 别名]
# 或者: from Player import getPosition [as 别名]
def attack(): #Gestion du combat
if Map.isMonster(Player.getPosition()) == 0:
descript = "Tell me, who are you trying to fight? The walls perhaps?"
else :
playerPow = Player.getPower()
monsterPow = Map.getMonsterPower(Player.getPosition())
player1, player2, monster1, monster2 = random.randint(1,6),random.randint(1,6),random.randint(1,6),random.randint(1,6)
if Player.isEquip() == 1:
equipPow = Player.getEquipModifier()
else:
equipPow = 0
descript = "You both charge at the other."
if playerPow+player1+player2+equipPow >= monsterPow+monster1+monster2:
Map.editMonsterHealth(Player.getPosition(),-2)
descript += "You hit your opponent."
else:
if random.randint(1,6) == 6:
Player.editHealth(-2)
else :
Player.editHealth(-1)
descript += "Your opponent hits you. "
if Map.getMonsterHealth(Player.getPosition()) <= 0:
descript += "THIS blow is deadly. It's body falls like a ragdoll and, a few seconds later, it disintegrates."
Player.editXp(Map.getMonsterXp(Player.getPosition()))
Map.removeMonster(Player.getPosition())
Player.editTime(1)
return descript
示例8: move
# 需要导入模块: import Player [as 别名]
# 或者: from Player import getPosition [as 别名]
def move(direction): # Deplace le joueur si possible
global visited
flee = random.randint(1,6)
if Map.isMonster(Player.getPosition()) == 0 or flee == 6:
answer = Map.check(Player.getPosition(),direction)
if answer == 0:
return 'There is a wall in this direction.'
elif answer == 1 :
Player.move(direction)
Player.editTime(10)
if Map.getVisited(Player.getPosition()) == 0:
Map.setMonster(Player.getPosition(),Player.getLevel())
Map.setVisited(Player.getPosition())
visited += 1
return Map.getDescript(Player.getPosition())
else :
win()
exitGame()
else:
Player.editHealth(-1)
Player.editTime(1)
return "You opponent pulls you by the collar and punches you in the stomach. Fight for heaven's sake!"
示例9: getAction
# 需要导入模块: import Player [as 别名]
# 或者: from Player import getPosition [as 别名]
def getAction(): # Traite les interactions clavier
global items, pick, throw, use
key = 0
while 1:
if isInput():
key = sys.stdin.read(1)
if key == '1' :
if int(key) > items:
return "Cet objet n'existe pas!"
elif pick == 1:
return pickItem(Player.getPosition(),0)
elif throw == 1:
return throwItem(Player.getPosition(),0)
elif use == 1:
return useItem(0)
elif key == '2' :
if int(key) > items:
return "Cet objet n'existe pas!"
elif pick == 1:
return pickItem(Player.getPosition(),1)
elif throw == 1:
return throwItem(Player.getPosition(),1)
elif use == 1:
return useItem(1)
elif key == '3' :
if int(key) > items:
return "Cet objet n'existe pas!"
elif pick == 1:
return pickItem(Player.getPosition(),2)
elif throw == 1:
return throwItem(Player.getPosition(),2)
elif use == 1:
return useItem(2)
elif key == '4' :
if int(key) > items:
return "Cet objet n'existe pas!"
elif pick == 1:
return pickItem(Player.getPosition(),3)
elif throw == 1:
return throwItem(Player.getPosition(),3)
elif use == 1:
return useItem(3)
elif key == '5' :
if int(key) > items:
return "Cet objet n'existe pas!"
elif pick == 1:
return pickItem(Player.getPosition(),4)
elif throw == 1:
return throwItem(Player.getPosition(),4)
elif use == 1:
return useItem(4)
elif key == '6' :
if int(key) > items:
return "Cet objet n'existe pas!"
elif pick == 1:
return pickItem(Player.getPosition(),5)
elif throw == 1:
return throwItem(Player.getPosition(),5)
elif use == 1:
return useItem(5)
elif key == 'z' :
pick, throw, use = 0,0,0
return move('north')
elif key == 'q' :
pick, throw, use = 0,0,0
return move('west')
elif key == 's' :
pick, throw, use = 0,0,0
return move('south')
elif key == 'd' :
pick, throw, use = 0,0,0
return move('east')
elif key == 'o' :
pick, throw, use = 0,0,0
return altDescript()
elif key == 'r' :
pick, throw, use = 0,0,0
return pickList()
elif key == 'j' :
pick, throw, use = 0,0,0
return throwList()
elif key == 'e' :
pick, throw, use = 0,0,0
return useList()
elif key == 'a' :
pick, throw, use = 0,0,0
return attack()
elif key == '\x1b' :
exitGame()
time.sleep(0.2)
elif key == 'c' :
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, defaultTerminal)
cheat = raw_input("Enter cheat code : ")
tty.setcbreak(sys.stdin.fileno())
if cheat == "doppel":
Map.addDoppel(Player.getPosition())
return "Il y a desormais un Doppelganger devant vous!"
elif cheat == "pepperonipizza":
Player.addItem({"name" : "une Pizza" , "rate" : 9 , "type" : 0 , "Modifier" : 100 , "liste" : "Une Pizza Pepperoni -- "})
return "Une Pizza Pepperoni se materialise dons votre inventaire!"
#.........这里部分代码省略.........
示例10: altDescript
# 需要导入模块: import Player [as 别名]
# 或者: from Player import getPosition [as 别名]
def altDescript(): # Recupere la description avancee de la zone active
return Map.getAltDescript(Player.getPosition())
示例11: descript
# 需要导入模块: import Player [as 别名]
# 或者: from Player import getPosition [as 别名]
def descript(): # Recupere la description de base de la zone active
return Map.getDescript(Player.getPosition())
示例12: getAction
# 需要导入模块: import Player [as 别名]
# 或者: from Player import getPosition [as 别名]
def getAction(): # Traite les interactions clavier
global items, pick, throw, use
while 1:
if isInput():
key = sys.stdin.read(1)
if key == 'w' :
if pick == 1:
return pickItem(Player.getPosition(),0)
elif throw == 1:
return throwItem(Player.getPosition(),0)
elif use == 1:
return useItem(0)
elif key == 'x' :
if pick == 1:
return pickItem(Player.getPosition(),1)
elif throw == 1:
return throwItem(Player.getPosition(),1)
elif use == 1:
return useItem(1)
elif key == 'c' :
if pick == 1:
return pickItem(Player.getPosition(),2)
elif throw == 1:
return throwItem(Player.getPosition(),2)
elif use == 1:
return useItem(2)
elif key == 'v' :
if pick == 1:
return pickItem(Player.getPosition(),3)
elif throw == 1:
return throwItem(Player.getPosition(),3)
elif use == 1:
return useItem(3)
elif key == 'b' :
if pick == 1:
return pickItem(Player.getPosition(),4)
elif throw == 1:
return throwItem(Player.getPosition(),4)
elif use == 1:
return useItem(4)
elif key == 'n' :
if pick == 1:
return pickItem(Player.getPosition(),5)
elif throw == 1:
return throwItem(Player.getPosition(),5)
elif use == 1:
return useItem(5)
elif key == 'z' :
pick, throw, use = 0,0,0
return move('north')
elif key == 'q' :
pick, throw, use = 0,0,0
return move('west')
elif key == 's' :
pick, throw, use = 0,0,0
return move('south')
elif key == 'd' :
pick, throw, use = 0,0,0
return move('east')
elif key == 'o' :
pick, throw, use = 0,0,0
return altDescript()
elif key == 'r' :
pick, throw, use = 0,0,0
return pickList()
elif key == 'j' :
pick, throw, use = 0,0,0
return throwList()
elif key == 'e' :
pick, throw, use = 0,0,0
return useList()
elif key == 'a' :
pick, throw, use = 0,0,0
return attack()
elif key == '\x1b' :
exitGame()
time.sleep(0.2)
示例13: GameScene
# 需要导入模块: import Player [as 别名]
# 或者: from Player import getPosition [as 别名]
class GameScene(Scene):
player = None
bullets = {}
bonuses = {}
players = {}
show_info = False
def __init__(self, username, clientSocket):
self.username = username
self.clientSocket = clientSocket
self.clientSocket.setListener(self.listener)
def playerDelegate(self, player, key):
if key == "HealthBar":
return self.show_info
return True
def listener(self, packet):
self.clientSocket.clientLock()
if isinstance(packet, Packets.RequestGameStatePacket):
w, h = self.getGame().getSize()
self.player = Player(
self.getGame(), [w/2, h/2], Color(255, 255, 255)
)
self.player.setPlayerName(self.username)
self.bullets = {}
self.bonuses = {}
self.players = {}
elif isinstance(packet, Packets.PlayerInfoPacket):
if packet.isMe():
self.player.setHealth(packet.getHealth())
self.player.setDeath(packet.getDeath())
self.player.setRespawnTime(packet.getRespawnTime())
else:
if packet.getPlayerId() not in self.players:
player = Player(self.getGame())
player.setPlayerName(packet.getPlayerName())
self.players[packet.getPlayerId()] = player
else:
player = self.players[packet.getPlayerId()]
player.setDelegate(lambda p, k: self.playerDelegate(p, k))
player.setPosition(packet.getPosition())
player.setVelocity(packet.getVelocity())
player.setAngle(packet.getAngle())
player.setHealth(packet.getHealth())
player.setDeath(packet.getDeath())
player.resetTimeout()
elif isinstance(packet, Packets.BulletInfoPacket):
if packet.getBulletId() not in self.bullets:
bullet = Bullet()
self.bullets[packet.getBulletId()] = bullet
else:
bullet = self.bullets[packet.getBulletId()]
bullet.setPosition(packet.getPosition())
bullet.setVelocity(packet.getVelocity())
bullet.resetTimeout()
if not packet.isAlive():
bullet.kill()
elif isinstance(packet, Packets.BonusInfoPacket):
if packet.getBonusId() not in self.bonuses:
bonus = Bonus()
self.bonuses[packet.getBonusId()] = bonus
else:
bonus = self.bonuses[packet.getBonusId()]
bonus.setPosition(packet.getPosition())
bonus.resetTimeout()
if not packet.isAlive():
bonus.kill()
elif isinstance(packet, Packets.PlayerGunPacket):
self.player.getGun().setReload(packet.isReloading())
self.player.getGun().setBulletInMagazine(
packet.getBulletInMagazine()
)
self.player.getGun().setTotalBullet(packet.getTotalBullet())
elif packet is not None:
print("Packet received (type " + str(packet) + ")")
self.clientSocket.clientUnlock()
def onInit(self):
w, h = self.getGame().getSize()
self.player = Player(self.getGame(), [w/2, h/2], Color(255, 255, 255))
self.player.setPlayerName(self.username)
def onRender(self, renderer, delta):
px, py = self.player.getPosition()
renderer.drawString(
(10, 20), "Player Position: " + str(px) + ", " + str(py)
)
renderer.drawString(
(10, 35), "Bullets on screen: " + str(len(self.bullets))
)
renderer.drawString(
(10, self.getGame().getSize()[1]-20),
"Health: " + str(self.player.getHealth())
)
if self.show_info:
offset = 0
for player in [self.player] + list(self.players.values()):
import Tkinter as tk
renderer.drawString(
#.........这里部分代码省略.........
示例14: getAction
# 需要导入模块: import Player [as 别名]
# 或者: from Player import getPosition [as 别名]
def getAction(): # Traite les interactions clavier
global pick, use, throw
while 1:
command = raw_input()
if len(command) == 0:
return baseDescript()
command = command.split()
if command[0] == controls[0]:
return altDescript()
elif command[0] == controls[1]:
return move(command[0])
elif command[0] == controls[2]:
return move(command[0])
elif command[0] == controls[3]:
return move(command[0])
elif command[0] == controls[4]:
return move(command[0])
elif command[0] == controls[5]:
return "AAAAAAAAAARGH!!!!!!!"
elif command[0] == controls[6]:
return attack()
elif command[0] == controls[7]:
return useList()
elif command[0] == controls[8]:
return throwList()
elif command[0] == controls[9]:
return pickList()
elif command[0] == "w" and Map.isItem(Player.getPosition()) >= 1:
if pick == 1:
return pickItem(Player.getPosition(),0)
elif use == 1:
return useItem(0)
elif throw == 1:
return throwItem(Player.getPosition(),0)
elif command[0] == "x" and Map.isItem(Player.getPosition()) >= 1:
if pick == 1:
return pickItem(Player.getPosition(),1)
elif use == 1:
return useItem(1)
elif throw == 1:
return throwItem(Player.getPosition(),1)
elif command[0] == "c" and Map.isItem(Player.getPosition()) >= 1:
if pick == 1:
return pickItem(Player.getPosition(),2)
elif use == 1:
return useItem(2)
elif throw == 1:
return throwItem(Player.getPosition(),2)
elif command[0] == "v" and Map.isItem(Player.getPosition()) >= 1:
if pick == 1:
return pickItem(Player.getPosition(),3)
elif use == 1:
return useItem(3)
elif throw == 1:
throwItem(Player.getPosition(),3)
elif command[0] == "b" and Map.isItem(Player.getPosition()) >= 1:
if pick == 1:
return pickItem(Player.getPosition(),4)
elif use == 1:
return useItem(4)
elif throw == 1:
return throwItem(Player.getPosition(),4)
elif command[0] == "n" and Map.isItem(Player.getPosition()) >= 1:
if pick == 1:
return pickItem(Player.getPosition(),5)
elif use == 1:
return useItem(5)
elif throw == 1:
return throwItem(Player.getPosition(),5)
elif command[0] == controls[10]:
exitGame()
else:
return baseDescript()
示例15: getAction
# 需要导入模块: import Player [as 别名]
# 或者: from Player import getPosition [as 别名]
def getAction(): # Traite les interactions clavier
global items, pick, throw, use
key = 0
while 1:
if isInput():
key = sys.stdin.read(1)
if key == '1' :
if int(key) > items:
return "This item doesn't exist!"
elif pick == 1:
return pickItem(Player.getPosition(),0)
elif throw == 1:
return throwItem(Player.getPosition(),0)
elif use == 1:
return useItem(0)
elif key == '2' :
if int(key) > items:
return "This item doesn't exist!"
elif pick == 1:
return pickItem(Player.getPosition(),1)
elif throw == 1:
return throwItem(Player.getPosition(),1)
elif use == 1:
return useItem(1)
elif key == '3' :
if int(key) > items:
return "This item doesn't exist!"
elif pick == 1:
return pickItem(Player.getPosition(),2)
elif throw == 1:
return throwItem(Player.getPosition(),2)
elif use == 1:
return useItem(2)
elif key == '4' :
if int(key) > items:
return "This item doesn't exist!"
elif pick == 1:
return pickItem(Player.getPosition(),3)
elif throw == 1:
return throwItem(Player.getPosition(),3)
elif use == 1:
return useItem(3)
elif key == '5' :
if int(key) > items:
return "This item doesn't exist!"
elif pick == 1:
return pickItem(Player.getPosition(),4)
elif throw == 1:
return throwItem(Player.getPosition(),4)
elif use == 1:
return useItem(4)
elif key == '6' :
if int(key) > items:
return "This item doesn't exist!"
elif pick == 1:
return pickItem(Player.getPosition(),5)
elif throw == 1:
return throwItem(Player.getPosition(),5)
elif use == 1:
return useItem(5)
elif key == 'w' :
pick, throw, use = 0,0,0
return move('north')
elif key == 'a' :
pick, throw, use = 0,0,0
return move('west')
elif key == 's' :
pick, throw, use = 0,0,0
return move('south')
elif key == 'd' :
pick, throw, use = 0,0,0
return move('east')
elif key == 'o' :
pick, throw, use = 0,0,0
return altDescript()
elif key == 'p' :
pick, throw, use = 0,0,0
return pickList()
elif key == 't' :
pick, throw, use = 0,0,0
return throwList()
elif key == 'e' :
pick, throw, use = 0,0,0
return useList()
elif key == 'f' :
pick, throw, use = 0,0,0
return attack()
elif key == '\x1b' :
exitGame()
time.sleep(0.2)
elif key == 'c' :
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, defaultTerminal)
cheat = raw_input("Enter cheat code : ")
tty.setcbreak(sys.stdin.fileno())
if cheat == "doppel":
Map.addDoppel(Player.getPosition())
return "There is now a Doppelganger in front of you!"
elif cheat == "pepperonipizza":
Player.addItem({"name" : "a Pizza" , "rate" : 9 , "type" : 0 , "Modifier" : 100 , "liste" : "A Pepperoni Pizza ---- "})
return "A Pepperoni Pizza materialises in your inventory!"
#.........这里部分代码省略.........