Exemple #1
0
def main():
    user32 = ctypes.windll.user32
    screensize = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)
    os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (
        screensize[0] // 2 - WINDOW_SIZE[0] // 2,
        screensize[1] // 2 - WINDOW_SIZE[1] // 2 - 10)

    pygame.init()
    pygame.mixer.init()

    clock = pygame.time.Clock()

    state = game_state.State(True, Music())

    screen = pygame.display.set_mode(WINDOW_SIZE)
    generator = g.Generator()

    while state.running:
        clock.tick(30)

        controller.handle_events(state)

        if state.reset:
            m = state.music
            state = game_state.State(False, m)
            generator = g.Generator()

        generator.update(state)  # Has to be before state.update()

        state.update()

        graphics.update_screen(screen, state)

    pygame.quit()
Exemple #2
0
 def should_restart(self):
     if self.state == WAITING_FOR_RESTART:
         self.game_state = game_state.State()
         return True
     return False
if the_maze_question == 'y':
    main_grid.create_maze()

pygame.init()

#Set the size of pygame
total_height = get_total_pixel_height(main_grid.num_of_rows)
total_width = get_total_pixel_width(main_grid.num_of_cols)
WINDOW_SIZE = (total_width, total_height)
screen = pygame.display.set_mode(WINDOW_SIZE)
#create a title
pygame.display.set_caption("A* Pathfinder")

# Loop until the user clicks the close button.
state = game_state.State()

# Used to manage how fast the screen updates
clock = pygame.time.Clock()

# -------- Main Program Loop -----------
while not state.done:
    # --- Main event loop
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            state.done = True

        if event.type == pygame.MOUSEBUTTONDOWN:
            button = get_button(pygame.mouse.get_pressed())
            if button == MIDDLE:
                state.run = True
Exemple #4
0
 def __init__(self):
     self.game_state = game_state.State()
     self.state = SELECT_MARBLE_TYPE
     self.selected_marble = None
     self.capture_from = None