Beispiel #1
0
dialog.set_is_visible(False)



# Create a button that pulls up the dialog
button = Button(100, 100, 200, 50)
button.fill(pygame.Color(100, 100, 0))
button.set_alpha(255)

def show_dialog(args):

    s = Card("Colonel Mustard", CardType.SUSPECT, "Colonel Mustard")
    args['d'].set_unavailable_players([s])
    args['d'].set_is_visible(True)

button.set_on_click(show_dialog, {'d': dialog})

backgroundview = View(0, 0, 1000, 1000)
backgroundview.fill(pygame.Color(255, 255, 255))
backgroundview.set_alpha(255)



# ENTER MAIN GAME LOOP
while not crashed:

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            crashed = True

    backgroundview.draw(pygame.mouse, gameDisplay)
Beispiel #2
0

# Define a fucntion to be executed when big button is hovered over
def big_hover(args):
    args['b'].fill(pygame.Color(0, 0, 100))
    args['b'].set_alpha(255)


# Set a default action. Really only useful for making Button a default color
def big_default(args):
    args['b'].fill(pygame.Color(0, 255, 0))
    args['b'].set_alpha(100)


# Set action, and pass big_button as a parameter
big_button.set_on_click(big_clicked, {'b': big_button})
big_button.set_on_hover_action(big_hover, {'b': big_button})
big_button.set_default_action(big_default, {'b': big_button})

# Create one button as a sub view of Button
sm_button_1 = Button(20, 20, 50, 50)
sm_button_2 = Button(70, 70, 50, 50)


# A button's action doesn't have to reference itself or a sub/superview
# For example, when sm_button_1 is clicked, change enabled status of sm_button_2
def sm_button_1_click(args):
    # This references a reference of sm_button_1 in args
    args['b'].fill(pygame.Color(100, 100, 0))
    # This references a local variable in button_example.py
    sm_button_2.set_enabled(True)