def __init__(self): ShowBase.__init__(self) debug.setDebug(True) self.create_buttons() self.logo_text = "" self.run_logo() self.gui_handler = EventHandlerGui() self.gui_handler.load_gui(gui.menu.start, self.start_game) FPS = 60 globalClock = ClockObject.getGlobalClock() globalClock.setMode(ClockObject.MLimited) globalClock.setFrameRate(FPS) size = base.win.getDisplayRegion(0).getDimensions()
class Start(ShowBase): def __init__(self): ShowBase.__init__(self) debug.setDebug(True) self.create_buttons() self.logo_text = "" self.run_logo() self.gui_handler = EventHandlerGui() self.gui_handler.load_gui(gui.menu.start, self.start_game) FPS = 60 globalClock = ClockObject.getGlobalClock() globalClock.setMode(ClockObject.MLimited) globalClock.setFrameRate(FPS) size = base.win.getDisplayRegion(0).getDimensions() #frame = DirectFrame(pos=(0, 0, 0), frameSize=(size), image="images/title_background.png", image_scale=(1,1,1)) def create_buttons(self): print "herp" def start_game(self): self.start = Game() #self.startButton.destroy() self.logo_text.destroy() self.gui_handler.destroy_gui(gui.menu.start) def run_logo(self): """This is a mess, will change later.""" font = loader.loadFont('digital.egg', pixelsPerUnit=120, ) self.logo_text = OnscreenText( text='Space Fighter', pos=(0, .6), scale=0.4, font=font, fg=(1, 1, 1, 1), mayChange=True) logo_length = 14 space_fighter = "Space Fighter" self.current_logo = 0 def split_left(string, index): """Takes a string and returns the substring to the left of index""" return "".join(string[i] for i in range(index)) def split_right(string, index): """Takes a string and returns the substring to the right of index""" i = index index = len(string) - i return "".join(string[i] for i in range(index)) def set_logo(): space_fighter_rand = self.string_generator(5) + " " + self.string_generator(7) split = split_left(space_fighter, self.current_logo) rand_split = split_right(space_fighter_rand, self.current_logo) space_fighter_rand = split + rand_split print split + rand_split try: self.logo_text.setText(space_fighter_rand) except AttributeError: logo_seq.finish() self.current_logo += 1 delay = Wait(0.1) logo_seq = Sequence() for i in range(logo_length): logo_seq.append(Func(set_logo)) logo_seq.append(delay) logo_seq.start() def string_generator(self, size=6, chars=pstring.ascii_uppercase + pstring.digits): return ''.join(random.choice(chars) for x in range(size))