def gameplay(game): game.game_started = True while True: print("gameplay") game.game_loop() if game.game_finished: break
def main(): ''' This is the starting function to start the game ''' game.initialize(WIDTH, HEIGHT, TITLE) game.game_loop(FPS) return 0
def main(): print_header() print_high_scores() print() rolls = build_rolls() name = input("What is your name? ") player1 = game_service.find_or_create_player(name) player2 = game_service.find_or_create_player("computer") game.game_loop(player1, player2, rolls)
def main(): # SETTINGS board_size = 8 n_games = 10000 print_step = 1000 wins = {"left": 0, "right": 0} for i in range(n_games): board = Board(board_size) # SET UP PLAYERS left_player = Random_player(board.left) # left_player = One_ply_player(board.left) # left_player = Minimax_player(board.left, 3) right_player = Random_player(board.right) # play the game winner = game_loop(board, left=left_player, right=right_player, on_turn=left_player, prints=False) if winner == left_player: wins["left"] += 1 if winner == right_player: wins["right"] += 1 if print_step > 0 and (i + 1) % print_step == 0: print(i + 1, "games played") print("left won", wins["left"], "times.") print("right won", wins["right"], "times.")
def main(): option = 'main_menu' # Game screens while option is not 'exit': if option == 'main_menu': option = menu.menu_loop() elif option == 'game': option = game.game_loop() elif option == 'instruction': option = instruction.instruction_loop() else: # game over option = over.over_loop(option[1])
def main(): playMode = 'Play' done = False frame_count = 0 while not done: kbrd.reset_toggle() for event in pygame.event.get(): if event.type == pygame.QUIT: done = True if event.type == pygame.MOUSEBUTTONDOWN: maker.click_event() if event.type == pygame.KEYDOWN: if event.key == ord('\t'): if playMode == 'Play': playMode = 'Make' else: playMode = 'Play' kbrd.give_event(event) frame_count += 1 screen.fill(screenColor) if playMode == 'Play': game_loop() game_draw(screen) if playMode == 'Make': maker.update(pygame.mouse.get_pos()) draw_map(screen) maker.draw(screen) pygame.display.flip() clock.tick_busy_loop(fps) if frame_count % fps == 0: print(clock.get_fps())
import game if __name__ == "__main__": game = game.Game("map.txt") game.game_loop()
""" Snek """ import pygame from game import game_loop from game_objects.game_settings import GameSettings pygame.init() game_settings = GameSettings() display = pygame.display.set_mode(game_settings.display_size, ) pygame.display.set_caption("Py_Snek_Game") game_loop(display, game_settings)
def main(s, Tm): inicio = True while inicio: tela.fill(bg(Tm)) texto("Flash Cat", bc(Tm), 60, u.LARGURA / 3, u.ALTURA / 14) pygame.draw.rect(tela, bt(Tm), [250, 70, 130, 25]) texto("Medio(1)", fcb(Tm), 30, 275, 75) pygame.draw.rect(tela, bt(Tm), [250, 120, 130, 25]) texto("Dificil(2)", fcb(Tm), 30, 275, 125) pygame.draw.rect(tela, bt(Tm), [250, 170, 130, 25]) texto("Insano(3)", fcb(Tm), 30, 275, 175) pygame.draw.rect(tela, u.Vermelho, [510, 0, 130, 25]) texto("Sair(esc)", u.BRANCO, 30, 535, 5) tema(bt(Tm), bc(Tm), Tm) menu_audio(s) control(bc(Tm), fc(Tm)) pygame.display.update() for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_1: inicio = False n = 1 g.game_loop(n, s) if event.key == pygame.K_2: inicio = False n = 2 g.game_loop(n, s) if event.key == pygame.K_3: inicio = False n = 3 g.game_loop(n, s) if event.key == pygame.K_TAB: if s == True: s = False else: s = True pygame.display.update() if event.key == pygame.K_l: u.tema(Tm) pygame.display.update() if event.key == pygame.K_ESCAPE: pygame.quit() if event.type == pygame.MOUSEBUTTONDOWN: x = pygame.mouse.get_pos()[0] y = pygame.mouse.get_pos()[1] if x > 250 and y > 70 and x < 380 and y < 95: inicio = False n = 1 g.game_loop(n, s) if x > 250 and y > 120 and x < 380 and y < 145: inicio = False n = 2 g.game_loop(n, s) if x > 250 and y > 170 and x < 380 and y < 195: inicio = False n = 3 g.game_loop(n, s) if x > 2 and y > 302 and x < 46 and y < 352: if s == True: s = False else: s = True print("mudei") pygame.display.update() if x > 10 and y > 10 and x < 60 and y < 60: u.tema(Tm) pygame.display.update() if x > 510 and y > 0 and x < 640 and y < 25: pygame.quit()
def test_game(): assert game() == True assert print_header() == True assert build_three_rolls == True assert get_players_name == True assert game_loop() == True
from game import game_loop game_loop()