def __init__(self): rgl.display.init(2, "BubbMan 2", NESRES) intro.Intro().loop() self.font_white = rgl.font.Font(NES_FONT, (255, 255, 255)) self.font_black = rgl.font.Font(NES_FONT, (1, 1, 1)) self.menu1 = rgl.dialog.Menu( self.font_white, [" Start Game", " Controls", " Quit Game"]) self.background = rgl.util.load_image("data/background-1.png") self.foreground1 = rgl.util.load_image("data/hills-back.png") self.foreground2 = rgl.util.load_image("data/hills-front-1.png") self.logo = rgl.util.load_image("data/logo.png") rgl.util.play_music("data/od-special_s.mod", -1, 0.7) self.cloud = rgl.util.load_image("data/cloud.png") self.clouds = [] for i in range(10): self.clouds.append([ random.choice([1.0, 0.8, 0.75, 0.6, 0.5, 0.4, 0.3]) * 2, [i * 25, random.randrange(75)] ]) self.clouds.sort() self.clouds.reverse() self.help = 0 self.help_text = [ "Controls:", "", "A Button = Z Key ", "B Button = X Key ", "Start = Enter ", "Select = R. Shift", "", "Press start!", ]
def __init__(self, context, prev, next, install): Gtk.VBox.__init__(self) self.prev = prev self.next = next self.install = install self.context = context intro_card = intro.Intro(self.context) device_card = device.Device(self.context) partition_card = partition.Partition(self.context) timezone_card = timezone.Timezone(self.context) locale_card = locale.Locale(self.context) user_card = user.User(self.context) root_card = root.Root(self.context) finalinfo_card = finalinfo.FinalInfo(self.context) status_card = status.Status(self.context) self.card_names = [ 'intro_card', 'device_card', 'partition_card', 'timezone_card', 'locale_card', 'user_card', 'root_card', 'finalinfo_card', 'status_card' ] self.cards = [ intro_card, device_card, partition_card, timezone_card, locale_card, user_card, root_card, finalinfo_card, status_card ] self.the_stack = Gtk.Stack() self.the_stack.set_hexpand(True) self.the_stack.set_vexpand(True) self.context['the_stack'] = self.the_stack self.pack_start(self.the_stack, True, True, 0) self.set_name('stack') # add the cards to the stack self.the_stack.add_titled(intro_card, 'intro_card', 'Introduction') self.the_stack.add_titled(device_card, 'device_card', 'Device') self.the_stack.add_titled(partition_card, 'partition_card', 'Partition') self.the_stack.add_titled(timezone_card, 'timezone_card', 'Timezone') self.the_stack.add_titled(locale_card, 'locale_card', 'Locale') self.the_stack.add_titled(user_card, 'user_card', 'User') self.the_stack.add_titled(root_card, 'root_card', 'Root') self.the_stack.add_titled(finalinfo_card, 'finalinfo_card', 'Confirmation') self.the_stack.add_titled(status_card, 'status_card', 'Status') self.prev.connect('clicked', self.nav_prev) self.next.connect('clicked', self.nav_next) self.current_card = self.card_names[0] self.current_index = 0 self.prev.set_sensitive(False) self.install.set_sensitive(False)
def do_main(no_intro=0, the_level=0): global flags print("hello from zanthor do_main") pygame.mixer.pre_init(22050, -16, 2, 1024) pygame.init() pygame.font.init() #pygame.display.set_caption("The Wrath of ZANTHOR") #It's powered by steam!") pygame.display.set_caption( "The Wrath of ZANTHOR! It's powered by steam! h key for help") #flags = FULLSCREEN print flags print(SW, SH) screen = pygame.display.set_mode((SW, SH), flags) # Map the back button to the escape key. if android: android.map_key(android.KEYCODE_BACK, pygame.K_ESCAPE) print("initialising joystick module") pygame.joystick.init() joystics = [] num_joys = pygame.joystick.get_count() print "initialising joys", num_joys for x in range(num_joys): print "x joy is:", x j = pygame.joystick.Joystick(x) j.init() joystics.append(j) print "initialising joys: done." game = Game() game.should_restore_stats = True game.backup_upgradable_amounts = None game.backup_castle_stats = None # the intro is not done first. #game.run(states.Title(game),screen) if no_intro == 0: game.run(intro.Intro(game), screen) elif no_intro == 1: #game.run(level.Level(game, 0,100),screen) game.run(menu.Menu(game), screen) elif no_intro == 3: # we load the level number from the levels defined in menu. n = menu.data[no_intro][4] perc = menu.data[no_intro][5] music = menu.data[no_intro][7] game.run(level.Level(game, n, perc, music), screen) else: game.run(level.Level(game, no_intro, 100, None), screen)
def setup(self): """Initialize pygame, find the main game file and parse it.""" #initialise pygame pygame.init() #find the main game file and parse it if settings.path is not None: fn = os.path.join(settings.path, "data", "game.xml") else: raise error.DittoInvalidResourceException("settings.py", "path") root = data.getTreeRoot(fn, "Ditto Main") for p in data.getChildren(root, "property"): if data.getAttr(p, "name", data.D_STRING) == "tilesize": globs.TILESIZE = data.getAttr(p, "value", data.D_INT2LIST) elif data.getAttr(p, "name", data.D_STRING) == "font": globs.FONT = data.getAttr(p, "value", data.D_STRING) elif data.getAttr(p, "name", data.D_STRING) == "dialog": globs.DIALOG = data.getAttr(p, "value", data.D_STRING) elif data.getAttr(p, "name", data.D_STRING) == "pokemon": globs.POKEMON = data.getAttr(p, "value", data.D_STRING) elif data.getAttr(p, "name", data.D_STRING) == "soundeffects": soundPath = os.path.join( settings.path, "data", data.getAttr(p, "value", data.D_STRING)) elif data.getAttr(p, "name", data.D_STRING) == "moves": globs.MOVES = os.path.join( settings.path, "data", data.getAttr(p, "value", data.D_STRING)) elif data.getAttr(p, "name", data.D_STRING) == "behaviours": globs.BEHAVIOURS = os.path.join( settings.path, "data", data.getAttr(p, "value", data.D_STRING)) #if there's an icon specified, use it if len(data.getChildren(root, "icon")) > 0: node = data.getChild(root, "icon") iconPath = os.path.join(settings.path, "data", data.getAttr(node, "file", data.D_STRING)) icon = data.getImage(iconPath, fn) pygame.display.set_icon(icon) #set up the main window windowSize = settings.screenSize[0] * globs.TILESIZE[ 0], settings.screenSize[1] * globs.TILESIZE[1] self.screen = pygame.display.set_mode(windowSize) pygame.display.set_caption("%s --- Ditto Engine" % data.getAttr(root, "title", data.D_STRING)) #create a clock object self.clock = pygame.time.Clock() #initialise sound sound.init(soundPath) #set up the initial scene, the intro self.activeScene = intro.Intro(self.screen)
def __init__(self, op): """Inicializamos las variables necesarias para la aplicacion. Creamos la pantalla, definimos los estados y creamos los objetos pertinentes.""" #self.scr = pygame.display.set_mode((TAMX, TAMY)) self.state = INTRO self.intro = intro.Intro(JOIN(DATA,"desarrollado.png"), JOIN(DATA,"derechos.png")) self.menu = menu.Menu() self.juego = juego.Juego()
def __init__(self): ''' #brief Constructor. Carga e inicializa la configuración principal y las variables principales de la clase ''' os.environ["SDL_VIDEO_CENTERED"] = "1" #Cargamos el archivo de configuración parser = xml.dom.minidom.parse(data.get_path_xml('configuration.xml')) #Obtenemos las dimensiones de la pantalla for element in parser.getElementsByTagName('screen'): self.__screen_width = int(element.getAttribute('width')) self.__screen_height = int(element.getAttribute('height')) self.caption = element.getAttribute('caption') #Obtenemos los fps for element in parser.getElementsByTagName('fps'): self.fps = int(element.getAttribute('value')) #Inicializamos Pygame pygame.init() #Obtenemos la ventana de juego self.screen = None self.set_screen() #Obtenemos el icono for element in parser.getElementsByTagName('icon'): icon_code = str(element.getAttribute('code')) self.icon = resource.get_image(icon_code) #Deshabilitamos el cursor pygame.mouse.set_visible(False) pygame.display.set_icon(self.icon) #Creamos el reloj self.clock = pygame.time.Clock() self.font = resource.get_font('cheesebu', 30) #Estado actual del juego self.__actual_state = intro.Intro(self, 'intro.xml')
def __init__(self): print("Instanceando clase RunGame") pygame.init() self.screen_param = (800, 500) self.screen = pygame.display.set_mode(self.screen_param) pygame.display.set_caption('Durak') self.clock = pygame.time.Clock() self.state_dict = { "INTRO": intro.Intro(), "MENU": menu.Menu(), #"JUEGO" : juego.Juego(), "CREDITOS": creditos.Creditos() } # el estado actual (en que stage esta el juego) self.state_name = "INTRO" self.st_done = False # usando el stage, a state se asigna la clase actual la que va a correr self.state = self.state_dict[self.state_name] # tecla recibida self.key = pygame.key.get_pressed() print("Instancee excitosamente la clase RunGame de rungame.py")