Exemplo n.º 1
0
Arquivo: menu.py Projeto: kjwilcox/hex
    def __init__(self):

        print "initializing program"
        pygame.display.init()

        print "pre-rendering fonts"
        pygame.font.init()
        self.font = "DejaVuSans.ttf"
        self.current_font = pygame.font.Font(self.font, 40)
        self.menu_text = {}
        self.menu_text["HvH1"] = (
            self.current_font.render("Human vs. Human (same computer)",
                True, (0,10,0)), (40, 200))
        self.menu_text["HvHn"] = (
            self.current_font.render("Human vs. Human (networked)",
                True, (0,10,0)), (40, 260))
        self.menu_text["HvC"] = (
            self.current_font.render("Human vs. Computer",
                True, (0,10,0)), (40, 320))
        self.menu_text["how"] = (
            self.current_font.render("How to play",
                True, (0,10,0)), (40, 380))
        self.menu_text["music"] = (
            self.current_font.render("Toggle music",
                True, (0,10,0)), (40, 440))
        self.menu_text["exit"] = (
            self.current_font.render("Exit Game",
                True, (0,10,0)), (40, 500))

        print "precalculating collision grid"
        self.collision = collision.generate_collision_grid()

        print "loading resources"
        self.images = exhibition.load_images()
        self.sounds = jukebox.Jukebox()

        pygame.display.set_caption("Hex")
        pygame.display.set_icon(self.images["icon"])

        print "opening window"
        self.screen = pygame.display.set_mode((800, 600))

        print "optimizing images"
        exhibition.optimize(self.images)

        print "ready!"

        # start the music
        if self.sounds.music != []:
            self.sounds.play_music()
Exemplo n.º 2
0
 def __init__(self):
     """ Creates the display surface and loads the game assets. """
     
     pygame.init()
     log.info("Initializing display surface at {}x{}".format(
         data.SCREEN_RESOLUTION[0], data.SCREEN_RESOLUTION[1]))
     self.screen = pygame.display.set_mode(data.SCREEN_RESOLUTION)
     pygame.display.set_caption("digital heist")
     
     # load image resources
     exhibition.images(os.path.join(data.DATA_DIR, "images"))
     exhibition.optimize()
     
     self.level = level1.Level1()
     self.input = inputdevice.KeyboardInput()