本文整理汇总了Python中buffer.Buffer.read_short方法的典型用法代码示例。如果您正苦于以下问题:Python Buffer.read_short方法的具体用法?Python Buffer.read_short怎么用?Python Buffer.read_short使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类buffer.Buffer
的用法示例。
在下文中一共展示了Buffer.read_short方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Bot
# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import read_short [as 别名]
#.........这里部分代码省略.........
self.game.add_id(id)
print('[32] ', id)
elif id == 49:
self.ladder = {}
self.mode = 'ffa'
amount = b.read_int()
for i in range(0, amount):
id = b.read_int()
self.ladder[id] = b.read_string()
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_int()
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_h = self.view_h = b.read_double()
print('[64] viewport:', self.view_x, self.view_y, self.view_w, self.view_h)
# version 520
def parse_mergers(self):
amount = self.buffer.read_short()
for i in range(0, amount):
hunter, prey = self.buffer.read_int(), self.buffer.read_int()
if self.game.has_id(hunter) and self.game.has_id(prey): # if we both know these cells
# self.ids: our own cells ids
# game.ids: all bot cell ids
# game.cells: all global cell objects
# game.cells: remove eaten cell from global cells
cell = self.game.get_cell(prey) # prey = prey_id
self.game.remove_cell(prey)
# self.ids/game.ids: remove cell id from bot and game if it is our own
if self.has_id(cell.id):
self.remove_id(cell.id)
self.game.remove_id(cell.id)
print('[game/parse_mergers] %d ate %d' % (hunter, prey))
# version 520
def parse_updates(self):
b = self.buffer
current_time = time.time()
while True:
id = b.read_int()
if id == 0:
break
x = b.read_short()
y = b.read_short()
size = b.read_short()
red = b.read_byte()