Пример #1
0
def make_buttons():
    button_vertical_spacing = 60
    data.buttons.append(
        graphics.Button((20, 20), "Vertex Mode", button_vertex_callback))
    data.buttons[0].selected = True
    data.buttons.append(
        graphics.Button((20, 20 + button_vertical_spacing), "Edge Mode",
                        button_edge_callback))
    data.buttons.append(
        graphics.Button((20, 20 + 2 * button_vertical_spacing), "Infect Mode",
                        button_infect_callback))
    data.buttons.append(
        graphics.Button((20, 20 + 3 * button_vertical_spacing), "Step",
                        button_step_callback, False))
    data.buttons.append(
        graphics.Button((20, 20 + 4 * button_vertical_spacing), "TEST",
                        button_test_callback, False))
    data.buttons.append(
        graphics.Button((20, 20 + 5 * button_vertical_spacing),
                        "Play Infection", button_play_callback, False))
    data.buttons.append(
        graphics.Button((20, 20 + 6 * button_vertical_spacing),
                        "List of Dates", button_list_dates, False))
    data.buttons.append(
        graphics.Button((20, 20 + 7 * button_vertical_spacing),
                        "Run multiple times", button_copy_run, False))
    data.buttons.append(
        graphics.Button((20, 20 + 8 * button_vertical_spacing),
                        "Write it down", button_record_dates, False))
    data.input_boxes.append(
        graphics.InputBox((data.WIDTH - 140, 160), input_box_p_callback))
    data.input_boxes.append(
        graphics.InputBox((data.WIDTH - 140, 210), input_box_d_callback))
    data.input_boxes.append(
        graphics.InputBox((data.WIDTH - 140, 260), input_box_repeats_callback))
Пример #2
0
    def __init__(self):
        self.graphics = graphics.Graphics()
        self.titleScreen = self.graphics.loadImage("start.png")
        self.pauseScreen = self.graphics.loadImage("pause.png")
        self.winScreen = self.graphics.loadImage("win.png")
        self.loseScreen = self.graphics.loadImage("lose.png")
        self.world = world.World()
        self.state = GAMESTATE_TITLE

        #create human player
        self.human = player.Player(self.graphics, self.world, team=1)
        position = (0, 0)
        colony = mapobject.Colony(self.human, position, self.graphics)
        self.world.addObject(colony)
        self.human.addColony(colony)

        #create AI Player
        self.AIPlayer = aiplayer.AIPlayer(self.graphics, self.world,
                                          team=2)  #ai does nothing yet
        #generate random position for AI colony
        randomAngle = random.randint(0, 360)
        randomDist = math.sqrt(
            random.random() * ((MAXAIDISTANCE - MINAIDISTANCE)**2)
        ) + MINAIDISTANCE  #this ensures that the random targets are uniformly spread out over the sector
        position = (position[0] +
                    randomDist * math.cos(randomAngle * math.pi / 180),
                    position[1] +
                    randomDist * math.sin(randomAngle * math.pi / 180))

        colony = mapobject.Colony(self.AIPlayer,
                                  position,
                                  self.graphics,
                                  team=2)
        #print "AI position: " + str(position)
        self.world.addObject(colony)
        self.AIPlayer.addColony(colony)

        self.world.addLeaves(self.graphics)  #add lots of random leaves

        self.input = Input()
        self.input.onClick(self.leftClick)
        self.input.onRightClick(self.rightClick)
        self.input.onDrag(self.drag)

        #make gui
        self.gui = graphics.ContainerWidget()
        self.gui.add(graphics.ResourceDisplay(self.human))
        workerImage = self.graphics.loadImage('workerbutton.png')
        soldierImage = self.graphics.loadImage('soldierbutton.png')
        buildWidget = graphics.BuildWidget(pygame.Rect((0, 0), (116, 61)),
                                           (200, 200, 200))
        buildWidget.add(
            graphics.Button(pygame.Rect((0, 0), (50, 50)),
                            image=soldierImage,
                            bgColor=(100, 100, 100),
                            action=self.buySoldier))
        buildWidget.add(
            graphics.Button(pygame.Rect((0, 0), (50, 50)),
                            image=workerImage,
                            bgColor=(100, 100, 100),
                            action=self.buyWorker))
        self.gui.add(buildWidget)
        position = self.graphics.normalizeScreenCoords((-150, -150))
        rect = pygame.Rect(position, (150, 150))
        minimap = graphics.Minimap(rect, self.world, self.graphics)
        self.gui.add(minimap)
        try:
            pygame.mixer.init()
            self.music = True
        except:
            self.music = False

        if self.music:
            try:
                self.titlemusic = pygame.mixer.Sound(
                    data.filepath('titlemusic.ogg'))
                self.titlemusic.play(-1)
            except:
                self.music = False
Пример #3
0
    def __init__(self):
        self.win = g.GraphWin("Longest and Shortest in the Bible", 600, 600)
        self.win.setCoords(1, 15, 14, 0)

        self.quitButton = g.Button("Quit", g.Point(2, 1), g.Point(7, 2))
        self.quitButton.activate()
        self.quitButton.draw(self.win)
        self.mainButton = g.Button("Main Menu", g.Point(8, 1), g.Point(13, 2))
        self.mainButton.activate()
        self.mainButton.draw(self.win)

        self.introText = g.Text(g.Point(7.5, 3), "Bible Counter")
        self.introText.setStyle("bold")
        self.introText.draw(self.win)
        text1 = g.Text(g.Point(7.5, 4), "Welcome")
        text2 = g.Text(g.Point(7.5, 5), "This program finds the chapter, book, or verse")
        text3 = g.Text(g.Point(7.5, 6), "With the most or least chapters, words, characters, or verses")
        text4 = g.Text(g.Point(7.5, 7), "")
        text5 = g.Text(g.Point(7.5, 8), "")

        self.textboxes = [text1, text2, text3, text4, text5]
        for x in self.textboxes:
            time.sleep(1)
            x.draw(self.win)
        time.sleep(1)

        self.verseButton = g.Button("Verses", g.Point(2, 9), g.Point(5, 10))
        self.verseButton.draw(self.win)

        self.chapterButton = g.Button("Chapters", g.Point(6, 9), g.Point(9, 10))
        self.chapterButton.draw(self.win)

        self.bookButton = g.Button("Books", g.Point(10, 9), g.Point(13, 10))
        self.bookButton.draw(self.win)

        opt1 = g.Button("Most\nChapters", g.Point(2, 11), g.Point(4, 12))
        opt3 = g.Button("Most\nVerses", g.Point(5, 11), g.Point(7, 12))
        opt5 = g.Button("Most\nWords", g.Point(8, 11), g.Point(10, 12))
        opt7 = g.Button("Most\nCharacters", g.Point(11, 11), g.Point(13, 12))
        opt2 = g.Button("Least\nChapters", g.Point(2, 13), g.Point(4, 14))
        opt4 = g.Button("Least\nVerses", g.Point(5, 13), g.Point(7, 14))
        opt6 = g.Button("Least\nWords", g.Point(8, 13), g.Point(10, 14))
        opt8 = g.Button("Least\nCharacters", g.Point(11, 13), g.Point(13, 14))
        self.options = [opt1, opt2, opt3, opt4, opt5, opt6, opt7, opt8]
        for opt in self.options:
            opt.draw(self.win)

        time.sleep(1)
        self.mainMenu()
Пример #4
0
shoot_image = pygame.image.load("images\shoot_image.jpg")

username = ""

#authentication screen
login_background = pygame.image.load("authen.jpg")
login_username_box = graphics.TextBox(screen, 200, 175, 350, 40, "username")
login_password_box = graphics.TextBox(screen,
                                      200,
                                      241,
                                      350,
                                      40,
                                      "password",
                                      hide=True)
login_button = graphics.Button(195, 307, 360, 43, "sign in")
create_account_button = graphics.Button(394, 371, 151, 20, "create account")
login_error_box = graphics.DialogBox(screen, 195, 123,
                                     "wrong password or username")

#register screen
signup_background = pygame.image.load("signup.jpg")
signup_username_box = graphics.TextBox(screen, 200, 170, 350, 40, "username")
signup_password_box = graphics.TextBox(screen,
                                       200,
                                       236,
                                       350,
                                       40,
                                       "password",
                                       hide=True)
signup_confirm_box = graphics.TextBox(screen,
Пример #5
0
    def __init__(self, app, channel: audio.Channel, y_off=0):
        self.app = app
        self.channel = channel
        self.channel.update()
        self.color = channel.color
        y_off *= self.SPACING
        self.y = y_off
        self.scroll_y = 0

        # DIVS
        self.channel_view = graphics.Canvas(app,
                                            0.7,
                                            0.2,
                                            0.1,
                                            0.0 + y_off,
                                            bg=self.BG,
                                            border_width=1,
                                            border_color=self.color,
                                            xoffset=-1,
                                            yoffset=0 + self.y,
                                            hoffset=-2)
        self.presets = graphics.Div(app,
                                    0.1,
                                    0.2,
                                    0.0,
                                    0.0 + y_off,
                                    bg=self.BG,
                                    border_width=1,
                                    border_color=self.color)
        self.buttons = graphics.Div(app,
                                    0.2,
                                    0.2,
                                    0.8,
                                    0.0 + y_off,
                                    bg=self.BG,
                                    border_width=1,
                                    border_color=self.color)

        # PRESETS
        #self.compression_label = graphics.Label(app, '', y=0.01 + y_off, fg=self.FG_1, bg=self.BG)
        #self.compression_label.define_pre_label('COMP ')
        self.mono_label = graphics.Label(app,
                                         '',
                                         y=0.01 + y_off,
                                         fg=self.FG_1,
                                         bg=self.BG,
                                         fontscale=1.0)
        self.track_count_label = graphics.Label(app,
                                                '',
                                                y=0.06 + y_off,
                                                fg=self.FG_1,
                                                bg=self.BG)

        # TRACK NAME
        self.track_name_label = graphics.Label(app,
                                               '',
                                               x=0.1,
                                               y=0.002 + y_off,
                                               fontscale=1.3,
                                               fg=self.FG_2,
                                               bg=self.BG)

        # TIME
        self.elapsed_label = graphics.Label(app,
                                            '',
                                            x=0.12,
                                            y=0.16 + y_off,
                                            yoffset=-10,
                                            fontscale=0.9,
                                            fg=self.FG_2,
                                            bg=self.BG)
        self.total_label = graphics.Label(app,
                                          '',
                                          x=0.7,
                                          y=0.16 + y_off,
                                          yoffset=-10,
                                          fontscale=0.9,
                                          fg=self.FG_2,
                                          bg=self.BG)

        # NEXT PREV
        self.prev_label = graphics.Label(app,
                                         '',
                                         x=0.13,
                                         y=0.067 + y_off,
                                         fontscale=1,
                                         fg=self.FG_1,
                                         bg=self.BG)
        self.prev_label.define_pre_label('Prev: ')
        self.next_label = graphics.Label(app,
                                         '',
                                         x=0.45,
                                         y=0.067 + y_off,
                                         fontscale=1,
                                         fg=self.FG_1,
                                         bg=self.BG)
        self.next_label.define_pre_label('Next: ')

        # BAR
        self.timebar = graphics.ProgressBar(app,
                                            self.channel_view,
                                            x=0.18,
                                            y=0.8,
                                            w=0.65,
                                            h=0.1,
                                            xoffset=10,
                                            yoffset=-5,
                                            fill_color=self.color,
                                            border_color=self.color)

        # CHANNEL
        self.channel_label = graphics.RightAlignLabel(app,
                                                      self.channel.name,
                                                      x=0.817,
                                                      y=0.005 + y_off,
                                                      fontscale=1.5,
                                                      fg=self.color,
                                                      bg=self.BG)

        # PAUSED
        self.paused_label = graphics.Label(app,
                                           '',
                                           x=0.7,
                                           y=0.065 + y_off,
                                           fontscale=1.3,
                                           fg='white',
                                           bg=self.BG)

        # BUTTONS
        LINE1Y = 0.03
        LINE2Y = 0.11
        CENTERX = 0.8875
        SIZE = 0.02

        self.pause_button = graphics.Button(app,
                                            SIZE,
                                            SIZE,
                                            CENTERX + 0.0,
                                            LINE1Y + y_off,
                                            img_name=app.IMG + 'play.png',
                                            img_scale=0.9,
                                            background=self.BUTTONBG,
                                            cmd=self.cmd_play)
        self.next_button = graphics.Button(app,
                                           SIZE,
                                           SIZE,
                                           CENTERX + 0.03,
                                           LINE1Y + y_off,
                                           img_name=app.IMG + 'next.png',
                                           background=self.BUTTONBG,
                                           cmd=self.cmd_next)
        self.last_button = graphics.Button(app,
                                           SIZE,
                                           SIZE,
                                           CENTERX + 0.06,
                                           LINE1Y + y_off,
                                           img_name=app.IMG + 'last.png',
                                           background=self.BUTTONBG,
                                           cmd=self.cmd_last)
        self.prev_button = graphics.Button(app,
                                           SIZE,
                                           SIZE,
                                           CENTERX - 0.03,
                                           LINE1Y + y_off,
                                           img_name=app.IMG + 'prev.png',
                                           background=self.BUTTONBG,
                                           cmd=self.cmd_back)
        self.first_button = graphics.Button(app,
                                            SIZE,
                                            SIZE,
                                            CENTERX - 0.06,
                                            LINE1Y + y_off,
                                            img_name=app.IMG + 'first.png',
                                            background=self.BUTTONBG,
                                            cmd=self.cmd_first)

        self.stop_button = graphics.Button(app,
                                           SIZE,
                                           SIZE,
                                           CENTERX,
                                           LINE2Y + y_off,
                                           img_name=app.IMG + 'stop.png',
                                           img_scale=0.8,
                                           background=self.BUTTONBG,
                                           cmd=self.cmd_stop)

        self.ch_gain_label = graphics.Label(app,
                                            'CH GAIN',
                                            x=0.9275,
                                            y=0.15 + y_off,
                                            fontscale=0.6,
                                            fg=self.FG_1,
                                            bg=self.BG)
        self.tr_gain_label = graphics.Label(app,
                                            'TR GAIN',
                                            x=0.82,
                                            y=0.15 + y_off,
                                            fontscale=0.6,
                                            fg=self.FG_1,
                                            bg=self.BG)

        self.ch_gain_inc = graphics.Incrementor(app,
                                                min=self.GAIN_MIN,
                                                max=self.GAIN_MAX,
                                                step=self.GAIN_STEP_INC,
                                                x=0.92,
                                                y=0.111 + y_off,
                                                w=5,
                                                yoffset=0,
                                                bg='#000',
                                                fg=self.color,
                                                buttonbg=self.BUTTONBG,
                                                fontscale=1)
        self.tr_gain_inc = graphics.Incrementor(app,
                                                min=self.GAIN_MIN,
                                                max=self.GAIN_MAX,
                                                step=self.GAIN_STEP_INC,
                                                x=0.8125,
                                                y=0.111 + y_off,
                                                w=5,
                                                yoffset=0,
                                                bg='#000',
                                                fg=self.color,
                                                buttonbg=self.BUTTONBG,
                                                fontscale=1)

        self.parts = (
            self.channel_view,
            self.presets,
            self.buttons,
            self.mono_label,
            self.track_count_label,  # Removed gain and comp labels
            self.track_name_label,
            self.elapsed_label,
            self.total_label,
            self.next_label,
            self.prev_label,
            self.channel_label,
            self.paused_label,  # no timebar
            self.pause_button,
            self.next_button,
            self.last_button,
            self.prev_button,
            self.first_button,
            self.stop_button,
            self.ch_gain_label,
            self.tr_gain_label,
            self.ch_gain_inc,
            self.tr_gain_inc)

        app.track(self)
        self.update_labels()
        self.update_times()
        self.ch_gain_inc.set(str(self.channel.gain))
        self.tr_gain_inc.set(str(self.current.gain))
Пример #6
0
    def __init__(self, app, cue_manager):
        self.cm: cues.CueManager = cue_manager
        self.app = app

        self.box = graphics.Div(app,
                                w=0.8,
                                h=0.1,
                                x=0.1,
                                y=0.9,
                                bg=self.BG,
                                border_color=self.BD,
                                border_width=1,
                                yoffset=1,
                                hoffset=2)

        self.prev_label = graphics.Label(app,
                                         x=0.105,
                                         y=0.915,
                                         fg=self.FG_1,
                                         bg=self.BG,
                                         fontscale=0.8)
        self.prev_label.define_pre_label('Last: ')
        self.next_label = graphics.Label(app,
                                         x=0.105,
                                         y=0.955,
                                         fg=self.FG_1,
                                         bg=self.BG,
                                         fontscale=0.8)
        self.next_label.define_pre_label('Next: ')

        self.current_label = graphics.Label(app,
                                            x=0.35,
                                            y=0.905,
                                            yoffset=1,
                                            fg=self.FG_2,
                                            bg=self.BG,
                                            fontscale=1.4)
        #self.current_label.define_pre_label('Now: ')
        self.next_cmd = graphics.Label(app,
                                       x=0.35,
                                       y=0.945,
                                       yoffset=7,
                                       fg=self.FG_3,
                                       bg=self.BG,
                                       fontscale=0.7,
                                       h=0.01,
                                       anchor='n')

        self.prev_button = graphics.Button(app,
                                           w=0.02,
                                           h=0.06,
                                           x=0.065,
                                           y=0.92,
                                           img_name=self.app.IMG + 'first.png',
                                           background=self.BBG_1,
                                           activebackground=self.ABBG_1,
                                           cmd=self.cm.back)
        self.next_button = graphics.Button(app,
                                           w=0.02,
                                           h=0.06,
                                           x=0.915,
                                           y=0.92,
                                           xoffset=-4,
                                           img_name=self.app.IMG + 'last.png',
                                           background=self.BBG_1,
                                           activebackground=self.ABBG_1,
                                           cmd=self.cm.next)

        self.stop_all_button = graphics.Button(app,
                                               w=0.02,
                                               h=0.06,
                                               x=0.029,
                                               y=0.92,
                                               img_name=self.app.IMG +
                                               'stop2.png',
                                               background=self.BBG_2,
                                               activebackground=self.ABBG_2,
                                               cmd=self.cm.m.stop_all,
                                               img_scale=0.98)
        self.go_button = graphics.Button(app,
                                         w=0.02,
                                         h=0.06,
                                         x=0.95,
                                         y=0.92,
                                         xoffset=-4,
                                         img_name=self.app.IMG + 'go.png',
                                         background=self.BBG_2,
                                         activebackground=self.ABBG_2,
                                         cmd=self.cm.do,
                                         img_scale=1.05)

        app.track(self)