當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。