Ejemplo n.º 1
0
    def __init__(self):
        self.menuStage = 0  #  Current menu state.
        self.rollingStarfield = 0  #  Pixel index for the background starfield.
        self.starField = pygame.image.load(
            os.path.join('Graphics_Assets', 'cloud.png'))
        self.musicState = False

        #  Prepare starfield for blitting.
        self.starFieldScaled = pygame.transform.scale(self.starField,
                                                      (g.width, g.height))

        #  Main Menu Graphics
        self.menuGraphic = pygame.image.load(
            os.path.join('Graphics_Assets', 'intro5.png'))

        #  Prepare menu graphic for blitting
        self.menuGraphicScaled = pygame.transform.scale(
            self.menuGraphic, (g.width, g.height))

        #  Positional buttons for the screen options.
        self.newGame = buttons.Button(int(
            (g.height / 200) * 10), int((g.width / 320) * 113), (int(
                (g.width / 320) * 35), int((g.height / 200) * 153)))
        self.intro = buttons.Button(int(
            (g.height / 200) * 10), int((g.width / 320) * 96), (int(
                (g.width / 320) * 54), int((g.height / 200) * 173)))
        self.quitGame = buttons.Button(int(
            (g.height / 200) * 10), int((g.width / 320) * 88), (int(
                (g.width / 320) * 168), int((g.height / 200) * 173)))
        self.loadGame = buttons.Button(int(
            (g.height / 200) * 10), int((g.width / 320) * 105), (int(
                (g.width / 320) * 168), int((g.height / 200) * 153)))
Ejemplo n.º 2
0
    def run(self):
        g.init()
        g.journal = self.journal
        if not self.journal:
            utils.load()
            self.best = g.best
        else:
            g.best = self.best
        buttons.Button('reset', (g.sx(15.6), g.yc), True)
        buttons.Button('new', (g.sx(18.8), g.yc), True)
        self.board = tra.Board()
        self.board.setup()
        if self.journal:  # Sugar only
            a, b, c, d = pygame.cursors.load_xbm('my_cursor.xbm',
                                                 'my_cursor_mask.xbm')
            pygame.mouse.set_cursor(a, b, c, d)
        going = True
        while going:
            g.mx, g.my = pygame.mouse.get_pos()
            # Pump GTK messages.
            while gtk.events_pending():
                gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal: utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.redraw = True
                    if self.canvas <> None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 2:  # centre button
                        if not self.journal:
                            g.version_display = not g.version_display
                    if event.button == 1:
                        g.glow_ms = None
                        g.red_ms = None
                        bu = buttons.check()
                        if bu != '': self.do_button(bu)
                        else: self.board.click()
                elif event.type == pygame.KEYDOWN:
                    self.do_key(event.key)
                    g.redraw = True
            if not going: break
            self.update()
            #self.board.setup(); g.redraw=True###
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                pygame.display.flip()
                g.redraw = False
            if g.score > g.best: g.best = g.score
            self.best = g.best
            tf = False
            if pygame.mouse.get_focused(): tf = True
            pygame.mouse.set_visible(tf)
            g.clock.tick(40)
 def buttons_setup(self):
     cy=g.sy(19.8)
     buttons.Button('new',(g.sx(30),cy),caption='new game')
     buttons.Button('replay',(g.sx(2),cy),caption='replay')
     cx=g.sx(26)
     buttons.Button('try',(cx,g.sy(8.5)),caption='try')
     buttons.Button('clear',(cx,g.sy(13)),caption='clear')
     buttons.Button('help',(g.sx(30),g.sy(3.3)),caption='help')
    def run(self):
        g.init()
        if not self.journal:
            utils.load()
            self.tess_n = g.tess_n
            self.max_n = g.max_n
        else:
            g.tess_n = self.tess_n
            g.max_n = self.max_n
        self.tessl = tess.Tess(g.tesses[g.tess_n - 1])
        dx = g.sy(2.4)
        bx = g.sx(16) - dx / 2
        by = g.sy(20.2)
        buttons.Button("back", (bx, by), True)
        bx += dx
        buttons.Button("fd", (bx, by), True)
        bx = g.sx(16)
        by = g.sy(11)
        buttons.Button("solve", (bx, by), True)
        if self.journal:  # Sugar only
            a, b, c, d = pygame.cursors.load_xbm('my_cursor.xbm',
                                                 'my_cursor_mask.xbm')
            pygame.mouse.set_cursor(a, b, c, d)
        going = True

        while going:
            # Pump GTK messages.
            while gtk.events_pending():
                gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal: utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.redraw = True
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 2:  # centre button
                        if not self.journal:
                            g.version_display = not g.version_display
                            break
                    bu = ''
                    if not self.tessl.carrying:
                        bu = buttons.check()
                    if bu <> '': self.do_button(bu)
                    else: self.tessl.click()
            self.tessl.update()
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                pygame.display.flip()
                g.redraw = False
            tf = False
            if pygame.mouse.get_focused(): tf = True
            pygame.mouse.set_visible(tf)
            g.clock.tick(40)
Ejemplo n.º 5
0
 def buttons_setup(self):
     cx=g.sx(30.5)
     cy=g.sy(1.6); dy=g.sy(3)
     for i in range(1,5):
         buttons.Button(str(i),(cx,cy))
         cy+=dy
     buttons.Button('reset',(cx,g.sy(17.5)))
     buttons.Button('new',(cx,g.sy(20.5)))
     self.score_cxy=(cx,g.sy(14)); self.smiley_cxy=(g.sx(3),g.sy(20.5))
Ejemplo n.º 6
0
 def buttons_setup(self):
     dx = g.sy(2.4)
     bx = g.sx(16) - dx
     by = g.sy(20.2)
     buttons.Button("back", (bx, by), True)
     bx += dx
     buttons.Button("toc", (bx, by), True)
     bx += dx
     buttons.Button("fd", (bx, by), True)
Ejemplo n.º 7
0
 def buttons_setup(self):
     cx=g.sx(30.25); cy=g.sy(6.5); dy=g.sy(2)
     buttons.Button('save',(cx,cy)); cy+=dy
     y1=cy; cy+=2*dy
     buttons.Button('load',(cx,cy)); cy+=dy
     y2=cy; cy+=2*dy
     buttons.Button('clear',(cx,cy)); cy+=dy
     self.save_c=(cx,y1); self.load_c=(cx,y2)
     if g.saves_n==0: buttons.off('load')
     self.load_d=g.sy(.5) # half size of number for clicking
Ejemplo n.º 8
0
    def __init__(self):
        self.state = 0
        self.internalState = 0
        self.online = False
        self.initOnline = False
        self.buttons = [
            buttons.Button([pyxel.width / 2, 80], [100, 10], [12, 5, 1],
                           ['ENTRENAMIENTO LOCAL', 6]),  # LOCAL
            buttons.Button([pyxel.width / 2 - pyxel.width / 4, 100], [70, 10],
                           [12, 5, 1], ['CREAR SERVIDOR', 6]),  # CLIENT
            buttons.Button([pyxel.width / 2 + pyxel.width / 4, 100], [80, 10],
                           [12, 5, 1], ['UNIRSE A SERVIDOR', 6]),  # SERVER
        ]
        self.returnButton = buttons.Button([25, 10], [50, 10], [7, 0, 0],
                                           ['VOLVER', 13])

        self.connectButton = buttons.Button([pyxel.width / 2, 110], [80, 10],
                                            [3, 1, 1],
                                            ['UNIRSE A SERVIDOR', 11])
        self.hostButton = buttons.Button([pyxel.width / 2, 110], [80, 10],
                                         [9, 1, 1], ['CREAR SERVIDOR', 10])

        self.addrInput = KeyboardInput('192.168.')
        self.addrBox = buttons.Button([pyxel.width / 2, 65], [100, 10],
                                      [7, 0, 0], [self.addrInput.storage, 3])
        self.portInput = KeyboardInput('8000')
        self.portBox = buttons.Button([pyxel.width / 2, 95], [100, 10],
                                      [7, 0, 0], [self.portInput.storage, 3])
        self.nameInput = KeyboardInput('player')
        self.nameBox = buttons.Button([pyxel.width / 2, 35], [100, 10],
                                      [7, 0, 0], [self.nameInput.storage, 3])
        self.player = player.Player(5, 3, (pyxel.width / 2),
                                    (pyxel.height / 2), 1)
        self.otherPlayer = player.Player(5, 3, (pyxel.width / 2),
                                         (pyxel.height / 2), 1, True)
Ejemplo n.º 9
0
 def buttons_setup(self):
     x = g.sx(3.5)
     y = g.sy(19)
     dx = g.sy(5)
     g.arrows_xy = (x + g.sy(5), y - g.sy(1.9))
     g.score_c = (x, y)
     x += dx  # since we dropped '0'
     for i in range(1, 5):
         buttons.Button(str(i), (x, y))
         x += dx
     buttons.Button('new', (x, y))
Ejemplo n.º 10
0
    def run(self):
        g.init()
        self.rects=rects.Rects()
        if not self.journal:
            utils.load()
        else:
            g.level=self.level
        self.slider=slider.Slider(g.sx(16),g.sy(20.5),10,utils.GREEN)
        self.new1()
        bx=g.sx(29.5); by=g.sy(12)
        buttons.Button("cyan",(bx,by),True)
        by=g.sy(16)
        buttons.Button("black",(bx,by),True)
        if self.journal: # Sugar only
            a,b,c,d=pygame.cursors.load_xbm('my_cursor.xbm','my_cursor_mask.xbm')
            pygame.mouse.set_cursor(a,b,c,d)
        going=True
        while going:
            # Pump GTK messages.
            while gtk.events_pending():
                gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type==pygame.QUIT:
                    if not self.journal: utils.save()
                    going=False
                elif event.type == pygame.MOUSEMOTION:
                    g.redraw=True
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw=True
                    if event.button==2: # centre button
                        if not self.journal:
                            g.version_display=not g.version_display; break
                    bu=buttons.check()
                    if bu<>'': self.button(bu); break
                    if self.slider.mouse(): self.new1(); break
                    if self.rects.click():
                        if not g.magic_show:
                            if self.rects.correct():
                                g.score+=g.level; g.magic_show=True
                                buttons.off("black")
            if not going: break
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                pygame.display.flip()
                g.redraw=False
            tf=False
            if pygame.mouse.get_focused(): tf=True
            pygame.mouse.set_visible(tf)
            g.clock.tick(40)
            # be ready for xo quit at any time
            self.level=g.level
Ejemplo n.º 11
0
    def run(self):
        g.init()
        if not self.journal:
            utils.load(); self.level=g.level
        else:
            g.level=self.level
        x=g.sx(26); y=g.sy(11.2)
        buttons.Button("new",(x,y))
        x=g.sx(4); y=g.sy(10); dx=g.sy(4)
        buttons.Button("back",(x,y)); x+=dx
        buttons.Button("plus",(x,y)); x+=dx
        buttons.Button("times",(x,y)); x+=dx
        buttons.Button("equals",(x,y))
        self.slider=slider.Slider(g.sx(20.5),g.sy(20.5),10,utils.GREEN)
        if self.journal: # Sugar only
            a,b,c,d=pygame.cursors.load_xbm('my_cursor.xbm','my_cursor_mask.xbm')
            pygame.mouse.set_cursor(a,b,c,d)
        self.level1() # initial animation
        going=True
        while going:
            self.level=g.level
            # Pump GTK messages.
            while gtk.events_pending():
                gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type==pygame.QUIT:
                    if not self.journal: utils.save()
                    going=False
                elif event.type == pygame.MOUSEMOTION:
                    g.redraw=True
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw=True
                    if event.button==2: # centre button
                        if not self.journal:
                            g.version_display=not g.version_display; break
                    bu=buttons.check()
                    if bu=='':
                        if not self.check_numbers():
                            if self.slider.mouse(): self.level1()
                    else: self.do_button(bu) # eg do_button('plus')
            if not going: break
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                pygame.display.flip()
                g.redraw=False
            tf=False
            if pygame.mouse.get_focused(): tf=True
            pygame.mouse.set_visible(tf)
            g.clock.tick(40)
Ejemplo n.º 12
0
 def buttons_setup(self):
     d = g.d + g.space
     x = g.xc
     y = g.y0 + d
     dy = d
     buttons.Button('reset', (x, y), True)
     y += dy
     buttons.Button('new', (x, y), True)
     y += dy
     g.yc = y + d + d  # for count
     if g.count == 0: buttons.off('new')
     if g.started == 0:
         buttons.off('reset')  # turned on when tile placed by sud.click()
Ejemplo n.º 13
0
 def buttons_setup(self):
     cx = g.sx(3.7)
     cy = g.sy(16.4)
     dx = g.sy(3.6)
     dy = g.sy(3.3)
     buttons.Button('cls', (cx, cy))
     cx += dx
     buttons.Button('run', (cx, cy))
     cx -= dx
     cy += dy
     buttons.Button('grid', (cx, cy))
     cx += dx
     buttons.Button('hide', (cx, cy))
Ejemplo n.º 14
0
 def buttons_setup(self):
     cx = g.sx(29.5)
     cy = g.sy(5)
     dy = g.sy(3)
     buttons.Button('cyan', (cx, cy))
     cy += dy
     buttons.Button('green', (cx, cy))
     cy += dy
     buttons.Button('red', (cx, cy))
     cy += dy
     buttons.Button('reset', (cx, cy))
     cy += dy
     buttons.Button('one', (cx, cy))
     cy += dy
     if g.pattern == 1: buttons.off('one')
Ejemplo n.º 15
0
    def __init__(self):
        """Initialize the settings"""
        self.game_active = True
        self.settings = settings.Settings()
        self.screen_width = self.settings.WIDTH
        self.screen_height = self.settings.HEIGHT
        self.bg_color = self.settings.bg_color
        self.click = False
        self.current_color = (0, 0, 0)
        self.current_size = 5

        # initialize the screen
        self.screen = pygame.display.set_mode(
            (self.screen_width, self.screen_height))
        pygame.display.set_caption("Paint!")

        # initialize different buttons
        self.color_buttons = []
        self.initialize_color_buttons()
        self.size_buttons = []
        self.initialize_size_buttons()
        self.eraser = buttons.Button(self, self.settings.WIDTH / 2,
                                     self.settings.HEIGHT / 2)
        self.eraser_on = False

        # initialize the pen
        self.drawings = pygame.sprite.Group()
Ejemplo n.º 16
0
 def buttons_setup(self):
     cy=g.sy(5.8); dx=g.sy(4.87); dy=g.sy(7.1); n=1
     for r in range(3):
         cx=g.sx(3.82)
         for c in range(6):
             buttons.Button(str(n),(cx,cy),colour='yellow')
             buttons.off(str(n))
             cx+=dx; n+=1
         cy+=dy
     cx,cy=g.sx(29),g.h-g.sy(7.2); dy=g.sy(3.5)
     buttons.Button('menu',(cx,cy))
     buttons.Button('help',(g.sy(3),cy)); cy+=dy
     buttons.Button('new',(cx,cy),colour='cyan')
     g.bw=(g.sy(3),cy)
     k=g.sy(3); g.star_c=[(k+g.offset,k),(g.w-k+g.offset,k)]
     self.menu()
Ejemplo n.º 17
0
 def __init__(self):
     self.PIN1 = 16
     self.b = buttons.Button(self.PIN1, cb=self.set_btn_evt)
     self.lcd = i2c_lcd.lcd(0x3f)
     self.lcd.lcd_clear()
     self.lcd_mq = Queue()
     self.lcd_evt = Event()
Ejemplo n.º 18
0
    def addButton(self, height, width, x, y, returnValue):

        self.buttons.append(
            (returnValue,
             buttons.Button(int((g.height / 200) * height),
                            int((g.width / 320) * width), (int(
                                (g.width / 320) * x), int(
                                    (g.height / 200) * y)))))
Ejemplo n.º 19
0
 def buttons_setup(self):
     if self.sugar:
         self.tick_button.set_sensitive(False)
         self.back_button.set_sensitive(False)
         return
     dx = g.sy(4)
     cx = g.sx(16) - 1.5 * dx
     cy = g.sy(15)
     buttons.Button('new', (cx, cy))
     cx += dx
     buttons.Button('tick', (cx, cy))
     cx += dx
     buttons.off('tick')
     buttons.Button('back', (cx, cy))
     cx += dx
     buttons.off('back')
     buttons.Button('help', (cx, cy))
Ejemplo n.º 20
0
    def __init__(self, player_count):
        self.turn = 0
        self.players = []
        self.game_display = pygame.display.set_mode(var.resolution,
                                                    pygame.HWSURFACE)
        pygame.display.set_caption("Risk")
        for i in range(player_count):
            self.players.append(areas.Player(self, i))

        menu_back = pygame.image.load("menukuvat/menumap.png").convert()
        self.menu_back = pygame.transform.scale(
            menu_back, (var.gameWidth, var.gameHeight))
        self.game_display.blit(self.menu_back, (0, 0))

        pygame.mixer.music.load("music/emergence_menu.wav")
        pygame.mixer.music.play(loops=-1)

        load_progress = 0
        load_button = but.Button(self,
                                 int(var.gameWidth / 2),
                                 int(var.gameHeight / 2),
                                 "Loading " + str(load_progress) + " %",
                                 "menukuvat/nonvisible.png",
                                 150,
                                 60,
                                 color=(100, 150, 100))

        t1 = t.time()
        load_button.draw()
        pygame.display.update()

        #some state variables
        file_names = []
        self.territories = []
        #first the names of the pictures and then load the pictures
        file_names.extend(
            ["karttapalat/" + name for name in os.listdir("karttapalat/")])
        for i in range(len(file_names)):
            picture = pygame.image.load(
                "karttapalat/" + file_names[i].split("/")[-1]).convert_alpha()
            picture = pygame.transform.scale(picture,
                                             (var.gameWidth, var.gameHeight))
            mask = pygame.mask.from_surface(picture, 127)
            self.territories.append(areas.Territory(0, 0, i, mask, self))
            if (self.territories[-1].territory_number + 1) % 10 == 0:
                load_progress += 25
                load_button.update("Loading " + str(load_progress) + " %")
                self.game_display.blit(self.menu_back, (0, 0))
                load_button.draw()
                pygame.display.update(load_button.rect)

        print(t.time() - t1)

        self.selected_territory = None
        self.selected_enemy = None
        self.start_phase = True
        self.reinforcement_phase = False
Ejemplo n.º 21
0
 def initialize_color_buttons(self):
     """initialize the color choice buttons"""
     colors = ['black', 'red', 'blue', 'green', 'white']
     for i in range(0, len(colors)):
         self.color_buttons.append(
             buttons.Button(
                 self,
                 self.screen_width / 2 + (self.settings.b_width + 5) * i,
                 3 * self.screen_height / 4))
         self.color_buttons[i].set_color(colors[i])
Ejemplo n.º 22
0
    def loadGame(self, position, color):

        self.loadGame_button = buttons.Button(self.window,
                                              position,
                                              self.dimension_button,
                                              color,
                                              writing='Load Game')

        #Keeps track of button
        self.buttons_in_use.append(self.loadGame_button)
Ejemplo n.º 23
0
    def exit(self, position, color):

        self.exit_button = buttons.Button(self.window,
                                          position,
                                          self.dimension_button,
                                          color,
                                          writing='Exit')

        #Keeps track of button
        self.buttons_in_use.append(self.exit_button)
Ejemplo n.º 24
0
 def initialize_size_buttons(self):
     """Initializes the size choice buttons"""
     sizes = ['small', 'medium', 'large']
     for i in range(len(sizes)):
         self.size_buttons.append(
             buttons.Button(
                 self,
                 self.screen_width / 2 + (self.settings.b_width + 5) * i,
                 3 * self.screen_height / 4 + self.settings.b_height + 5))
         self.size_buttons[i].set_size(sizes[i], self)
Ejemplo n.º 25
0
    def displayVictory(self):
        winner = self.territories[0].owner
        quit_notice = but.Button(self, int(var.gameWidth / 2),
                                 int(var.gameHeight / 2),
                                 "Player " + str(winner.number + 1) + " wins!",
                                 "menukuvat/nonvisible.png", 150, 60)
        quit_notice.draw()
        pygame.display.update()

        while 1:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    quit()
Ejemplo n.º 26
0
 def __init__(self, playerShip):
     
     self.ironSeed = playerShip
     self.thePlanet = "Placeholder"
     self.systemState = 14
     self.planetCommsStage = 0  #  Setup/interaction stage.
     self.musicState = False
     
     #  Graphics related
     self.planetCommsInterface = pygame.image.load(os.path.join('Graphics_Assets', 'com.png'))
     self.planetCommsInterfaceScaled = pygame.transform.scale(self.planetCommsInterface, (g.width, g.height))
     self.planetCommsInterfaceScaled.set_colorkey(g.WHITE)  # !
     
     #  There are rather a lot of alien backgrounds, so we will
     #  Use an array to store them.
     self.alienBackground = []
     
     self.loadBackgrounds()
     
     #  The alien textures are much the same.
     self.alienTextures = []
     
     self.loadAlienTextures()
     
     #  Alien graphics as an array of arrays.
     
     self.aliens = []
     
     #  With the alien textures, they appear to almost be unique per alien
     #  in terms of available elements, sizes etc.
     #  It will necessary to create an alien texture format tab delimited
     #  file with some semblance of formatting along the lines of:
     #  Alien Type
     #  Graphic, frame amount
     #  co-ordinate 1 etc.
     #  Keep repeating until EOA, then next alien entry.
     
     #  Create individual graphical elements.
     
     
     
     #  Define button positions scaled from a 320x200 screen.
     #  Note: expect this to be very buggy!  Placeholder class in effect.
     #  Button positions and handler objects.
     #  Positional buttons for the screen options.
     self.exit = buttons.Button(int((g.height/200)*9),
                                int((g.width/320)*16),
                                (int((g.width/320)*310),
                                 int((g.height/200)*152)))
Ejemplo n.º 27
0
 def bu_setup(self):
     self.bu = {'N': None, 'S': None, 'E': None, 'W': None, 'X': None}
     x0 = g.sx(23.2)
     y0 = g.sy(15.8)
     dx = g.sy(2.2)
     dy = dx
     for v in 'NSEWX':
         if v == 'N':
             x = x0
             y = y0 - dy
         if v == 'S':
             x = x0
             y = y0 + dy
         if v == 'E':
             x = x0 + dx
             y = y0
         if v == 'W':
             x = x0 - dx
             y = y0
         if v == 'X':
             x = x0
             y = y0
         self.bu[v] = buttons.Button(v, (x, y), True)
     buttons.Button('new', (g.sx(30), g.sy(20)), True)
Ejemplo n.º 28
0
 def buttons_setup(self):
     cx=g.sx(1.8); cy=g.sy(18.8); dx=g.sy(3.2); dy=g.sy(2)
     buttons.Button('green',(cx,cy)); cx+=dx
     buttons.Button('yellow',(cx,cy)); cx+=dx
     buttons.Button('cream',(cx,cy)); cx+=dx
     buttons.Button('cyan',(cx,cy))
     self.load_c=cx,cy+dy; cx+=dx; self.load_d=g.sy(.5)
     buttons.Button('orange',(cx,cy))
     self.save_c=cx,cy+dy; cx+=dx
     buttons.Button('help',(g.sx(27.77),g.sy(2.8)))
Ejemplo n.º 29
0
def popup(filename, x, y):  # eg data/1a.txt - x,y is the button posn
    layout = Layout(g.w - 2 * g.offset, g.h, (255, 255, 220))
    maxx, maxy = render(layout, filename)
    border = g.sy(.15)
    b2 = 2 * border
    surf = pygame.Surface((maxx + b2, maxy + b2))
    surf.fill(utils.MAGENTA)
    surf.blit(layout.surf, (border, border), (0, 0, maxx, maxy))
    bu = buttons.Button("yellow", (x + g.offset, y), False)
    dy = bu.up.get_height()
    y += dy / 4
    if (x + maxx + b2) > layout.w: x = layout.w - maxx - b2
    if (y + maxy + b2) > g.screen.get_height():
        y = g.screen.get_height() - maxy - b2
    g.popups.append((bu, filename, surf, x + g.offset, y))
    return dy
Ejemplo n.º 30
0
 def buttons_setup(self):
     cx1 = g.sx(1.5)
     cy1 = g.sy(1.5)
     cx2 = g.sx(32) - g.sy(1.5)
     cy2 = g.sy(19.8)
     buttons.Button('clear', (cx1, cy1), caption='clear', colour='yellow')
     buttons.Button('try', (cx2, cy2), caption='try', colour='yellow')
     buttons.Button('minus', (cx1, cy2), caption='dash', colour='yellow')
     buttons.Button('space', (cx1 + g.sy(3), cy2),
                    caption='space',
                    colour='yellow')
     buttons.Button('replay', (cx2, cy1), caption='replay', colour='yellow')
     dx = g.sy(2.4)
     bx = g.sx(16) - dx
     by = g.sy(20.2)
     buttons.Button('bk', (bx, by), True)
     bx += dx
     buttons.Button('blue', (bx, by), True)
     bx += dx
     buttons.Button('fd', (bx, by), True)
     buttons.Button('back', (g.sx(2), g.sy(18)), True)
     buttons.off(('fd', 'blue', 'bk', 'back'))