本文整理汇总了Python中buffer.Buffer.read_uint方法的典型用法代码示例。如果您正苦于以下问题:Python Buffer.read_uint方法的具体用法?Python Buffer.read_uint怎么用?Python Buffer.read_uint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类buffer.Buffer
的用法示例。
在下文中一共展示了Buffer.read_uint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Bot
# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import read_uint [as 别名]
#.........这里部分代码省略.........
if not self.last_update == self.game.timestamp:
# if we didn't receive an update this tick, we dont need to check for destroys.
return
# removing dead cells no longer happens in bot.py
# cells are only removed on a packet, or when there are no watchers (only on disconnect)
return True
def act(self):
# todo: write AI
pass
def parse_packet(self, id):
#print("====",id,"====")
b = self.buffer
if id == 16:
self.last_update = self.game.timestamp
self.parse_mergers()
self.parse_updates()
self.parse_deaths()
elif id == 17:
x = b.read_float()
y = b.read_float()
ratio = b.read_float()
print('[17]', x, y, ratio)
elif id == 20:
for id in self.ids:
self.game.remove_id(id)
self.ids = []
print('[20] cell reset')
elif id == 32:
id = b.read_uint()
self.add_id(id)
self.game.add_id(id)
print('[32] ', id)
elif id == 49:
self.ladder = {}
self.mode = 'ffa'
amount = b.read_uint()
for i in range(0, amount):
id = b.read_uint()
self.ladder[i] = b.read_string16()
self.game.ladder = self.ladder.copy()
self.game.mode = 'ffa'
#print('[49]')
elif id == 50:
# the 3rd ladder version, original was 48 (non-indexed ladder), 49 (indexed) and now 50
self.ladder = []
count = b.read_uint()
for i in range(0, count):
self.ladder.append(b.read_float())
if len(self.game.ladder) == 0:
self.game.ladder = self.ladder.copy()
self.game.mode = 'teams'
#print('[50]')
elif id == 64:
self.game.view_x = self.view_x = b.read_double()
self.game.view_y = self.view_y = b.read_double()
self.game.view_w = self.view_w = b.read_double() - self.game.view_x
self.game.view_h = self.view_h = b.read_double() - self.game.view_y
print('[64] viewport:', self.view_x, self.view_y, self.view_w, self.view_h)
if len(b.input) > 0: