本文整理汇总了Python中buffer.Buffer.write_double方法的典型用法代码示例。如果您正苦于以下问题:Python Buffer.write_double方法的具体用法?Python Buffer.write_double怎么用?Python Buffer.write_double使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类buffer.Buffer
的用法示例。
在下文中一共展示了Buffer.write_double方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Bot
# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import write_double [as 别名]
#.........这里部分代码省略.........
def send_init(self):
if self.is_connected() and not self.has_sent_init:
self.has_sent_init = True
self.buffer.write_byte(254)
self.buffer.write_int(4)
self.buffer.flush_session(self.session)
self.buffer.write_byte(255)
self.buffer.write_int(1)
self.buffer.flush_session(self.session)
return True
return False
def send_spawn(self):
if self.is_connected() and (time.time() - self.last_sent_spawn > 4):
for cell in self.game.cells.values():
cell.remove_watcher(self)
self.last_sent_spawn = time.time()
self.buffer.write_string(self.name)
self.buffer.flush_session(self.session)
return True
return False
def send_move(self, x, y):
if self.is_connected() and self.is_alive():
if not (self.last_x == x and self.last_y == y):
# update our last variables
self.last_x = x
self.last_y = y
# send new coordinates
self.buffer.write_byte(16)
self.buffer.write_double(x)
self.buffer.write_double(y)
self.buffer.write_int(0)
# flush
self.buffer.flush_session(self.session)
return True
return False
def send_move_relative(self, rel_x, rel_y):
x, y = self.get_center()
x += rel_x
y += rel_y
return self.send_move(x, y)
def send_split(self, times=1):
if self.is_connected() and self.is_alive():
for i in range(0, times):
self.buffer.write_byte(17)
self.buffer.flush_session(self.session)
return True
return False
def send_throw(self, times=1):
if self.is_connected() and self.is_alive():
for i in range(0, times):
self.buffer.write_byte(21)
self.buffer.flush_session(self.session)
return True
return False
def send_spectate(self):