本文整理汇总了Python中Player.addItem方法的典型用法代码示例。如果您正苦于以下问题:Python Player.addItem方法的具体用法?Python Player.addItem怎么用?Python Player.addItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player.addItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pickItem
# 需要导入模块: import Player [as 别名]
# 或者: from Player import addItem [as 别名]
def pickItem(position,index): #Ramasse un objet
global pick
pick = 0
print "add"
Player.addItem(Map.getItem(position,index))
print "describe"
descript = "Vous ramassez " + Map.getItemName(position,index)
print "remove"
Map.removeItem(position,index)
print "return"
return descript
示例2: getAction
# 需要导入模块: import Player [as 别名]
# 或者: from Player import addItem [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!"
#.........这里部分代码省略.........
示例3: getAction
# 需要导入模块: import Player [as 别名]
# 或者: from Player import addItem [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!"
#.........这里部分代码省略.........
示例4: createPlayer
# 需要导入模块: import Player [as 别名]
# 或者: from Player import addItem [as 别名]
class App:
#player creator
def createPlayer(self, x, y):
body = self.world.CreateDynamicBody(position = (x, y))
body.fixedRotation = True
box = body.CreatePolygonFixture(box=(5,10), density=1, friction=1)
self.player = Player(x, y, [])
self.player.setBody(body)
self.player.addItem(0, 100)
self.player.addItem(1, 1)
self.player.selectItem(0)
#static tile creator
def createStatic(self, x, y):
return self.world.CreateStaticBody(shapes = b2EdgeShape(vertices = [(5, -5), (5, 5), (-5, 5), (-5, -5)]), position = (x, y))
def __init__(self):
self._running = True
self._display_surf = None
self.size = self.weight, self.height = 1600, 900
self.PPM=20.0
self.h_speed = 0
self.v_speed = 0
def on_init(self):
pygame.init()
self.world = b2World((0,75), True)
self._display_surf = pygame.display.set_mode(self.size, 0, 32)
self._running = True
def on_event(self, event):
if event.type == pygame.QUIT:
self._running = False
#add movement
if event.type == pygame.KEYDOWN:
print event.key
if pygame.K_d == event.key:
self.h_speed = 5
elif pygame.K_a == event.key:
self.h_speed = -5
if pygame.K_SPACE == event.key:
self.v_speed = -750
if pygame.K_1 == event.key:
self.player.nextSelected()
#stop h_movement
if event.type == pygame.KEYUP:
if event.key == pygame.K_a or event.key == pygame.K_d:
self.h_speed = 0
#block breaking
if event.type == pygame.MOUSEBUTTONUP:
pos = pygame.mouse.get_pos()
if self.player.getSelected() != None:
for y in range(len(self.map.getBlocks())):
for x in range(len(self.map.getBlocks()[y])):
if abs(y * 10 + 20 - pos[1]) < 5 and abs(x * 10 + 5 - pos[0]) < 5:
body = self.player.getBody()
if abs(x * 10 + 5 - body.position.x) < 50 and abs(y * 10 + 20 - body.position.y) < 50:
if (self.player.getSelected().getId() == 0 and self.map.getBlocks()[y][x].getTile() != 0):
self.player.addItem(self.map.getBlocks()[y][x].getTile(), 1)
self.map.getBlocks()[y][x].setTile(0)
if (self.map.getBlocks()[y][x].getBody() != None):
self.world.DestroyBody(self.map.getBlocks()[y][x].getBody())
self.map.getBlocks()[y][x].setBody(None)
elif self.player.getSelected().getId() != 0:
if (self.map.getBlocks()[y][x].getBody() == None):
self.map.getBlocks()[y][x].setTile(self.player.getSelected().getId())
self.map.getBlocks()[y][x].setBody(self.createStatic(x * 10, y * 10))
self.player.removeItem(self.player.getSelected().getId(), 1)
return
def on_loop(self):
pass
def on_render(self):
self._display_surf.fill((255,255,255))
#render blocks
for y in range(len(self.map.getBlocks())):
for x in range(len(self.map.getBlocks()[y])):
block = self.map.getBlocks()[y][x]
blockX = block.getX()
blockY = block.getY()
color = (255, 255, 255)
if block.getTile() == 1:
color = color = (255, 0, 255)
if block.getTile() == 2:
color = color = (0, 0, 255)
pygame.draw.rect(self._display_surf, color, (blockX * 10, blockY * 10 + 15, 10, 10))
i = 0
for item in self.player.getItems():
if self.player.getSelected() != None and self.player.getSelected().getId() == item.getId():
pygame.draw.rect(self._display_surf, (125, 225, 125), [10 + i * 25 + 5, 10, 25, 25])
else:
pygame.draw.rect(self._display_surf, (225, 225, 225), [10 + i * 25 + 5, 10, 25, 25])
pygame.draw.rect(self._display_surf, (0, 0, 0), [10 + i * 25 + 5, 10, 25, 25], 2)
color = (255, 255, 255)
if item.getId() == 1:
#.........这里部分代码省略.........