def main(): screen_width = 600 screen_height = 500 frames_per_second = 30 game = Main(screen_width, screen_height, frames_per_second) game.main_loop() return
def main(): try: game = Uttt(config.TITLE, config.SCREEN_X, config.SCREEN_Y, \ config.FRAMES_PER_SECOND) game.main_loop() finally: pygame.quit()
def main(): if len(sys.argv) > 1: starting_level = int(sys.argv[1]) else: starting_level = 1 game = ToadsAdventure(starting_level, MAP_TILES_FILENAME, CHARACTER_TILES_FILENAME) game.main_loop()
def main(): screen_width = 600 screen_height = 500 frames_per_second = 20 game = PygameStarter(screen_width, screen_height, frames_per_second) game.main_loop() if game.Cpoint == game.winner: print ('Computer Wins!') game.EndGame(game.Cpoint) if game.Upoint == game.winner: print ('You Win!') game.EndGame(game.Upoint) return
def main(): game = AsteroidsGame() game.main_loop()
def main(): pygame.font.init() game = PygameApp(TITLE, WINDOW_WIDTH, WINDOW_HEIGHT, DESIRED_RATE) game.main_loop()
#/usr/bin/python import game if __name__ == "__main__": game = game.Game() game.main_loop()
def main(): pygame.font.init() game = PygameApp(700, 700, 30) game.main_loop()
def main( ): pygame.font.init( ) pygame.mixer.init( ) game = PygameApp( TITLE, WINDOW_WIDTH, WINDOW_HEIGHT, DESIRED_RATE ) pygame.display.toggle_fullscreen( ) game.main_loop( )
def main(): menu_running = True # Start menu music pygame.mixer.music.load(globalvars.ASSETS.music_menu) pygame.mixer.music.play(-1) title_x = constants.CAMERA_WIDTH / 2 title_y = constants.CAMERA_HEIGHT / 2 - 40 title_text = "Python - RL" # Button addreses continue_button_y = title_y + 40 new_game_button_y = continue_button_y + 40 options_button_y = new_game_button_y + 40 quit_button_y = options_button_y + 40 continue_game_button = draw.UiButton(globalvars.SURFACE_MAIN, 'CONTINUE', (150, 30), (title_x, continue_button_y)) new_game_button = draw.UiButton(globalvars.SURFACE_MAIN, 'NEW GAME', (150, 30), (title_x, new_game_button_y)) options_button = draw.UiButton(globalvars.SURFACE_MAIN, 'OPTIONS', (150, 30), (title_x, options_button_y)) quit_button = draw.UiButton(globalvars.SURFACE_MAIN, 'QUIT', (150, 30), (title_x, quit_button_y)) while menu_running: list_of_events = pygame.event.get() mouse_position = pygame.mouse.get_pos() game_input = (list_of_events, mouse_position) # Handle menu events for event in list_of_events: if event.type == pygame.QUIT: pygame.quit() sys.exit() # If continue if continue_game_button.update(game_input): # Stop music menu pygame.mixer.music.stop() # Start music game pygame.mixer.music.load(globalvars.ASSETS.music_background) pygame.mixer.music.play(-1) # try to load game, start new if problems. try: game.load() except: game.new() game.main_loop() # If new game if new_game_button.update(game_input): # Stop music menu pygame.mixer.music.stop() # Start music game pygame.mixer.music.load(globalvars.ASSETS.music_background) pygame.mixer.music.play(-1) game.new() game.main_loop() if options_button.update(game_input): options() if quit_button.update(game_input): pygame.quit() sys.exit() # draw menu globalvars.SURFACE_MAIN.blit(globalvars.ASSETS.MAIN_MENU_BG, (0, 0)) text.display(globalvars.SURFACE_MAIN, title_text, constants.FONT_TITLE_SCREEN, (title_x, title_y - 20), constants.COLOR_RED, back_color=constants.COLOR_BLACK, center=True) # Draw the buttons continue_game_button.draw() new_game_button.draw() options_button.draw() quit_button.draw() # update surface pygame.display.update() globalvars.CLOCK.tick(constants.GAME_FPS)
def main(): pygame.font.init() game = Frogger() game.main_loop()
def menu_start(client_context): # GLOBAL CLIENT CONTEXT global context context = client_context global test test = 0 # INIT PYGAME pygame.init() client_context.surface = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Pong!") client_context.clock = pygame.time.Clock() # CONNECT MENU context.menu_connect = pygameMenu.Menu( context.surface, bgfun=client_context.menu_background_draw, color_selected=WHITE, font=pygameMenu.font.FONT_BEBAS, font_color=WHITE, font_size=40, font_size_title=30, menu_alpha=100, menu_color=(20, 67, 109), menu_height=HEIGHT, menu_width=WIDTH, onclose=pygameMenu.events.DISABLE_CLOSE, option_shadow=False, title='MENU', window_height=HEIGHT, window_width=WIDTH, back_box=False, menu_color_title=(20, 32, 52), ) # Add Menu input connect_username = "" if context.username is None else context.username context.menu_connect.add_text_input("Name: ", default=connect_username, maxchar=20, textinput_id="name") context.menu_connect.add_text_input("IP: ", default="192.168.0.200", maxchar=15, textinput_id="ip") context.menu_connect.add_text_input("Port: ", default="8080", maxchar=5, textinput_id="port") context.menu_connect.add_option("CONNECT", menu_connect_action) context.menu_connect.add_option("RECONNECT", menu_reconnect_action) # Connected menu menu_player_init() # ------------------------------------------------------------------------- # Start menu # ------------------------------------------------------------------------- while True: # Clear draw area context.surface.fill(BLACK) # Application events events = list(pygame.event.get()) if context.menu_connect.is_enabled(): # Connection menu context.menu_connect.mainloop(events) else: if context.menu_game.is_enabled(): # Player menu - Starts after Connect menu is disabled menu_player_action_refresh() context.menu_game.mainloop() else: # Main game loop game.main_loop(context) # Flip surface pygame.display.flip()
sdl.Rectangle(200 + 300j, sdl.Dimensions(1000, 10)), sdl.Rectangle(500 + 100j, sdl.Dimensions(10, 1000)), ] if __name__ == '__main__': with sdl.destroying(sdl.Window(b'Title', WINDOW_DIMENSIONS)) as window, \ sdl.destroying(window.renderer()) as renderer, \ sdl.destroying(renderer.load_textures(TEXTURES_PATHS)) as textures: keyboard = sdl.Keyboard() wolfram = Wolfram(position=300 + 0j, textures=textures) def main_callback(delta: utils.Seconds) -> None: print(wolfram.position) renderer.render_clear() for box in solid_boxes: renderer.draw_color = sdl.Color.black() renderer.fill_rectangle(wolfram.checkbox) renderer.fill_rectangle(box) renderer.draw_color = sdl.Color.white() wolfram.handle_keyboard(keyboard) wolfram.update_physics(solid_boxes, delta) wolfram.render(renderer) renderer.render_present() game.main_loop(main_callback, fps=60)