本文整理匯總了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