Ejemplo n.º 1
0
 def __init__(self, screenSize, question, answer, posQ=(0,0), posA=(0,0)):
     f = pygame.font.SysFont(pygame.font.get_default_font(),20)
     self.imageQ = get_font_surf(f,question,screenSize[0]/2-QABORDER*2,True,(0,0,255),(0,0,0,0))
     self.imageA = get_font_surf(f,answer,screenSize[0]/2-QABORDER*2,True,(0,0,255),(0,0,0,0))
     
     self.rectQ = pygame.Rect(posQ[0]-QABORDER,posQ[1]-QABORDER,self.imageQ.get_width()+QABORDER*2,self.imageQ.get_height()+QABORDER*2)
     self.rectA = pygame.Rect(posA[0]-QABORDER,posA[1]-QABORDER,self.imageA.get_width()+QABORDER*2,self.imageA.get_height()+QABORDER*2)
     self.done = False
Ejemplo n.º 2
0
 def make_sprite(self, text, position):
     """ create a single invader sprite, with given text and starting position """
     #create the background image
     image = pygame.Surface((self.unitWidth, self.unitHeight))
     image.fill((250, 150, 150))
     #add the text to the image
     textImage = get_font_surf(self.font, text,image.get_width(), True, (0,0,0), (250,150,150))
     image.blit(textImage, ((self.unitWidth-textImage.get_width())/2, (self.unitHeight-textImage.get_height())/2))
     #create the sprite
     spr = Sprite(image, position)
     return spr
Ejemplo n.º 3
0
 def refresh_text_surface(self):
     """ using the current text, set the image for the text """
     #get_font_surf creates a surface with the text wrapped to a certain width
     self.textSurface = get_font_surf(self.font, self.text,self.image.get_width(), True, (0,0,0), (150,150,250))
     self.textRect = pygame.Rect((self.width - self.textSurface.get_width())/2, (self.height - self.textSurface.get_height())/2, 0, 0)