本文整理汇总了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