"gamemenu handler. main menu" import math, os import pygame from pygame.locals import * import game, gfx, snd import gameplay from basegamehandler import BaseGameHandler # text-related constants from text import * FONT_SMALL = 0 FONT_MEDIUM = 1 FONT_LARGE = 2 FONT_LAST = 3 MAGICK_RED = [199,20,37] credits = ( ('Developer', ('Adam Feuer',)), # ('Quality Assurance', ('Ran Prieur',)), ('Special Thanks', ('Guido van Rossom', 'Sam Lantinga', 'Pete Shinners')), ) licenseinfo = ('This program is free software. You are encouraged to make', 'copies and/or modify it, subject to the terms of the LGPL.', 'See the file "COPYING.txt" for details.') babelfish_fontinfo = ('Babelfish', 'font by Dale Thorpe') fonts = [] images = [] def load_game_resources(): global fonts, images fontname = BABELFISH_FONTPATH fonts.append((pygame.font.Font(fontname, FONTSIZE_SMALL), BLUE_GREY)) fonts.append((pygame.font.Font(fontname, FONTSIZE_MEDIUM), WHITE)) fonts.append((pygame.font.Font(fontname, FONTSIZE_LARGE), WHITE)) img = gfx.load('oldstarblazer.png') r = img.get_rect() r.bottom = gfx.rect.bottom - 40 r.right = gfx.rect.right images.append((img, r)) img = gfx.load('credrules.gif') #r = img.get_rect().move(220, 20) r = img.get_rect() r.centerx = gfx.rect.centerx r.top = 20 images.append((img, r)) img = gfx.load('pygame.gif') r = img.get_rect().move(520, 40) images.append((img, r)) img = gfx.load('magick.png') r = img.get_rect().move(570, 150) images.append((img, r)) img = gfx.load('python.gif') r = img.get_rect().move(450, 120) images.append((img, r)) img = gfx.load('sdl.gif') r = img.get_rect().move(698, 115) images.append((img, r)) img = gfx.load('gfx_by_gimp.gif') r = img.get_rect().move(500, 225) images.append((img, r)) font_verytiny = pygame.font.Font(None, 14) x = 530 y = 190 txt = gfx.text(font_verytiny, MAGICK_RED , "Image rotation by ", (x,y)) images.append(txt) font_tiny = pygame.font.Font(None, FONTSIZE_TINY) font_babelfish = pygame.font.Font(BABELFISH_FONTPATH,28) top = 530 mid = 240 for l in licenseinfo: txt = gfx.text(font_tiny, GREY , l, (mid, top)) top += txt[1].height images.append(txt) x = gfx.rect.centerx - 260 y = 470 txt = gfx.text(font_babelfish,WHITE,babelfish_fontinfo[0]) txt[1].topleft = x,y images.append(txt) x += txt[1].width + 5 y += 5 txt = gfx.text(font_tiny,WHITE,babelfish_fontinfo[1]) txt[1].topleft = x,y images.append(txt) snd.preload('select_choose') class GameCredits(BaseGameHandler): def __init__(self, prevhandler): BaseGameHandler.__init__(self) self.prevhandler = prevhandler self.done = 0 self.top = 60 self.center = gfx.rect.centerx - 160 self.text = [] self.drawncredits = 0 self.createtext(" Credits: ",FONT_LARGE) #self.createtext(" ",FONT_SMALL) for cred in credits: self.createtext(cred[0], FONT_SMALL) for people in cred[1]: self.createtext(people, FONT_MEDIUM) self.top += 25 self.text.extend(images) self.createtext('Star Blazer on the Apple2', FONT_SMALL,(625,300)) def createtext(self, text, size, pos=None): if size not in range(0,FONT_LAST): size = 0 f, c = fonts[size] if pos == None: t = gfx.text(f, c, text, (self.center, 0)) t[1].top = self.top self.top = t[1].bottom else: t = gfx.text(f, c, text, pos) self.text.append(t) def quit(self): game.handler = self.prevhandler self.done = 1 snd.play('select_choose') def input(self, i): self.quit() def event(self, e): pass def get_events(self): return pygame.event.get() def run(self): if self.drawncredits == 0: gfx.clearscreen() for cred in self.text: r = cred[1] self.background(r) gfx.dirty(r) for cred, pos in self.text: gfx.surface.blit(cred, pos) gfx.background.blit(cred,pos) self.drawncredits = 1 def background(self, area): return gfx.surface.fill((0, 0, 0), area)