当前位置: 首页>>代码示例>>Python>>正文


Python World.get方法代码示例

本文整理汇总了Python中World.get方法的典型用法代码示例。如果您正苦于以下问题:Python World.get方法的具体用法?Python World.get怎么用?Python World.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在World的用法示例。


在下文中一共展示了World.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: addMessage

# 需要导入模块: import World [as 别名]
# 或者: from World import get [as 别名]
import Interface
import Event
import App
import World
import chat  # Chat manager
from Interface import *
from Event import *
from App import *
from World import *

##########################################################
#####Global variables
I = Interface.get()  # Interface manager
A = App.get()  # Application
E = Event.get()  # Event manager
W = World.get()
MainChatWindow = I.getWindow("ChatWindow/MainWindow")  # Main chat window
ChannelWindow = I.getWindow("ChatWindow/Channel", WinType.STATIC_TEXT)  # Channel window
EditWindow = I.getWindow("ChatWindow/Edit")  # Edit widnow
###########################################################
#####Channel class
class CChannel:
    m_messages = ""
    m_name = ""

    def addMessage(self, nick, msg):
        self.m_messages += "<" + nick + "> " + msg + "\n"
        while len(self.m_messages) > 2000 and (string.find(self.m_messages, "\n") != -1):
            self.m_messages = self.m_messages.split("\n", 1)[1]
        if Chat.m_curChannel == self.m_name:
            self.show()
开发者ID:proton,项目名称:ireon,代码行数:33,代码来源:chat.py

示例2: __init__

# 需要导入模块: import World [as 别名]
# 或者: from World import get [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 == "+":
#.........这里部分代码省略.........
开发者ID:initrl,项目名称:MinecraftRL,代码行数:103,代码来源:game.py


注:本文中的World.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。