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


Python Windows.draw_windows方法代碼示例

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


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

示例1: Game

# 需要導入模塊: import Windows [as 別名]
# 或者: from Windows import draw_windows [as 別名]

#.........這裏部分代碼省略.........


            if event.type == KEYDOWN and event.key == K_UP:
                self.up = True
                #self.sendData('self.up = True')
                self.data['coordinate'] = (0,0,1,0)
                self.sendData(self.data)

            if event.type == KEYUP and event.key == K_UP:
                self.up = False
                #self.sendData('self.up = False')
                self.data['coordinate'] = self.stop_coord
                self.sendData(self.data)


            if event.type == KEYDOWN and event.key == K_DOWN:
                self.down = True
                self.data['coordinate'] = (0,0,0,1)
                self.sendData(self.data)

                #self.sendData('self.down = True')
            if event.type == KEYUP and event.key == K_DOWN:
                self.down = False
                #self.sendData('self.down = False')
                self.data['coordinate'] = self.stop_coord
                self.sendData(self.data)


            if event.type == KEYDOWN and event.key == K_SPACE:
                self.space = True
                #self.sendData('self.space = True')
                self.data['shoot'] = True
                self.sendData(self.data)
            if event.type == KEYUP and event.key == K_SPACE:
                self.shot_bull_game()
                self.space = False
                self.data['shoot'] = False
                self.sendData(self.data)

            if (event.type == QUIT) or (event.type == KEYDOWN and event.key == K_ESCAPE):
                self.sendData("GOODBYE!!!!!!!")
                reactor.stop()
                sys.exit(0)

        self.draw_game()
        self.update_game()


    #****************************отобрыжение процессов
    def draw_game(self):
        self.windows.draw_windows(self.screen)#рисуем окна
        self.all_sprites_list.draw(self.screen)
        self.block_list.draw(self.screen)
        self.bullet_list.draw(self.screen)
        pygame.display.update()# обновление и вывод всех изменений на экран

    #****************************shot
    def shot_bull_game(self):
        self.player.shot_bull()
        self.bullet_list.add(self.player.ret_bull())

    #**************************** при столкновении пули с объектом удаление пули
    def destroy_bull_game(self):

        sprite.groupcollide(self.block_list,self.bullet_list,0,1)

    #**************************** update
    def update_game(self):
        self.player.tank_update(self.left,self.right,self.up,self.down,self.space,self.platforms)
        self.destroy_bull_game()
        self.player.bull_move()

    #****************************удаление данных (destroy data here)
    def end_pygame():
        pygame.quit()

    #****************************ЗАПУСК ИГРЫ
    def play_game(self):
        print 'play_game'
        self.init_window()
        #self.end_pygame()

    #****************************фунция запуска

    def sendData(self, data):
        self.cf.conn.send(data)

    def getData(self, data):
        print "INCOMING: ", data
        self.parseData(data)

    def parseData(self, data):
        print type(data)
        if isinstance(data, dict):
            print "PARSING"
            print data['id']
            if data.get('type') == 'start':
                print 'START  THE GAME'
            for k in data:
                print "KEY: ",k," VALUE: ",data[k]
開發者ID:Oleksandr1,項目名稱:tank,代碼行數:104,代碼來源:Game.py


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