本文整理汇总了Python中World.updateC方法的典型用法代码示例。如果您正苦于以下问题:Python World.updateC方法的具体用法?Python World.updateC怎么用?Python World.updateC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类World
的用法示例。
在下文中一共展示了World.updateC方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import World [as 别名]
# 或者: from World import updateC [as 别名]
class Game:
def __init__(self):
self.cons = IO()
self.world = World()
self.player = self.world.player
self.player.update()
self.world.updateAllC()
self.colors = [libtcod.red, libtcod.green, libtcod.blue, libtcod.white,
libtcod.gray, libtcod.flame, libtcod.light_green, libtcod.yellow,
libtcod.gold, libtcod.darker_yellow]
def mainloop(self):
while 1:
self.cons.clear()
for x in range(self.player.x - SW,self.player.x + SW):
for y in range(self.player.y - SH,self.player.y + SH):
char = self.world.char(x, y)
color = self.world.get(x,y).color
color2 = libtcod.dark_gray
color3 = libtcod.color_lerp(color,color2,
(((x - self.player.x)**2) + ((y-self.player.y)**2)) / 2500.0)
color = libtcod.color_lerp(color3,libtcod.white,0.1)
libtcod.console_put_char(self.cons.console,
(W/2 - self.player.x) + x,
(H/2 - self.player.y) + y,
char,
libtcod.BKGND_DEFAULT)
libtcod.console_set_char_foreground(self.cons.console,
(W/2 - self.player.x) + x,
(H/2 - self.player.y) + y,
color)
self.cons.prints(W/2,H/2,"@",self.player.color,False)
x = W/2 - (len(self.colors) * 2)
for i in range(len(self.colors)):
color = self.colors[i]
if i == 9:
if i == self.player.ccolor:
self.cons.printex(x, H - 4, ("%c+%c" % (libtcod.COLCTRL_1,libtcod.COLCTRL_STOP)) * 2, color, False)
else:
self.cons.printex(x, H - 2, ("%c+%c" % (libtcod.COLCTRL_1,libtcod.COLCTRL_STOP)) * 2, color, False)
self.cons.printex(x, H - 3, ("%c+%c" % (libtcod.COLCTRL_1,libtcod.COLCTRL_STOP)) * 2, color, False)
else:
if i == self.player.ccolor:
self.cons.printex(x, H - 4, ("%c#%c" % (libtcod.COLCTRL_1,libtcod.COLCTRL_STOP)) * 2, color, False)
else:
self.cons.printex(x, H - 2, ("%c#%c" % (libtcod.COLCTRL_1,libtcod.COLCTRL_STOP)) * 2, color, False)
self.cons.printex(x, H - 3, ("%c#%c" % (libtcod.COLCTRL_1,libtcod.COLCTRL_STOP)) * 2, color, False)
x += 4
self.cons.printex(0, H - 1, "%c%s%c" % (libtcod.COLCTRL_1,TITLE +
" (" + DAY + ")",libtcod.COLCTRL_STOP),libtcod.flame, True)
key = self.cons.key()
if key.c == ord('q'):
break
elif self.keyparse(key):
self.player.move(self.keyparse(key),self.movecheck)
elif key.c == ord('x'):
key = libtcod.console_wait_for_keypress(True)
if self.keyparse(key):
yx2 = self.keyparse(key)[0] + self.player.x
yy2 = self.keyparse(key)[1] + self.player.y
if self.world.get(yx2,yy2).walkable and self.world.get(yx2,yy2).chr != "~":
if self.player.ccolor == 9:
self.world.setCell(yx2,yy2,Door())
else:
self.world.setCell(yx2,yy2,Block(self.colors[self.player.ccolor]))
self.world.updateC(yx2, yy2)
continue
elif key.c == ord('z'):
key = libtcod.console_wait_for_keypress(True)
if self.keyparse(key):
yx2 = self.keyparse(key)[0] + self.player.x
yy2 = self.keyparse(key)[1] + self.player.y
if self.world.get(yx2,yy2).diggable and not self.world.get(yx2,yy2).walkable:
self.world.setCell(yx2,yy2,Dirt())
self.world.updateC(yx2, yy2)
continue
elif key.c == ord('c'):
key = libtcod.console_wait_for_keypress(True)
if self.keyparse(key):
yx2 = self.keyparse(key)[0] + self.player.x
yy2 = self.keyparse(key)[1] + self.player.y
if self.world.get(yx2,yy2).chr == "+" or \
self.world.get(yx2,yy2).chr == "-":
self.world.get(yx2,yy2).toggle()
self.world.updateC(yx2, yy2)
continue
def movecheck(self,x,y):
if self.world.get(x,y).chr == "+":
#.........这里部分代码省略.........