# Game Game Over Banner import os import pygame import pygame.font from pygame.locals import * import game, gfx # text-related constants from text import * def load_game_resources(): pass class SubsurfaceText: """Render a text message to a subsurface - rect is rectangle with position to draw text on surface if the width of the rect is 0, the surface will be big enough to hold the text """ def __init__(self,surface,background,text,rect, fontpath=BABELFISH_FONTPATH,fontsize=70,fontcolor=WHITE,center=0): font = pygame.font.Font(fontpath, fontsize) self.image, self.rect = gfx.text(font, fontcolor, text) width = self.rect.width height = self.rect.height if type(rect) == type(pygame.Rect((0,0,0,0))): x,y = rect.topleft if rect.width != 0: width = rect.width if rect.height != 0: height = rect.height else: x = 0 y = 0 height = self.rect.height width = self.rect.width # make subsurface for us to draw on self.display_rect = pygame.Rect((x,y,width,height)) self.surface = surface.subsurface(self.display_rect) self.background = background.subsurface(self.display_rect) if center == 1: self.rect.centerx = self.display_rect.width / 2 self.lastrect = self.rect def erase(self): # erase old menu self.surface.fill(0,self.rect) gfx.dirty(self.display_rect) self.background.fill(0,self.rect) def draw(self): r = self.surface.blit(self.image,self.rect) gfx.dirty(self.display_rect) #gfx.dirty2(r, self.lastrect) self.lastrect = r self.background.blit(self.image,self.rect) def tick(self, speedadjust = 1.0): pass