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


Python Player.removeItem方法代码示例

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


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

示例1: throwItem

# 需要导入模块: import Player [as 别名]
# 或者: from Player import removeItem [as 别名]
def throwItem(position,index): #Jette un objet
	global throw
	throw = 0
	Map.addItem(position,Player.getItem(index))
	descript = "Vous jetez " + Player.getItemName(index)
	Player.removeItem(index)
	return descript
开发者ID:ForgetfulMuffin,项目名称:The-Shades,代码行数:9,代码来源:GameFR.py

示例2: throwItem

# 需要导入模块: import Player [as 别名]
# 或者: from Player import removeItem [as 别名]
def throwItem(position,index): #Jette un objet
	global throw
	throw = 0
	Map.addItem(position,Player.getItem(index))
	descript = "You throw " + Player.getItemName(index) + " away."
	Player.removeItem(index)
	return descript
开发者ID:ForgetfulMuffin,项目名称:The-Shades,代码行数:9,代码来源:GameEN.py

示例3: useItem

# 需要导入模块: import Player [as 别名]
# 或者: from Player import removeItem [as 别名]
def useItem(index): #Utilise un objet
    global use
    use = 0
    item = Player.getItem(index)
    if item["type"] == 1:
        Player.equip(item)
        descript = "Vous equipez " + Player.getItemName(index)
    else:
        Player.editHealth(item["Modifier"])
        descript = "Vous mangez " + Player.getItemName(index)
        Player.removeItem(index)
    return descript
开发者ID:ValentinPearce,项目名称:The-Shades,代码行数:14,代码来源:OriginalGame.py

示例4: useItem

# 需要导入模块: import Player [as 别名]
# 或者: from Player import removeItem [as 别名]
def useItem(index): #Utilise un objet
	global use, levelUp
	use = 0
	item = Player.getItem(index)
	if item["type"] == 0 :
		Player.editHealth(item["Modifier"])
		descript = "Vous mangez " + Player.getItemName(index)
		Player.removeItem(index)
	elif item["type"] == 1 :
		Player.equip(item)
		descript = "Vous equipez " + Player.getItemName(index)
	elif item['type'] == 2 :
		for i in range (item['Modifier']):
			Player.setXp(levelUp)
			checkXp()
		descript = "Vous mangez " + Player.getItemName(index)
		Player.removeItem(index)
	return descript
开发者ID:ForgetfulMuffin,项目名称:The-Shades,代码行数:20,代码来源:GameFR.py

示例5: createPlayer

# 需要导入模块: import Player [as 别名]
# 或者: from Player import removeItem [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:
#.........这里部分代码省略.........
开发者ID:sritzow,项目名称:pygame,代码行数:103,代码来源:game.py


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