本文整理汇总了Python中hud.Hud.display_viruses方法的典型用法代码示例。如果您正苦于以下问题:Python Hud.display_viruses方法的具体用法?Python Hud.display_viruses怎么用?Python Hud.display_viruses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hud.Hud
的用法示例。
在下文中一共展示了Hud.display_viruses方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Lienzo
# 需要导入模块: from hud import Hud [as 别名]
# 或者: from hud.Hud import display_viruses [as 别名]
#.........这里部分代码省略.........
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)
self.hud.display_cells(cr,self.cells)
示例2: Lienzo
# 需要导入模块: from hud import Hud [as 别名]
# 或者: from hud.Hud import display_viruses [as 别名]
#.........这里部分代码省略.........
#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()
width1=score1*570/total
示例3: Lienzo
# 需要导入模块: from hud import Hud [as 别名]
# 或者: from hud.Hud import display_viruses [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