def update(self): #self.updateStatusText() self.draw() #for each of the menus instantiated, draw for menu in self.menuList: menu.draw()
def next_round(): global player1 global player2 global winner global bullets screen_pos = screen.get_rect() p1x = screen_pos.centerx - 100 p2x = screen_pos.centerx + 100 py = screen_pos.centery player1 = Player(PLAYER1_COLOR, p1x, py, 20, 0) player2 = Player(PLAYER2_COLOR, p2x, py, 20, math.pi) winner = None bullets = [] number_of_rounds = 2 * menu.draw(screen) + 1 round_count = 1 score = [0, 0] clock = pygame.time.Clock() # create the players screen_pos = screen.get_rect() p1x = screen_pos.centerx - 100 p2x = screen_pos.centerx + 100 py = screen_pos.centery player1 = Player(PLAYER1_COLOR, p1x, py, 20, 0) player2 = Player(PLAYER2_COLOR, p2x, py, 20, math.pi) winner = None
import colours import event_handler gamefield = field.Field() # ======== Инициализируем игровое окно ============= pygame.init() screen = pygame.display.set_mode(gamefield.field_size) screen.fill(colours.BACKGROUND) pygame.display.set_caption('Convey`s game of Life') clock = pygame.time.Clock() # =================================================== # ==== Инициализируем меню, счетчик, режим игры ===== menu = menu.Menu(gamefield) menu.draw(screen) handler = event_handler.EventHandler() done = False mode = 'draw' # В игре пять положения: draw, evolution, restart, quit, pause # =================================================== # ======== Основной цикл игры =========== while not done: mode, done = handler.event_handler(pygame.event.get(), mode, done, gamefield, menu) # Обработка состояний игры if mode == 'draw' or mode == 'pause':
def next_round(): global player1 global player2 global winner global bullets screen_pos = screen.get_rect() p1x = screen_pos.centerx - 100 p2x = screen_pos.centerx + 100 py = screen_pos.centery player1 = Player( PLAYER1_COLOR, p1x, py, 20, 0 ) player2 = Player( PLAYER2_COLOR, p2x, py, 20, math.pi ) winner = None bullets = [] number_of_rounds = 2*menu.draw(screen) + 1 round_count = 1 score = [0,0] clock = pygame.time.Clock() # create the players screen_pos = screen.get_rect() p1x = screen_pos.centerx - 100 p2x = screen_pos.centerx + 100 py = screen_pos.centery player1 = Player( PLAYER1_COLOR, p1x, py, 20, 0 ) player2 = Player( PLAYER2_COLOR, p2x, py, 20, math.pi ) winner = None
# Game initialization hier werden alle objekte erstellt und alle wichtigen variablen erstellt # todo options fahrzeug wählen dafür muss ich eine neue class options erstellen und einenen neuen status game.init() menu = menu.Menu() options = options.Options() clock = pygame.time.Clock() # Gameloop while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() if menu.status == 0: menu.update() menu.draw() options.waitselect = 10 elif menu.status == 1: menu.status = game.update() game.draw() elif menu.status == 2: menu.status = options.update() options.draw() menu.waitselect = 10 pygame.display.flip() clock.tick(30)
y = self.dest_surface.get_rect().centery - self.menu_height / 2 mx, my = self.pozycja_wklejenia self.pozycja_wklejenia = (x + mx, y + my) if __name__ == '__main__': import sys surface = pygame.display.set_mode((854, 480)) surface.fill((51, 51, 51)) menu = Menu() menu.init(['Game Start', 'Difficulty', 'Character', 'Quit'], surface) #necessary pygame.display.set_caption('TetandRis MENU') menu.draw() tmp = 0 tmp2 = 0 pygame.key.set_repeat(199, 69) pygame.display.update() tet = Tetandris() while 1: for event in pygame.event.get(): if event.type == KEYDOWN: if event.key == K_UP: menu.draw(-1) if event.key == K_DOWN: menu.draw(1) if event.key == K_RETURN: if menu.get_position() == 3:
if not pygame.font.get_init(): pygame.font.init() from global_defs import screen #surface = pygame.display.set_mode((854, 480)) screen.fill((51, 51, 51)) pygame.mixer.pre_init(44100, -16, 2, 4096) pygame.init() FindSticks() menu = menu.Menu() menu.init(['Start', 'Options', 'Quit'], screen) # necessary #menu.move_menu(0, 0) # optional menu.draw() # necessary pygame.key.set_repeat(199, 69) # (delay,interval) pygame.display.update() while 1: for event in pygame.event.get(): if event.type == KEYDOWN: if event.key == K_UP: # here is the Menu class method menu.draw(-1) if event.key == K_DOWN: # here is the Menu class method menu.draw(1) if event.key == K_RETURN: # here is the Menu class method if menu.get_position() == 0:
# Voer hier minigame 5 uit #Alles tekenen globals.screen.fill(globals.BLACK) if functions.checkIfGameStatesAreFalse(): #Startscherm functions.drawText("Dineerbeer!", "data/fonts/RAVIE.ttf", 72, globals.BLUE, (130, 200)) functions.drawText("Druk op ENTER om te beginnen", "data/fonts/RAVIE.ttf", 18, globals.GREEN, (210, 400)) functions.drawText("Druk op ESCAPE om af te sluiten", "data/fonts/RAVIE.ttf", 18, globals.RED, (200, 500)) elif globals.gameState[0]: #Menu menu.draw() # Minigame 1 tekenen # Teken hier minigame 1 # Minigame 2 tekenen # Teken hier minigame 2 # Minigame 3 tekenen # Teken hier minigame 3 # Minigame 4 tekenen # Teken hier minigame 4 # Minigame 5 tekenen # Teken hier minigame 5
icon = pygame.image.load('*****@*****.**').convert() pygame.display.set_icon(icon) font = pygame.font.SysFont("comicsansms",30) pygame.display.set_caption("Asteroid") moveY = False done = False is_init_1 = True is_init_2 = True clock = pygame.time.Clock() while done == False: if scene == 1: return_number = menu.draw(screen) if return_number== 1: init_game() if is_init_1: init_player(1) is_init_1 = False else: reinit_player(1) scene = 7 elif return_number== 2: pygame.mouse.set_visible(False) init_game() if is_init_2: init_player(2) is_init_2 = False else: