本文整理汇总了Python中display.Display.render方法的典型用法代码示例。如果您正苦于以下问题:Python Display.render方法的具体用法?Python Display.render怎么用?Python Display.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类display.Display
的用法示例。
在下文中一共展示了Display.render方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Game
# 需要导入模块: from display import Display [as 别名]
# 或者: from display.Display import render [as 别名]
class Game():
def __init__(self):
self.win = win
self.update = False
self.conn = conn
self.disp = Display(win, self)
self.inp = inp
self.running = False
self.worlds = {}
self.var = Varlist()
self.msg = []
self.players = {}
# self.get = self.varlist.getval
def getLevel(self, pos):
return self.worlds[pos.w].levels[pos.l]
def getCurrentLevel(self):
return self.getLevel(self.player.pos)
def quit(self):
self.conn.disconnect()
sys.exit()
def setup(self):
Var('console_prefix', '>>', varlist=self.var)
Var('chat_keeptime', 3, varlist=self.var)
Var('hide_players', 0, varlist=self.var)
Var('hide_ents', 0, varlist=self.var)
def getCurrentWorld(self):
return self.worlds[self.player.pos.w]
def move(self, new):
if checkMove(self.player, new, self.getCurrentLevel().map):
self.player.pos = new
self.conn.write({'action':'ACTION', 'type':'MOVE', 'pos':new.dump()})
self.disp.updaterender = True
def updatePos(self, cid, loc):
self.players[cid].pos = loc
self.disp.updaterender = True
def updateEntPos(self, eid, loc):
self.getLevel(loc).ents[eid].pos = loc
self.disp.updaterender = True
def addMsg(self, msg):
self.msg.append({'content':msg, 'type':'con', 'time':None})
self.disp.updaterender = True
def addChat(self, msg):
self.msg.append({'content':msg[1], 'type':'msg', 'id':msg[0], 'time':None})
self.disp.updaterender = True
def addPlayer(self, plyr):
self.players[plyr.id] = plyr
self.disp.updaterender = True
def rmvPlayer(self, plyr):
del self.players[plyr]
self.disp.updaterender = True
def addEnt(self, data):
if data['type'] == 'player':
self.players[data['data']['id']] = Player(data=data['data'])
elif data['type'] == 'mob':
m = MobHolder(data=data['data'])
#self.getLevel(Location(mob_types[data['data']['type']])
self.disp.updaterender = True
def startScreen(self):
g = self.disp.getCenterPos('Server IP: ')
ip = self.win.input("Server IP: ", g[0], g[1], fgcolor=BLUE)
g = self.disp.getCenterPos('Username: ')
name = self.win.input('Username: ', g[0], g[1], fgcolor=BLUE)
self.conn.connect(game=self, ip=ip, name=name)
def checkChat(self):
ret = False
for x, i in enumerate(self.msg):
if i['time'] == None: i['time'] = time.time()
elif time.time()-i['time'] >= self.var.get('chat_keeptime'):
self.msg.pop(x)
self.update = True
ret = True
return ret
def _specloop(self):
self.disp.render()
if len(self.conn.Q):
self.conn.parse(self.conn.Q.popleft()[0])
def startLoop(self):
self.setup()
thread.start_new_thread(self.conn.loop, ())
self.running = True
#.........这里部分代码省略.........