Hello. I made this tic tac toe game and a menu for the game aswell….

Question Answered step-by-step Hello. I made this tic tac toe game and a menu for the game aswell…. Hello. I made this tic tac toe game and a menu for the game aswell. I just dont know how to put them together. Would somebody be able to code one program to look like the concept i have made below?# menu.pyfrom pygame import *GREEN=0,255,0def instructions(): running = True inst = image.load(“instructions.png”) inst = transform.smoothscale(inst, screen.get_size()) screen.blit(inst,(0,0)) while running: print(“instructions”) for evnt in event.get(): if evnt.type == QUIT: running = False if key.get_pressed()[27]: running = False ##add a “back to main menu” button display.flip() return “menu” def credit(): running = True cred = image.load(“credits.png”) cred = transform.smoothscale(cred, screen.get_size()) screen.blit(cred,(0,0)) while running: print(“credit”) for evnt in event.get(): if evnt.type == QUIT: running = False if key.get_pressed()[27]: running = False #add a “back to main menu” button display.flip() return “menu” def story(): running = True story = image.load(“story.png”) story = transform.smoothscale(story, screen.get_size()) screen.blit(story,(0,0)) while running: print(“story”) for evnt in event.get(): if evnt.type == QUIT: running = False if key.get_pressed()[27]: running = False ###add a “back to main menu” button display.flip() return “menu”def level1(): running=True while running: print(“playing level 1”) for evnt in event.get(): if evnt.type == QUIT: running=False screen.fill((125,100,100)) display.flip() if key.get_pressed()[27]: running = False return “menu”def level2(): running=True while running: print(“playing level 2”) for evnt in event.get(): if evnt.type == QUIT: running=False screen.fill((25,100,200)) display.flip() if key.get_pressed()[27]: running = False return “menu” def menu(): running = True myClock = time.Clock() buttons=[Rect(100+x*150,300,80,40) for x in range(4)]#creating the buttons while running: print(“main menu”) for evnt in event.get(): if evnt.type == QUIT: return “exit” screen.fill(0) mx,my=mouse.get_pos() mb=mouse.get_pressed() for b in buttons: draw.rect(screen,GREEN,b) if mb[0]==1: if buttons[0].collidepoint(mx,my): return “lev1” if buttons[1].collidepoint(mx,my): return “lev2” if buttons[2].collidepoint(mx,my): return “instructions” if buttons[3].collidepoint(mx,my): return “story” display.flip() myClock.tick(60)# This is the important part of the example.# The idea is we have a variable (page) that keeps# track of which page we are one. We give control# of the program to a function until it is done and# the program returns the new page it should be on.screen = display.set_mode((800, 600))running = Truex,y = 0,0OUTLINE = (150,50,30)page = “menu”while page != “exit”: if page == “menu”: page = menu() if page == “lev1”: page = level1() if page == “lev2”: page = level2() if page == “instructions”: page = instructions() if page == “story”: page = story() quit()# game.pyfrom pygame import *from random import *init()width,height=600,700screen=display.set_mode((width,height))o_img = image.load(‘O.png’)x_img = image.load(‘X.png’)logo = image.load(‘logo.png’) # display this a screen.blit() on your desired locationRED=(255,0,0)GREY=(127,127,127)BLACK=(0,0,0)BLUE=(0,0,255)GREEN=(0,255,0)YELLOW=(255,255,0)font1 = font.SysFont(“Calibri”, 45)turn = 1mx,my=0,0mb=Noneclick=Falserestart=Rect(10, 610, 80, 80)#restart buttonslots=[[(0,0,200,200),”empty”],[(200,0,200,200),”empty”],[(400,0,200,200),”empty”],[(0,200,200,200),”empty”],[(200,200,200,200),”empty”],[(400,200,200,200),”empty”],[(0,400,200,200),”empty”],[(200,400,200,200),”empty”],[(400,400,200,200),”empty”]]#slots on the boarddef shadow(x, y): draw.line(screen, GREY, (x + 30, y + 30), (x + 170, y + 170), 7)#shadows to place X and O draw.line(screen, GREY, (x + 170, y + 30), (x + 30, y + 170), 7) draw.circle(screen, GREY, (x + 100, y + 100), 50, 5)def place_x(x, y): screen.blit(x_img, (x, y)) # used blit() to display imagedef place_o(x, y): screen.blit(o_img, (x, y)) # used blit() to display imagerunning = Truewhile running: click = False for evt in event.get(): if evt.type == QUIT: running = False if evt.type == MOUSEBUTTONDOWN and evt.button == 1: click = True mb = mouse.get_pressed() mx, my = mouse.get_pos() mouse.set_visible(False) screen.fill((20, 20, 20))#background res = False#restarting if restart.collidepoint(mx, my): draw.rect(screen, YELLOW, restart) if click: for i in range(0, 9): slots[i][1] = “Empty” turn = 1 else: res = True else: draw.rect(screen, GREY, restart) for i in range(0, 9): if slots[i][1] == “Empty”: shadow(slots[i][0][0], slots[i][0][1]) elif slots[i][1] == “x”: place_x(slots[i][0][0], slots[i][0][1]) elif slots[i][1] == “o”: place_o(slots[i][0][0], slots[i][0][1]) draw.circle(screen, YELLOW, (mx, my), 5) for i in range(0, 9): if Rect(slots[i][0]).collidepoint(mx, my): if turn == 1: if slots[i][1] == “Empty”: if click: slots[i][1] = “x” turn = 2 else: draw.rect(screen, RED, Rect(slots[i][0])) shadow(slots[i][0][0], slots[i][0][1]) elif turn == 2: if slots[i][1] == “Empty”: if click: slots[i][1] = “o” turn = 1 else: draw.rect(screen, BLUE, Rect(slots[i][0])) shadow(slots[i][0][0], slots[i][0][1]) display.flip()quit()Image transcription textRecycle Bin *Python 3.8.5 Shell* – X FileEdit Shell Debug Op pygame windowmain menu main menu X … Show more… Show moreImage transcription textTIC TAC TOE… Show moreThank you so much! Computer Science Engineering & Technology Python Programming BUSINESS 218.271 Share QuestionEmailCopy link Comments (0)