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


Python Command.runCmd方法代码示例

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


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

示例1: GameObject

# 需要导入模块: from Command import Command [as 别名]
# 或者: from Command.Command import runCmd [as 别名]
class GameObject():

	validObjects = ['beacon', 'tower', 'default', 'drone', 'asteroid', 'mine', 'scrap', 'worker', 'fighter'] #Definition list of all possible object type strings

	def __init__(self, loc, objectType, player):
		#Static attributes:
		self.loc = loc

		if(objectType in self.validObjects):
			self.objectType = objectType
		else:
			self.objectType = 'default'

		self.ID = None
		self.player = player
		self.mass = {'beacon':1000, 'tower':100, 'default':10, 'drone':10, 'asteroid':5, 'mine':1, 'scrap':1, 'worker':10, 'fighter':15}[self.objectType] #Get mass from dictionary according to the object type
		#Dynamic attributes:
		self.velocity = [0, 0] #Velocity vector. For example: [1, 0] refers to positive x direction at 1 unit per second
		self.acceleration = [0, 0]
		self.current_cmd = Command('drift') #Initialize GameObjec to drift based on initial acceleration and velocity when created
		self.angle = 0
		#Variable convention:
		#Player: a string representing the player name the object belongs to. Same for every object the player owns
		#ID: A unique ID that is dynamically assigned for each gameObject on the map. In the form player,objectType,number

	def update(self): #Each game object must be updated every tick
		self.current_cmd.runCmd(self)

	def getDict(self):
		obj_dict = self.__dict__.copy()
		del obj_dict['current_cmd']
		return obj_dict
开发者ID:Comperplex,项目名称:spaceout,代码行数:34,代码来源:GameObject.py


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