當前位置: 首頁>>代碼示例>>Python>>正文


Python Background.populate方法代碼示例

本文整理匯總了Python中background.Background.populate方法的典型用法代碼示例。如果您正苦於以下問題:Python Background.populate方法的具體用法?Python Background.populate怎麽用?Python Background.populate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在background.Background的用法示例。


在下文中一共展示了Background.populate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: GameWindow

# 需要導入模塊: from background import Background [as 別名]
# 或者: from background.Background import populate [as 別名]
class GameWindow(pyglet.window.Window):
    def __init__(self):
        global Name        
        
        super(GameWindow, self).__init__()
        self.textevents = 1
        self.set_size(800, 600)
        self.gamestate = 1  # 0 playing  1 main menu
        rabbyt.set_default_attribs()
        pyglet.clock.schedule(rabbyt.add_time)
        pyglet.clock.set_fps_limit(100)
        self.fps_display = pyglet.clock.ClockDisplay()
        self.mainmenu = MainMenu((self.width, self.height))
        self.mainmenu.open = 1
        self.creditsmenu = CreditsMenu((self.width, self.height)) 
        self.optionsmenu = OptionsMenu((self.width, self.height))
        self.keymenu = KeyMenu((self.width, self.height))
        self.sounds = Sounds()
        self.text_cursor = self.get_system_mouse_cursor('text')
        self.focus = None  
        self.configuration = player.Configuration()
        self.controls = self.configuration.getControls()
        self.keys = self.configuration.pykeys 
        self.idnum = 0
        #self.image = pyglet.image.load('ship2.png')
        #music = pyglet.resource.media('sample.wav',streaming=False)
        #music.play()
        #self.push_handlers(pyglet.window.event.WindowEventLogger())
        
    def playerLogin(self):
        self.name = self.mainmenu.textentry.get("Name").document.text
        password = self.mainmenu.textentry.get("Password").document.text
        print "NAME: ",self.name
        print "password: ", password
        self.net_client = netclient.NetData(self.name)
        data = self.net_client.Connect("localhost",6317,password)  #doyle.is-a-geek.net
        print "connection", data
        self.idnum = data[4]
        self.startsystem = pickle.loads(data[1])
        print "self.startsystem",self.startsystem
        return data
           
    def startPlaying(self,data):
        self.mainmenu.open = 0
        self.textevents = 0        
        self.otherlist = {}
        self.playercount = 1
        safejump = 500
        self.mapsize = (13000 * 4, 13000 * 4)
        self.center = (13000 * 2, 13000 * 2)
        self.safejump = range(self.center[0] - safejump, self.center[0] + safejump)                    
        def entities(self):
            self.label = pyglet.text.Label('Hello, world',
                                           font_name = 'Times New Roman',
                                           font_size = 36,
                                           x = self.width/2, y = self.height/2,
                                           anchor_x = 'center', anchor_y = 'center')
            self.panel = Panel((self.width,self.height))
            self.background = Background((self.width,self.height),self.panel.size)
            self.background.pos = [self.mapsize[0] / 2, self.mapsize[1] / 2]
            self.background.populate()
            self.bgcheck = 1
            self.player = player.Player((self.width,self.height),self.panel.size)
            self.player.name = self.name
            self.player.idnum = self.idnum
            self.player.location[0] = self.startsystem
            self.spritelist = [self.player.sprite]
            self.visible_size = (self.background.x,self.background.y)
            self.systemdict = MakeSystemDict("data/systems/systems.list",self.player.pos,self.center,self.visible_size)
            self.systemdict.get(self.startsystem.name).update(self.startsystem)
            self.systemdict.get(self.startsystem.name).active = 1
            self.system = self.systemdict.get(self.startsystem.name)
            self.selectedsystem = None
            self.activesystem = self.system.name
            self.linkdict = MakeLinks(self.systemdict)
            print "LINKDICT: " + str(self.linkdict)
            self.menudialogue = MenuDialogue((self.width,self.height))
            self.optionsdialogue = OptionsDialogue((self.width,self.height))
            self.controlsdialogue = ControlsDialogue((self.width,self.height))
            self.dockdialogue = DockDialogue((self.width,self.height))           
            self.mapdialogue = MapDialogue((self.width, self.height))
            self.mapdialogue.active = self.activesystem
        entities(self)
        
        self.playerdict = {}
        otherdata = pickle.loads(data[2])
        print "OTHERDATA"
        for each in otherdata:
            print each, otherdata.get(each)
            self.playerdict[each] = others.Other((self.width,self.height),self.panel.size)
            self.playerdict.get(each).setNonCrucial(otherdata.get(each))
            
        otherdata = pickle.loads(data[3])
        for each in otherdata:
            self.playerdict.get(each).setCrucial(otherdata.get(each))
        
        def init_player(self):
            self.player_rot=(0,"CW")
            self.player_accel=(0,0,0)
            self.player_about=(0,0,0)
#.........這裏部分代碼省略.........
開發者ID:remremrem,項目名稱:EV-Tribute,代碼行數:103,代碼來源:game.py


注:本文中的background.Background.populate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。