def __init__(self): self.background = graphics.ghostify(vista._screen.convert_alpha()) self.cloudticker = 0 self.active = True text = "Press y to delete your saved game and start over, or any other key to return to the game" self.textimg = font.blocktext(text, size = settings.layout.tipsize) self.torestart = False
def __init__(self): self.background = graphics.ghostify(vista._screen.convert_alpha()) self.cloudticker = 0 self.active = True text = _("Saving map to %s....") % settings.mapfile self.textimg = font.blocktext(text, size = settings.layout.tipsize) self.drawn = False self.savestate()
def __init__(self, name, color = (255, 255, 255)): # TODO: replace with a real icon import graphics self.name = name size = settings.iconsize try: self.img = pygame.image.load(data.filepath(name + ".png")).convert_alpha() self.img = pygame.transform.smoothscale(self.img, (size, size)) except: self.img = Surface(size, size, color) self.rect = self.img.get_rect() self.rect.center = settings.iconpos[self.name] self.ghost = graphics.ghostify(self.img) self.select = graphics.brighten(self.img) self.active = True self.selected = False
def __init__(self): self.background = graphics.ghostify(vista._screen.convert_alpha()) self.cloudticker = 0 self.active = True self.width = maxwidth = int(settings.sx * 0.75) rs = settings.getresolutions() rtexts = ["%sx%s" % res for res in rs] rescallback = lambda arg: settings.setresolution(*arg) self.resbuttons = ButtonSet(rtexts, rs, maxwidth, rescallback) self.resbuttons.buttonmap[settings.size].selected = True wargs = [False, True] wtexts = [_("window mode"), _("fullscreen mode")] def wcallback(arg): settings.fullscreen = arg self.wbuttons = ButtonSet(wtexts, wargs, maxwidth, wcallback) self.wbuttons.buttonmap[settings.fullscreen].selected = True args = [0.5, 1., 2.] texts = [_("slow"), _("normal"), _("fast")] def callback(arg): settings.gamespeed = arg speedbuttons = ButtonSet(texts, args, maxwidth, callback) speedbuttons.buttonmap[settings.gamespeed].selected = True args = [False, True] texts = [_("sound on"), _("sound off")] def callback(arg): settings.silent = arg soundbuttons = ButtonSet(texts, args, maxwidth, callback) soundbuttons.buttonmap[settings.silent].selected = True args = [True, False] texts = [_("star field on"), _("star field off")] def callback(arg): settings.showstars = arg starbuttons = ButtonSet(texts, args, maxwidth, callback) starbuttons.buttonmap[settings.showstars].selected = True texts = [_("back to game"), _("quit game")] callbacks = [self.backtogame, self.quitgame] donebuttons = ButtonSet(texts, None, maxwidth, onselects = callbacks) self.buttonsets = [soundbuttons, self.resbuttons, self.wbuttons, speedbuttons, starbuttons, donebuttons] hs = [buttonset.height for buttonset in self.buttonsets] self.height = sum(hs) + settings.layout.menudy * (len(hs) - 1) y = settings.sy / 2 - self.height / 2 for buttonset in self.buttonsets: buttonset.sety(y) y += buttonset.height + settings.layout.menudy
def __init__(self, name, color=(255, 255, 255)): # TODO: replace with a real icon import graphics self.name = name size = settings.iconsize try: self.img = pygame.image.load( data.filepath(name + ".png")).convert_alpha() self.img = pygame.transform.smoothscale(self.img, (size, size)) except: self.img = Surface(size, size, color) self.rect = self.img.get_rect() self.rect.center = settings.iconpos[self.name] self.ghost = graphics.ghostify(self.img) self.select = graphics.brighten(self.img) self.active = True self.selected = False
def think(self, dt): active = self.meter.amount >= self.amount self.visible = self.meter.height >= self.amount if not self.visible: return self.active = active if self.x is None: self.x = settings.layout.buildiconxs[self.number % len(settings.layout.buildiconxs)] _, self.y = self.meter.meterpos(self.amount, bounded = False) self.img = None if not self.img: self.img = graphics.icon(self.name) self.ghost = graphics.ghostify(self.img) self.select = graphics.brighten(self.img) self.currentimg = self.img self.rect = self.currentimg.get_rect(center = (self.x, self.y)) self.currentimg = (self.select if self.selected else self.img) if self.active else self.ghost self.linepos = x,y = self.meter.meterpos(self.amount) self.pointedto = False
def think(self, dt): active = self.meter.amount >= self.amount self.visible = self.meter.height >= self.amount if not self.visible: return self.active = active if self.x is None: self.x = settings.layout.buildiconxs[self.number % len( settings.layout.buildiconxs)] _, self.y = self.meter.meterpos(self.amount, bounded=False) self.img = None if not self.img: self.img = graphics.icon(self.name) self.ghost = graphics.ghostify(self.img) self.select = graphics.brighten(self.img) self.currentimg = self.img self.rect = self.currentimg.get_rect(center=(self.x, self.y)) self.currentimg = (self.select if self.selected else self.img) if self.active else self.ghost self.linepos = x, y = self.meter.meterpos(self.amount) self.pointedto = False
def pause(self): self.paused = True self.pscreen = graphics.ghostify(vista._screen) noise.pause()