Ejemplo n.º 1
0
# 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)

    # When a view isn't available, it's best to never draw it at all
Ejemplo n.º 2
0
import sys, os
import pygame

myPath = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, myPath + '/../')

from src.view import View

pygame.init()
gameDisplay = pygame.display.set_mode((800, 600))
crashed = False

clock = pygame.time.Clock()

top_view = View(0, 0, 200, 400)
top_view.fill(pygame.Color(100, 0, 0))
top_view.set_alpha(255)

sub_view = View(10, 10, 180, 380)
sub_view.fill(pygame.Color(0, 100, 0))
sub_view.set_alpha(255)

# Add sub_view as a subview to top_view
top_view.add_view(sub_view)

sub_sub_view = View(20, 20, 100, 300)
sub_sub_view.fill(pygame.Color(0, 0, 100))
sub_sub_view.set_alpha(255)

# Add sub_sub_view as a subview to sub_sub_view
sub_view.add_view(sub_sub_view)