def waitforkeypress(): music_ismuted = False while True: mpos = pygame.mouse.get_pos() for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: from menu import menu_main menu_main() return music_ismuted if event.type == pygame.MOUSEBUTTONDOWN and mute_rect.collidepoint( mpos[0], mpos[1]): if music_ismuted: music_ismuted = False else: music_ismuted = True screen.blit(title_screen, (0, 0)) if music_ismuted: screen.blit(muted, (300, 10)) pygame.mixer.music.pause() else: screen.blit(unmuted, (300, 10)) pygame.mixer.music.unpause() pygame.display.flip()
def start(): while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: # pressing escape quits from menu import menu_main menu_main() return
def save(): config = ConfigParser.RawConfigParser() config.add_section('WizardsMagic') for item in globals.menu_group: if item.type=='txtinput': config.set('WizardsMagic', item.key, item.text) if item.type=='checkbox': config.set('WizardsMagic', item.key, (item.value and 'Y' or 'N')) configfile=open('wizardsmagic.cfg', 'wb') config.write(configfile) configfile.close() read_configuration() launcher() menu.menu_main()
def TitleScreen(): menu_message = 'Select a difficulty!' while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: # pressing escape quits from menu import menu_main menu_main() if event.type == pygame.MOUSEBUTTONDOWN: for item in difficulties: if item.collidepoint(m_pos[0], m_pos[1]): if item == difficulties[0]: speed = -1 return speed elif item == difficulties[1]: speed = -2 return speed elif item == difficulties[2]: speed = -3 return speed elif item == difficulties[3]: player.commie = True difficulties_colours[3] = RED screen.fill(BLACK) m_pos = pygame.mouse.get_pos() for item in difficulties: if item.collidepoint(m_pos[0], m_pos[1]): item.width = 40 item.height = 40 else: item.width = 20 item.height = 20 menu_message = "Select a difficulty!" for i in range(len(difficulties)): if difficulties[i].width == 40: pygame.draw.rect(screen, difficulties_colours[i], difficulties[i].move(-10, -10)) menu_message = difficulties_text[i] drawText(menu_message, font, screen, 250, 350, YELLOW) elif difficulties[i].width == 20: pygame.draw.rect(screen, difficulties_colours[i], difficulties[i]) drawText(menu_message, font, screen, 250, 350, YELLOW) drawText("Flappy Ship!", title_font, screen, 175, 100, YELLOW) pygame.display.flip()
def save(): config = ConfigParser.RawConfigParser() config.add_section('WizardsMagic') for item in globals.menu_group: if item.type == 'txtinput': config.set('WizardsMagic', item.key, item.text) if item.type == 'checkbox': config.set('WizardsMagic', item.key, (item.value and 'Y' or 'N')) config.set('WizardsMagic', 'language', globals.language) configfile = open(globals.current_folder + '/wizardsmagic.cfg', 'wb') config.write(configfile) configfile.close() read_configuration() launcher() menu.menu_main()
def gameover(): respawn_text = font2.render('Play Again? Y/N', True, WHITE) while True: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: from menu import menu_main menu_main() elif event.key == pygame.K_y: pong_main() elif event.key == pygame.K_n: from menu import menu_main menu_main() screen.blit(respawn_text, (190, 150)) pygame.display.flip()
def respawn(): screen.fill(BLACK) drawText('You Died :(', title_font, screen, 175, 100, RED) drawText('Respawn? Y/N', font, screen, 250, 350, YELLOW) pygame.display.flip() while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: # pressing escape quits from menu import menu_main menu_main() if event.key == pygame.K_y: fs_main() if event.key == pygame.K_n: from menu import menu_main menu_main()
def smash_main(): import pygame from TitleScreen import TitleScreen from smash_Platform import Platform from smash_Player import Player import time import sys pygame.init() size = (1050, 650) screen = pygame.display.set_mode(size) pygame.display.set_caption("Epic Smash Siblings Omega") clock = pygame.time.Clock() # Colours BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) BLUE = (0, 0, 255) YELLOW = (255, 255, 0) PURPLE = (255, 0, 255) # Vars done = False timer = 0 def character_select(ID): p1_choose = TitleScreen(74, screen, 250, 100, "Player 1 Choose Colour.") p2_choose = TitleScreen(74, screen, 250, 100, "Player 2 Choose Colour") r = 255 g = 0 b = 0 RGB = (r, g, b) colour_rects = [ pygame.Rect(400, 200, 20, 20), pygame.Rect(450, 200, 20, 20), pygame.Rect(500, 200, 20, 20), pygame.Rect(550, 200, 20, 20), pygame.Rect(600, 200, 20, 20), pygame.Rect(500, 240, 20, 20) ] colour_list = [RED, BLUE, GREEN, YELLOW, PURPLE, RGB] done = False while not done: if r > 0 and b == 0: r -= 5 g += 5 colour_list[5] = (r, g, b) elif g > 0 and r == 0: g -= 5 b += 5 colour_list[5] = (r, g, b) elif b > 0 and g == 0: r += 5 b -= 5 colour_list[5] = (r, g, b) if ID == 0: p1_choose.drawText() else: screen.blit(title_image, (0, 0)) p2_choose.drawText() pygame.draw.rect(screen, BLACK, (390, 190, 240, 40)) pygame.draw.rect(screen, BLACK, (490, 230, 40, 40)) for i in range(len(colour_rects)): if colour_rects[i].width == 40: pygame.draw.rect(screen, colour_list[i], colour_rects[i].move(-10, -10)) else: pygame.draw.rect(screen, colour_list[i], colour_rects[i]) pygame.display.update() m_pos = pygame.mouse.get_pos() for colour in colour_rects: if pygame.Rect(colour).collidepoint(m_pos[0], m_pos[1]): colour.width = 40 colour.height = 40 else: colour.width = 20 colour.height = 20 for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() elif event.type == pygame.MOUSEBUTTONDOWN: if ID == 0: if pygame.Rect(colour_rects[0]).collidepoint( m_pos[0], m_pos[1]): players[0].colour = RED click_sound.play() return elif pygame.Rect(colour_rects[1]).collidepoint( m_pos[0], m_pos[1]): players[0].colour = BLUE click_sound.play() return elif pygame.Rect(colour_rects[2]).collidepoint( m_pos[0], m_pos[1]): players[0].colour = GREEN click_sound.play() return elif pygame.Rect(colour_rects[3]).collidepoint( m_pos[0], m_pos[1]): players[0].colour = YELLOW click_sound.play() return elif pygame.Rect(colour_rects[4]).collidepoint( m_pos[0], m_pos[1]): players[0].colour = PURPLE click_sound.play() return elif pygame.Rect(colour_rects[5]).collidepoint( m_pos[0], m_pos[1]): players[0].is_RGB = True click_sound.play() return elif ID == 1: if pygame.Rect(colour_rects[0]).collidepoint( m_pos[0], m_pos[1]): players[1].colour = RED click_sound.play() return elif pygame.Rect(colour_rects[1]).collidepoint( m_pos[0], m_pos[1]): players[1].colour = BLUE click_sound.play() return elif pygame.Rect(colour_rects[2]).collidepoint( m_pos[0], m_pos[1]): players[1].colour = GREEN click_sound.play() return elif pygame.Rect(colour_rects[3]).collidepoint( m_pos[0], m_pos[1]): players[1].colour = YELLOW click_sound.play() return elif pygame.Rect(colour_rects[4]).collidepoint( m_pos[0], m_pos[1]): players[1].colour = PURPLE click_sound.play() return elif pygame.Rect(colour_rects[5]).collidepoint( m_pos[0], m_pos[1]): players[1].is_RGB = True click_sound.play() return def restart(): player_1_wins = TitleScreen(74, screen, 350, 250, "Player 1 Wins!") player_2_wins = TitleScreen(74, screen, 350, 250, "Player 2 Wins!") player_1_wins.colour = (255, 0, 0) player_2_wins.colour = (255, 0, 0) screen.blit(git_gud, (0, 0)) if players[1].stock_remaining == 0: player_1_wins.drawText() elif players[0].stock_remaining == 0: player_2_wins.drawText() pygame.display.update() time.sleep(2) while True: pygame.init() screen.blit(git_gud, (0, 0)) restart_text = TitleScreen(74, screen, 350, 250, "Play again? Y/N") restart_text.drawText() pygame.display.update() for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() elif event.type == pygame.KEYDOWN: if event.key == pygame.K_y: smash_main() elif event.key == pygame.K_n: return # Platforms platforms = [ Platform(screen, BLACK, 275, 450, 500, 40), Platform(screen, BLACK, 325, 350, 125, 10), Platform(screen, BLACK, 465, 250, 125, 10), Platform(screen, BLACK, 600, 350, 125, 10) ] # Main background image background_image = pygame.image.load( 'smash_main_background.jpeg').convert() # Players players = [ Player(screen, RED, 300, 400, 20, 40, platforms, 0), Player(screen, GREEN, 725, 400, 20, 40, platforms, 1) ] player_1_text = TitleScreen(24, screen, 160, 600, "Player 1's stock:") player_2_text = TitleScreen(24, screen, 460, 600, "Player 2's stock:") player_1_health = TitleScreen(24, screen, 160, 550, "Player 1's Health:") player_2_health = TitleScreen(24, screen, 460, 550, "Player 2's Health:") player_info = [ player_1_text, player_1_health, player_2_text, player_2_health ] # Title screen click_sound = pygame.mixer.Sound("smash_select_noise.wav") pygame.mixer.music.load('smash_title_screen_theme.wav') pygame.mixer.music.play(-1, 0.0) title_image = pygame.image.load('smash_cover.jpg').convert() title_image.set_colorkey(WHITE) play_button = TitleScreen(48, screen, 350, 575, "Press any key to play!") play_button.colour = BLACK git_gud = pygame.image.load('smash_git gud.png').convert() screen.fill(WHITE) screen.blit(title_image, (0, 0)) pygame.display.update() character_select(0) character_select(1) play_button.drawText() pygame.display.update() play_button.waitForPlayerToPressKey() click_sound.play() pygame.mixer.music.stop() pygame.mixer.music.load('smash_playing_theme.wav') pygame.mixer.music.play(-1, 0.0) # -------- Main Program Loop ----------- while not done: # --- Main event loop # --- All events are detected here for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_a: players[0].x_speed = -3 players[0].direction = "LEFT" if event.key == pygame.K_d: players[0].x_speed = 3 players[0].direction = "RIGHT" if event.key == pygame.K_w: if players[0].jumps_available > 0: players[0].jumping = True if event.key == pygame.K_SPACE: players[0].attacking = True if event.key == pygame.K_LEFT: players[1].x_speed = -3 players[1].direction = "LEFT" if event.key == pygame.K_RIGHT: players[1].x_speed = 3 players[1].direction = "RIGHT" if event.key == pygame.K_UP: if players[1].jumps_available > 0: players[1].jumping = True if event.key == pygame.K_KP_ENTER: players[1].attacking = True if event.type == pygame.KEYUP: if event.key == pygame.K_a: players[0].x_speed = 0 if event.key == pygame.K_d: players[0].x_speed = 0 if event.key == pygame.K_SPACE: players[0].attacking = False if event.key == pygame.K_LEFT: players[1].x_speed = 0 if event.key == pygame.K_RIGHT: players[1].x_speed = 0 if event.key == pygame.K_KP_ENTER: players[1].attacking = False # --- Game logic should go here for player in players: player.Move() if player == players[0]: player.die(300) else: player.die(725) if player.stock_remaining == 0: done = True # --- Screen-clearing code goes here screen.fill(WHITE) # --- Drawing code should go here # Background screen.blit(background_image, (0, 0)) # Platforms for platform in platforms: platform.draw_platform() # Players for player in players: player.draw() player.attack(players) # Stocks for text in player_info: text.drawText() players[0].draw_health_bar(300) players[1].draw_health_bar(600) for player in players: for i in range(player.stock_remaining): if player == players[0]: pygame.draw.rect(screen, player.colour, (300 + (30 * i), 600, 20, 20)) else: pygame.draw.rect(screen, player.colour, (600 + (30 * i), 600, 20, 20)) # --- Go ahead and update the screen with what we've drawn. pygame.display.flip() # --- Limit to 60 frames per second clock.tick(60) # Game over restart() from menu import menu_main menu_main()
def start_game(cli=False,ai=False): globals.attack_started = [True] globals.background = pygame.image.load(current_folder+'/misc/bg_sample.gif') #globals.background = globals.background.convert() #globals.background = pygame.Surface(globals.screen.get_size()) globals.background = globals.background.convert_alpha() globals.cards_of_element_shower_element = "water" #globals.background.fill((0, 0, 0)) background_backup = globals.background.copy() #font.set_bold(0) globals.games_cards[0]['water'] = cards.water_cards_deck[:] globals.games_cards[0]['fire'] = cards.fire_cards_deck[:] globals.games_cards[0]['air'] = cards.air_cards_deck[:] globals.games_cards[0]['earth'] = cards.earth_cards_deck[:] globals.games_cards[0]['life'] = cards.life_cards_deck[:] globals.games_cards[0]['death'] = cards.death_cards_deck[:] if globals.player1: globals.player1.enemy = None globals.player2.enemy = None globals.player1 = player.Player1() globals.player2 = player.Player2() globals.player1.enemy = globals.player2 globals.player2.enemy = globals.player1 globals.player = globals.player1 # 0 1 2 3 4 //Расположение # 5 6 7 8 9 globals.cardbox0 = cardbox.Cardbox((22, 46), globals.player1, 0) #0 место на поле globals.cardbox1 = cardbox.Cardbox((172, 46), globals.player1, 1) #1 место на поле globals.cardbox2 = cardbox.Cardbox((322, 46), globals.player1, 2) #2 место на поле globals.cardbox3 = cardbox.Cardbox((472, 46), globals.player1, 3) #3 место на поле globals.cardbox4 = cardbox.Cardbox((622, 46), globals.player1, 4) #4 место на поле globals.cardbox5 = cardbox.Cardbox((22, 238), globals.player2, 5) #5 место на поле globals.cardbox6 = cardbox.Cardbox((172, 238), globals.player2, 6) #6 место на поле globals.cardbox7 = cardbox.Cardbox((322, 238), globals.player2, 7) #7 место на поле globals.cardbox8 = cardbox.Cardbox((472, 238), globals.player2, 8) #8 место на поле globals.cardbox9 = cardbox.Cardbox((622, 238), globals.player2, 9) #9 место на поле globals.cardboxes = [globals.cardbox0, globals.cardbox1, globals.cardbox2, globals.cardbox3, globals.cardbox4, globals.cardbox5, globals.cardbox6, globals.cardbox7, globals.cardbox8, globals.cardbox9] #Ссылки на объекты for tcardbox in globals.cardboxes: if pygame.version.vernum < (1, 9, 1): tcardbox.normal_rect = copy.deepcopy(tcardbox.rect) tcardbox.opposite_rect = copy.deepcopy(tcardbox.get_opposite_cardbox().rect) else: tcardbox.normal_rect = tcardbox.rect.copy() tcardbox.opposite_rect = tcardbox.get_opposite_cardbox().rect.copy() globals.castlabel = cards.CastLabel() healthwindow.HealthWindowEnemy((175, 10)) #Окошко здоровья верхнего игрока healthwindow.HealthWindow((167, 557)) #Окошко здоровья нижнего игрока # Кнопки колод стихий первого игрока elementbutton.WaterElementShower((246, 2)) elementbutton.FireElementShower((337, 2)) elementbutton.AirElementShower((419, 2)) elementbutton.EarthElementShower((509, 2)) elementbutton.LifeElementShower((590, 2)) elementbutton.DeathElementShower((668, 2)) # Кнопки колод стихий второго игрока globals.water_element_button = elementbutton.WaterElementButton((11, 427)) globals.fire_element_button = elementbutton.FireElementButton((56, 427)) globals.air_element_button = elementbutton.AirElementButton((101, 427)) globals.earth_element_button = elementbutton.EarthElementButton((146, 427)) globals.life_element_button = elementbutton.LifeElementButton((191, 427)) globals.death_element_button = elementbutton.DeathElementButton((236, 427)) #Кнопки завершения хода первого и второго игрока. completethecoursebutton.CompleteTheCourseButton((758, 378)) #Окна выбора карты стихии globals.cardofelementsshower = cardsofelementshower.CardsOfElementShower() globals.nickname2 = nickname_window.NicknameWindow((142, 530), 'Guest') globals.nickname1 = nickname_window.NicknameWindow((22, 0), globals.nick) if ai: globals.player2.ai = True globals.nickname2.set_nickname('Computer') #стрелочки для сдвига карт в колоде #globals.leftarrow = cardsofelementshower.LeftArrow((356, 489)) #globals.rightarrow = cardsofelementshower.RightArrow((739, 491)) if not cli: globals.gameinformationpanel.display('Battle Started') globals.cli = False sockets.query = lambda x: x else: val = sockets.connect() if not val: globals.gameinformationpanel.display('Cant connect to server.') menu.menu_main() globals.stage = False return 0 else: globals.importantmessage = important_message.MessageWindow('We are waiting for another player') sockets.query = sockets.query_ globals.cli = True thread.start_new_thread(server_handler, ()) if not globals.cli: player.switch_position() #******************************************************************************** globals.screen.blit(globals.background, (0, 0)) globals.panels.update() globals.interface.update() pygame.display.flip() sockets.query({"action":"join", "nickname":globals.nick}) #входим в игру while globals.stage == 1: #if globals.turn_ended and len(cards_attacking) = 0: # for cardbox in globals.cardboxes: # cardbox.opposite = not cardbox.opposite for event in pygame.event.get(): globals.event_handler.event(event) globals.panels.update() globals.interface.update() globals.ccards_1.update() globals.ccards_2.update() globals.cardofelementsshower.update() globals.cards_in_deck.update() globals.card_info_group.update() globals.information_group.update() #interface_up_layer.update() globals.screen.blit(globals.background, (0, 0)) #globals.background.fill((0,0,0)) globals.background = background_backup.copy() if globals.animation == "N": for item in animations.animations_running + animations.cards_attacking + animations.cards_dying: del item animations.animations_running = [] animations.cards_attacking = [] animations.cards_dying = [] if len(animations.animations_running) == False and len(globals.attack_started): if not globals.cli: player.switch_position() for animation_running in animations.animations_running: animation_running.run() if len(globals.attack_started) and len(globals.cards_attacking) == False: if not globals.cli: player.switch_position() pygame.display.flip() clock.tick(50)
player.switch_position() pygame.display.flip() clock.tick(50) pygame.init() globals.screen = pygame.display.set_mode((800, 600)) pygame.display.set_caption('Wizards Magic') clock = pygame.time.Clock() #read configuration file options.read_configuration() if globals.music == "Y": thread.start_new_thread(load_and_start_bg_music,()) menu.menu_main() globals.event_handler = eventhandler.Event_handler() globals.point = eventhandler.Point() globals.gameinformationpanel = gameinformation.GameInformationPanel() globals.cardinfo = cardinfo.CardInfo() globals.screen.blit(globals.background, (0, 0)) pygame.display.flip() # noinspection PyPackageRequirements while 1: for event in pygame.event.get(): globals.event_handler.event(event) if globals.stage == 1: if globals.cli:
def cancel(): menu.menu_main()
def start_game(cli=False, ai=False): wzglobals.attack_started = [True] wzglobals.background = \ pygame.image.load(current_folder+'/misc/bg_sample.gif') # wzglobals.background = wzglobals.background.convert() # wzglobals.background = pygame.Surface(wzglobals.screen.get_size()) wzglobals.background = wzglobals.background.convert_alpha() wzglobals.cards_of_element_shower_element = "water" # wzglobals.background.fill((0, 0, 0)) background_backup = wzglobals.background.copy() # font.set_bold(0) wzglobals.games_cards[0]['water'] = cards.water_cards_deck.cards[:] wzglobals.games_cards[0]['fire'] = cards.fire_cards_deck.cards[:] wzglobals.games_cards[0]['air'] = cards.air_cards_deck.cards[:] wzglobals.games_cards[0]['earth'] = cards.earth_cards_deck.cards[:] wzglobals.games_cards[0]['life'] = cards.life_cards_deck.cards[:] wzglobals.games_cards[0]['death'] = cards.death_cards_deck.cards[:] if wzglobals.player1: wzglobals.player1.enemy = None wzglobals.player2.enemy = None wzglobals.player1 = player.Player1() wzglobals.player1.nickname = wzglobals.nick wzglobals.player2 = player.Player2() wzglobals.player1.enemy = wzglobals.player2 wzglobals.player2.enemy = wzglobals.player1 wzglobals.player = wzglobals.player1 # 0 1 2 3 4 //Расположение # 5 6 7 8 9 wzglobals.cardbox0 = \ cardbox.Cardbox((22, 46), wzglobals.player1, 0) # 0 место на поле wzglobals.cardbox1 = \ cardbox.Cardbox((172, 46), wzglobals.player1, 1) # 1 место на поле wzglobals.cardbox2 = \ cardbox.Cardbox((322, 46), wzglobals.player1, 2) # 2 место на поле wzglobals.cardbox3 = \ cardbox.Cardbox((472, 46), wzglobals.player1, 3) # 3 место на поле wzglobals.cardbox4 = \ cardbox.Cardbox((622, 46), wzglobals.player1, 4) # 4 место на поле wzglobals.cardbox5 = \ cardbox.Cardbox((22, 238), wzglobals.player2, 5) # 5 место на поле wzglobals.cardbox6 = \ cardbox.Cardbox((172, 238), wzglobals.player2, 6) # 6 место на поле wzglobals.cardbox7 = \ cardbox.Cardbox((322, 238), wzglobals.player2, 7) # 7 место на поле wzglobals.cardbox8 = \ cardbox.Cardbox((472, 238), wzglobals.player2, 8) # 8 место на поле wzglobals.cardbox9 = \ cardbox.Cardbox((622, 238), wzglobals.player2, 9) # 9 место на поле wzglobals.cardboxes = [ wzglobals.cardbox0, wzglobals.cardbox1, wzglobals.cardbox2, wzglobals.cardbox3, wzglobals.cardbox4, wzglobals.cardbox5, wzglobals.cardbox6, wzglobals.cardbox7, wzglobals.cardbox8, wzglobals.cardbox9 ] # Ссылки на объекты for tcardbox in wzglobals.cardboxes: if pygame.version.vernum < (1, 9, 1): tcardbox.normal_rect = copy.deepcopy(tcardbox.rect) tcardbox.opposite_rect = \ copy.deepcopy(tcardbox.get_opposite_cardbox().rect) else: tcardbox.normal_rect = tcardbox.rect.copy() tcardbox.opposite_rect = \ tcardbox.get_opposite_cardbox().rect.copy() wzglobals.castlabel = cards.CastLabel() # Окошко здоровья верхнего игрока healthwindow.HealthWindowEnemy((175, 10)) healthwindow.HealthWindow((167, 557)) # Окошко здоровья нижнего игрока # Кнопки колод стихий первого игрока elementbutton.WaterElementShower((246, 2)) elementbutton.FireElementShower((337, 2)) elementbutton.AirElementShower((419, 2)) elementbutton.EarthElementShower((509, 2)) elementbutton.LifeElementShower((590, 2)) elementbutton.DeathElementShower((668, 2)) # Кнопки колод стихий второго игрока wzglobals.water_element_button = \ elementbutton.WaterElementButton((11, 427)) wzglobals.fire_element_button = \ elementbutton.FireElementButton((56, 427)) wzglobals.air_element_button = \ elementbutton.AirElementButton((101, 427)) wzglobals.earth_element_button = \ elementbutton.EarthElementButton((146, 427)) wzglobals.life_element_button = \ elementbutton.LifeElementButton((191, 427)) wzglobals.death_element_button = \ elementbutton.DeathElementButton((236, 427)) # Кнопки завершения хода первого и второго игрока. completethecoursebutton.CompleteTheCourseButton((758, 378)) # Окна выбора карты стихии wzglobals.cardofelementsshower = \ cardsofelementshower.CardsOfElementShower() wzglobals.nickname2 = \ nickname_window.NicknameWindow((142, 530), 'Guest') wzglobals.player2.nickname = 'Guest' wzglobals.nickname1 = \ nickname_window.NicknameWindow((22, 0), wzglobals.nick) if ai: wzglobals.player2.ai = True wzglobals.nickname2.set_nickname('Computer') wzglobals.player2.nickname = 'Computer' # стрелочки для сдвига карт в колоде # wzglobals.leftarrow = cardsofelementshower.LeftArrow((356, 489)) # wzglobals.rightarrow = cardsofelementshower.RightArrow((739, 491)) if not cli: wzglobals.gameinformationpanel.display('Battle Started') wzglobals.cli = False sockets.query = lambda x: x else: val = sockets.connect() if not val: wzglobals.gameinformationpanel.display('Cant connect to server.') menu.menu_main() wzglobals.stage = False return 0 else: wzglobals.importantmessage = important_message.MessageWindow( 'We are waiting for another player') sockets.query = sockets.query_ wzglobals.cli = True server_thread = threading.Thread(target=server_handler) server_thread.start() if not wzglobals.cli: player.switch_position() # ************************************************************************** wzglobals.screen.blit(wzglobals.background, (0, 0)) wzglobals.panels.update() wzglobals.interface.update() pygame.display.flip() sockets.query({ "action": "join", "nickname": wzglobals.nick }) # входим в игру while wzglobals.stage == 1: # if wzglobals.turn_ended and len(cards_attacking) = 0: # for cardbox in wzglobals.cardboxes: # cardbox.opposite = not cardbox.opposite for event in pygame.event.get(): wzglobals.event_handler.event(event) wzglobals.panels.update() wzglobals.interface.update() wzglobals.ccards_1.update() wzglobals.ccards_2.update() wzglobals.cardofelementsshower.update() wzglobals.cards_in_deck.update() wzglobals.card_info_group.update() wzglobals.information_group.update() # interface_up_layer.update() wzglobals.screen.blit(wzglobals.background, (0, 0)) # wzglobals.background.fill((0, 0, 0)) wzglobals.background = background_backup.copy() if wzglobals.animation == "N": for item in (animations.animations_running + animations.cards_attacking + animations.cards_dying): del item animations.animations_running = [] animations.cards_attacking = [] animations.cards_dying = [] if (not len(animations.animations_running) and len(wzglobals.attack_started)): if not wzglobals.cli: player.switch_position() for animation_running in animations.animations_running: animation_running.run() if not (len(wzglobals.attack_started) and len(wzglobals.cards_attacking)): if not wzglobals.cli: player.switch_position() pygame.display.flip() clock.tick(50)
player.switch_position() pygame.display.flip() clock.tick(50) pygame.init() wzglobals.screen = pygame.display.set_mode((800, 600)) pygame.display.set_caption('Wizards Magic') clock = pygame.time.Clock() # read configuration file options.read_configuration() if wzglobals.music == "Y": music_thread = threading.Thread(target=load_and_start_bg_music) music_thread.start() menu.menu_main() wzglobals.event_handler = eventhandler.Event_handler() wzglobals.point = eventhandler.Point() wzglobals.gameinformationpanel = gameinformation.GameInformationPanel() wzglobals.cardinfo = cardinfo.CardInfo() wzglobals.screen.blit(wzglobals.background, (0, 0)) pygame.display.flip() # noinspection PyPackageRequirements while 1: for event in pygame.event.get(): wzglobals.event_handler.event(event) if wzglobals.stage == 1: if wzglobals.cli: