本文整理汇总了Python中screen.Screen.flush方法的典型用法代码示例。如果您正苦于以下问题:Python Screen.flush方法的具体用法?Python Screen.flush怎么用?Python Screen.flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类screen.Screen
的用法示例。
在下文中一共展示了Screen.flush方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GameHandler
# 需要导入模块: from screen import Screen [as 别名]
# 或者: from screen.Screen import flush [as 别名]
class GameHandler(Handler):
def __init__(self, socket, character):
Handler.__init__(self)
self._socket = socket
self._screen = Screen((32, 12))
self._character = character
self._view = View(character, self._map)
def enter(self):
name = self._character.name()
self.send_message_all('"%s"がログインしました。' % name)
self.send_message('ようこそ %s。' % name)
self._handlers[self._socket] = self
self._map.put_character(self._character, self._map.random_open_coordinate())
self.render_all()
def leave(self):
del self._handlers[self._socket]
self.send_message_all('"%s"がログアウトしました。' % self._character.name())
self._map.remove_character(self._character)
self._character.unregister()
self.render_all()
def receve_key(self, key):
if key == 'l': self._map.move_character(self._character, ( 1, 0))
if key == 'h': self._map.move_character(self._character, (-1, 0))
if key == 'j': self._map.move_character(self._character, ( 0, 1))
if key == 'k': self._map.move_character(self._character, ( 0, -1))
def receve_command(self, command):
message = '%s: %s' % (self._character.name(), command)
self.send_message_all(message)
def send_message_all(self, message):
for handler in self._handlers.values():
if isinstance(handler, GameHandler):
handler.send_message(message)
def render(self):
self._view.render(self._screen)
self._screen.flush(self._socket)
self._messages.flush(self._socket)
示例2: Service
# 需要导入模块: from screen import Screen [as 别名]
# 或者: from screen.Screen import flush [as 别名]
class Service(object):
def __init__(self):
self._x, self._y = (0, 0)
self._screen = Screen((80, 21))
def enter(self, socket):
self._screen = Screen((80, 21))
self._screen.flush(socket)
def leave(self, socket):
pass
def receve(self, socket, data):
self._screen.fill('.')
key = chr(int(data))
if key == 'l': self._x += 1
if key == 'h': self._x -= 1
if key == 'j': self._y += 1
if key == 'k': self._y -= 1
self._screen.put('@', (self._x, self._y), 'olive')
self._screen.write(u'入力キー:%s' % key, (4, 20), 'lime')
self._screen.flush(socket)