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


Python Hud.display_cells方法代码示例

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


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

示例1: Lienzo

# 需要导入模块: from hud import Hud [as 别名]
# 或者: from hud.Hud import display_cells [as 别名]

#.........这里部分代码省略.........
        #Le decimos a cairo que pinte su widget por primera vez.
        cr.set_source_rgb(0,0,0)
        cr.paint()

        #paint game info
        cr.set_source_rgb(1,1,1)
        cr.save()
        cr.move_to(15,15)
        text="To next cell: %d" % (self.ticksToNextCell)
        cr.show_text(text)
        cr.restore()
        #pintar a los agentes
        if self.currentState=="Training":
            for point in self.divisionPoints:
                cr.set_source_rgb(1,1,1)
                cr.move_to(point, 15)
                cr.line_to(point,WINDOW_SIZE-15)
                cr.set_line_width(0.6)
                cr.stroke()
            for i in xrange(len(self.classificationList)):
                text=str(self.classificationList[i])
                if i==0:
                    posXText=(self.divisionPoints[i])/2-(len(text)/2)*5
                else:
                    posXText=(self.divisionPoints[i-1]+self.divisionPoints[i])/2-(len(text)/2)*5
                posYText=15
                cr.save()
                cr.move_to(posXText,posYText)
                cr.set_source_rgba(1,1,1,0.7)
                cr.show_text(text)
                cr.restore()
                
            display_simulation(cr,[],self.cells)
            self.hud.display_cells(cr,self.cells)
            self.hud.display_viruses(cr, [])

        if self.currentState=="Running":
            cr.set_source_rgb(1,1,1)
            cr.move_to(15, WINDOW_SIZE-100)
            cr.line_to(WINDOW_SIZE-15,WINDOW_SIZE-100)
            cr.set_line_width(0.6)
            cr.stroke()
            for point in self.divisionPoints:
                cr.set_source_rgb(1,1,1)
                cr.move_to(point, WINDOW_SIZE-85)
                cr.line_to(point,WINDOW_SIZE-15)
                cr.set_line_width(0.6)
                cr.stroke()
            
            for i in xrange(len(self.classificationList)):
                text=str(self.classificationList[i])
                if i==0:
                    posXText=(self.divisionPoints[i])/2-(len(text)/2)*5
                else:
                    posXText=(self.divisionPoints[i-1]+self.divisionPoints[i])/2-(len(text)/2)*5
                posYText=TRAINING_ZONE_LIMIT+15
                cr.save()
                cr.move_to(posXText,posYText)
                cr.set_source_rgba(1,1,1,0.7)
                cr.show_text(text)
                cr.restore()

            for (cell,type) in self.trainingSet:
                cell.paint(cr)

            display_simulation(cr,self.virus,self.cells)
开发者ID:tucif,项目名称:BiokteriID3,代码行数:70,代码来源:main.py

示例2: Lienzo

# 需要导入模块: from hud import Hud [as 别名]
# 或者: from hud.Hud import display_cells [as 别名]

#.........这里部分代码省略.........
        cr.paint()

        #paint game info
        cr.set_source_rgb(1,1,1)
        cr.save()
        cr.move_to(15,15)
        text="To next cell: %d" % (self.ticksToNextCell)
        cr.show_text(text)
        cr.restore()

        cr.set_source_rgb(1,1,1)
        cr.move_to(100, 15)
        cr.line_to(100,WINDOW_SIZE-15)
        cr.set_line_width(0.6)
        cr.stroke()
        
        #pintar a los agentes
        cr.set_line_width(1)
        if self.currentState=="Training":
            for i in xrange(len(self.classificationList)):
                text=str(self.classificationList[i])
                if i==0:
                    posXText=(self.divisionPoints[i])/2-(len(text)/2)*5
                else:
                    posXText=(self.divisionPoints[i-1]+self.divisionPoints[i])/2-(len(text)/2)*5
                posYText=15
                cr.save()
                cr.move_to(posXText,posYText)
                cr.set_source_rgba(1,1,1,0.7)
                cr.show_text(text)
                cr.restore()
                
            display_simulation(cr,[],self.cells)
            self.hud.display_cells(cr,self.cells)
            self.hud.display_viruses(cr, [])

        if self.currentState=="Running":
            for (cell,type) in self.trainingSet:
                cell.paint(cr)

            display_simulation(cr,self.virus,self.cells)
            self.hud.display_cells(cr,self.cells)
            self.hud.display_viruses(cr, self.virus)

        #pintar efecto de selección sobre un agente
        if self.objetoSeleccionado:
            cr.set_line_width(2)
            cr.set_source_rgba(random.random(), 1, random.random(), 0.3)
            cr.rectangle(self.objetoSeleccionado.posX-20,self.objetoSeleccionado.posY-20,
                            self.objetoSeleccionado.width+40, self.objetoSeleccionado.height+40)

            cr.stroke()
                
        #paint score container
        cr.set_line_width(2)
        cr.set_source_rgba(1, 1, 1, 0.5)
        cr.rectangle(100+15,15,570, 5)
        cr.stroke()

        score1=self.virus[0].score+0.00000001
        score2=self.virus[1].score+0.00000001

        total=score1+score2

        #paint first gauge
        cr.save()
开发者ID:Zheroth,项目名称:BiokteriiFuzzy,代码行数:70,代码来源:main.py

示例3: Lienzo

# 需要导入模块: from hud import Hud [as 别名]
# 或者: from hud.Hud import display_cells [as 别名]

#.........这里部分代码省略.........
                        else:
                            leftLimit=self.divisionPoints[i-1]
                        break
                            
                cell.update(self.currentState,[leftLimit,rightLimit-cell.width,600,WINDOW_SIZE-cell.height])

    def paint(self, widget, event):
        """Nuestro metodo de pintado propio"""

        #Se crea un widget de cairo que despues se usara para desplegar
        #todo en la ventana
        cr = widget.window.cairo_create()
        #Le decimos a cairo que pinte su widget por primera vez.
        cr.set_source_rgb(0,0,0)
        cr.paint()

        #paint game info
        cr.set_source_rgb(1,1,1)
        cr.save()
        cr.move_to(15,15)
        text="To next cell: %d" % (self.ticksToNextCell)
        cr.show_text(text)

        cr.move_to(15,self.trainingZoneLimit)
        cr.line_to(WINDOW_SIZE-15,self.trainingZoneLimit)
        cr.set_line_width(0.6)
        cr.stroke()

        for x in xrange(3):
            cr.save()
            cr.move_to((WINDOW_SIZE/3)*x,self.trainingZoneLimit+15)
            cr.line_to((WINDOW_SIZE/3)*x,WINDOW_SIZE-15)
            cr.set_line_width(0.6)
            cr.stroke()
            cr.restore()

        for i in xrange(len(self.classificationList)):
            cr.set_source_rgba(1,1,1,0.7)
            text=str(self.classificationList[i])
            if i==0:
                posXText=(self.divisionPoints[i])/2-(len(text)/2)*5
            else:
                posXText=(self.divisionPoints[i-1]+self.divisionPoints[i])/2-(len(text)/2)*5
            cr.move_to(posXText,WINDOW_SIZE-100+15)
            cr.show_text(text)
        cr.restore()

        for (cell,type) in self.trainingSet:
            cell.paint(cr)

        #pintar a los agentes
        if self.currentState=="Training":
            pass
        
        if self.currentState=="Running":
            cr.set_source_rgb(1,1,1)
            cr.move_to(15, WINDOW_SIZE-100)
            display_simulation(cr,self.virus,self.cells)
            self.hud.display_cells(cr,self.cells)
            self.hud.display_viruses(cr, self.virus)

        #pintar efecto de selección sobre un agente
        if self.objetoSeleccionado:
            cr.set_line_width(2)
            cr.set_source_rgba(random.random(), 1, random.random(), 0.3)
            cr.rectangle(self.objetoSeleccionado.posX-20,self.objetoSeleccionado.posY-20,
                            self.objetoSeleccionado.width+40, self.objetoSeleccionado.height+40)

            cr.stroke()

        #coso <- ��
        if self.currentState == "Running":
            if self.virus[0].status == "Defending":
                cr.set_line_width(2)
                cr.set_source_rgba(1, random.random(), random.random(), 0.7)
                cr.arc(self.virus[0].posX+25,self.virus[0].posY+25, random.randint(40, 60),0, 360)
                cr.stroke()
                
        
    #Para drag & drop
    def button_press(self,widget,event):
        if event.button == 1:
            self.objetoSeleccionado=[]
            lstTemp = self.virus+self.cells
            for ob in lstTemp:
                if ob.drag(event.x,event.y):
                    self.draggingObject = ob
                    self.objetoSeleccionado=ob
                    break
                    
    def button_release(self,widget,event):
        if self.draggingObject:
            self.draggingObject.drop(event.x,event.y)
            self.draggingObject = None

    def pausar(self):
        self.corriendo=False

    def correr(self):
        self.corriendo=True
开发者ID:alex31016,项目名称:BiokteriiRL,代码行数:104,代码来源:main.py


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