def paint(self,screen): img = pygame.image.load(os.path.join("data","gfx","help.png")) screen.blit(img,(0,0)) g = self.game fg = (255,255,255) bg = (0,0,0) fnt = g.font_title text.write(screen,fnt,(20,10),fg,"You Won!",border=2) x,y = 20,140 txt = """You have saved the people from the evil potentate. Good job. Now you can spend the rest of your life basking in the glow of your great accomplishment. You are a true hero. Huzzah. """ for dx,dy in [(-1,0),(1,0),(0,1),(0,-1),(2,2)]: text.writewrap(screen,self.game.font_small,pygame.Rect(x+dx,y+dy,600,1),bg,txt) text.writewrap(screen,self.game.font_small,pygame.Rect(x,y,600,1),fg,txt) pygame.display.flip()
def paint(self,screen): img = pygame.image.load(os.path.join("data","gfx","help.png")) screen.blit(img,(0,0)) g = self.game fg = (255,255,255) bg = (0,0,0) fnt = g.font_title text.write(screen,fnt,(20,10),fg,"Help",border=2) x,y = 20,140 txt = """The evil potentate is ruining everyone's lives! Use the power of dynamite to destroy his strongholds. Detonate dynamite by the blue load bearing pillars to bring down the castles. Watch out for the guards. Hide next to walls, but not too close to guards. Escape via windows. Controls: Left Mouse Button - walk to a point Numeric Keypad - walk in a direction Right Mouse Button 1st Time - place dynamite Right Mouse Button 2nd Time - detonate dynamite Left CTRL - same as Right Mouse Button Arrow Keys - peek around the level Escape - quit; Enter / p - pause; F2 - toggle music """ for dx,dy in [(-1,0),(1,0),(0,1),(0,-1),(2,2)]: text.writewrap(screen,self.game.font_small,pygame.Rect(x+dx,y+dy,600,1),bg,txt) text.writewrap(screen,self.game.font_small,pygame.Rect(x,y,600,1),fg,txt) pygame.display.flip()
def paint(self,screen): if self.game.audio and self.text == 'Pause': #HACK, bleckl! pygame.mixer.music.pause() self.screen = screen self.orig = pygame.Surface((screen.get_width(),screen.get_height())) self.orig.blit(screen,(0,0)) c = (255,255,255) text.writec(screen,self.game.font_medium,c,self.text,border=2) bg = (0,0,0) if len(self.sub) > 40: for dx,dy in [(-1,0),(1,0),(0,1),(0,-1),(2,2)]: text.writewrap(screen,self.game.font_small,pygame.Rect(40+dx,270+dy,560,1),bg,self.sub) text.writewrap(screen,self.game.font_small,pygame.Rect(40,270,560,1),c,self.sub) else: img = self.game.font_small2.render(self.sub,1,bg) for dx,dy in [(-1,0),(1,0),(0,1),(0,-1),(2,2)]: screen.blit(img,((screen.get_width()-img.get_width())/2+dx,270+dy)) img = self.game.font_small2.render(self.sub,1,c) screen.blit(img,((screen.get_width()-img.get_width())/2,270)) pygame.display.flip()
def paint(self,screen): self.screen = screen self.orig = pygame.Surface((screen.get_width(),screen.get_height())) self.orig.blit(screen,(0,0)) screen.fill((0,0,0)) self.orig.set_alpha(128) screen.blit(self.orig,(0,0)) self.orig.set_alpha(255) c = (255,255,255) text.writec(screen,self.game.font_menu,c,self.text,border=2) bg = (0,0,0) if len(self.sub) > 40: for dx,dy in [(-1,0),(1,0),(0,1),(0,-1),(2,2)]: text.writewrap(screen,self.game.font_small,pygame.Rect(40+dx,270+dy,560,1),bg,self.sub) text.writewrap(screen,self.game.font_small,pygame.Rect(40,270,560,1),c,self.sub) else: img = self.game.font_small2.render(self.sub,1,bg) for dx,dy in [(-1,0),(1,0),(0,1),(0,-1),(2,2)]: screen.blit(img,((screen.get_width()-img.get_width())/2+dx,270+dy)) img = self.game.font_small2.render(self.sub,1,c) screen.blit(img,((screen.get_width()-img.get_width())/2,270)) pygame.display.flip()
from pgu import text pygame.font.init() screen = pygame.display.set_mode((640,480),SWSURFACE) fg = (0,0,0) bg = (0,192,255) screen.fill(bg) bg = (255,255,255) font = pygame.font.SysFont("default", 24) ##:: text.write(screen,font,(0,0),bg,"Hello World!") text.writec(screen,font,bg,"Centered Text") text.writepre(screen,font,pygame.Rect(160,48,320,100),fg,"""This is some preformatted t e x t""") text.writewrap(screen,font,pygame.Rect(160,268,320,100),fg,"""This is some text that will wrap automatically. This is some text that will wrap automatically. This is some text that will wrap automatically. This is some text that will wrap automatically.""") ## pygame.display.flip() _quit = 0 while not _quit: for e in pygame.event.get(): if e.type is QUIT: _quit = 1 pygame.time.wait(10)
def drawmenutext(self, screen, position, color, string): x, y = position text.writewrap(screen, self.font, pygame.Rect(20, 20, 280, 160), color, string) text.writewrap(screen, self.font, pygame.Rect(20, 20, 280, 160), (0, 0, 0), string)
screen = pygame.display.set_mode((640, 480), SWSURFACE) fg = (0, 0, 0) bg = (0, 192, 255) screen.fill(bg) bg = (255, 255, 255) font = pygame.font.SysFont("default", 24) ##:: text.write(screen, font, (0, 0), bg, "Hello World!") text.writec(screen, font, bg, "Centered Text") text.writepre(screen, font, pygame.Rect(160, 48, 320, 100), fg, """This is some preformatted t e x t""") text.writewrap( screen, font, pygame.Rect(160, 268, 320, 100), fg, """This is some text that will wrap automatically. This is some text that will wrap automatically. This is some text that will wrap automatically. This is some text that will wrap automatically.""" ) ## pygame.display.flip() _quit = 0 while not _quit: for e in pygame.event.get(): if e.type == QUIT: _quit = 1 pygame.time.wait(10)
def drawmenutext(self, screen, position, color, string): x, y = position text.writewrap(screen, self.font, pygame.Rect(x + 1, y + 1, 640, 30), (0, 0, 0), string) text.writewrap(screen, self.font, pygame.Rect(x, y, 640, 30), color, string)