def master_function(): win = False level = 0 background = 0 while win == False: background += 1 level += 1 x = random.randrange(7, 15) y = random.randrange(9, 17) lent = 0.5 clicklocal = clicklocation(x, y, lent) playing_field = gridmaker(x, y) count = 0 finalscore = (x * y * 10) totalscore = 0 clickcoords = [] attempts = random.randrange(12, 16) for i in range(100): temp = connectsearch(playing_field, x, y, totalscore) playing_field = temp[0] playing_field = gravity(playing_field, x, y) playing_field = reset(playing_field, x, y) while stddraw.mousePressed() == False: display(playing_field, x, y, lent, totalscore, finalscore, clickcoords, clicklocal, attempts, level, background, win) temp = connectsearch(playing_field, x, y, totalscore) playing_field = temp[0] totalscore = temp[1] playing_field = gravity(playing_field, x, y) playing_field = reset(playing_field, x, y) if attempts == 0 or totalscore >= finalscore: win = display(playing_field, x, y, lent, totalscore, finalscore, clickcoords, clicklocal, attempts, level, background, win) print('AA') break elif stddraw.mousePressed() == True: count += 1 clickcoords.append(stddraw.mouseX()) clickcoords.append(stddraw.mouseY()) if count == 2: playing_field = checker(playing_field, x, y, clickcoords, clicklocal) test = connectcheck(playing_field, x, y) if test == True: attempts = attempts - 1 temp = connectsearch(playing_field, x, y, totalscore) playing_field = temp[0] totalscore = temp[1] if test == False: playing_field = checker(playing_field, x, y, clickcoords, clicklocal) count = 0 clickcoords = []
def click(): while True: stddraw.show(0) if stddraw.mousePressed(): mx1 = stddraw.mouseX() my1 = stddraw.mouseY() return [mx1, my1]
def select(score, time): while True: stddraw.show(100) #pause for .1 second drawTop(score, time) #draw this each time to update time if time != 9999: time += .1 if checkScoreTime(time): #if times out then stop waiting for input return [0,0], score, time if stddraw.mousePressed() and stddraw.mouseY() < 9: #you press on the board mx = stddraw.mouseX() my = stddraw.mouseY() return [int(mx), int(my)], score, time
def main_menu_click(): global Clicked while not Clicked: if stddraw.mousePressed(): mx = stddraw.mouseX() my = stddraw.mouseY() # determines where and what to print if 446 > mx > 54 and 539 > my > 301: stddraw.picture(images.gameBackground,250,400) stddraw.picture(images.scoreOverlay,327,725) stddraw.setFontSize(25) stddraw.setPenColor(color.WHITE) stddraw.text(327,725, '0') Clicked = True stddraw.show(0.0)
def getMove(board, columns, rows): """ Returns x and y coordinates where the user has clicked """ while True: mouseClicked = sd.mousePressed() if mouseClicked: x = sd.mouseX() y = sd.mouseY() for i in range(columns): for j in range(rows): if i < x < i + 1 and j < y < j + 1: piece = [i, j] return piece sd.show(0.05)
def display_game_over(grid_height, grid_width): background_color = Color(42, 69, 99) button_color = Color(25, 255, 228) text_color = Color(31, 160, 239) # clear the background canvas to background_color stddraw.clear(background_color) # get the directory in which this python code file is placed current_dir = os.path.dirname(os.path.realpath(__file__)) # path of the image file img_file = current_dir + "/menu_image.png" # center coordinates to display the image img_center_x, img_center_y = (grid_width - 1) / 2, grid_height - 7 # image is represented using the Picture class image_to_display = Picture(img_file) # display the image stddraw.picture(image_to_display, img_center_x, img_center_y) # dimensions of the start game button button_w, button_h = grid_width - 1.5, 2 # coordinates of the bottom left corner of the start game button button_blc_x, button_blc_y = img_center_x - button_w / 2, 4 # display the start game button as a filled rectangle stddraw.setPenColor(button_color) stddraw.filledRectangle(button_blc_x, button_blc_y, button_w, button_h) # display the text on the start game button stddraw.setFontFamily("Arial") stddraw.setFontSize(25) stddraw.setPenColor(text_color) text_to_display = "Game Over" stddraw.text(img_center_x, 5.5, text_to_display) stddraw.text(img_center_x, 4.5, "Score : " + str(grid.total_score)) # menu interaction loop while True: # display the menu and wait for a short time (50 ms) stddraw.show(50) # check if the mouse has been left-clicked if stddraw.mousePressed(): # get the x and y coordinates of the location at which the mouse has # most recently been left-clicked mouse_x, mouse_y = stddraw.mouseX(), stddraw.mouseY() if mouse_x >= button_blc_x and mouse_x <= button_blc_x + button_w: if mouse_y >= button_blc_y and mouse_y <= button_blc_y + button_h: return True
def click(a): click_row = False click_row = False first_click = False while first_click is False: stddraw.show(0.0) if stddraw.mousePressed(): mx = stddraw.mouseX() my = stddraw.mouseY() if 5 < mx < 488 and 5 < my < 635: for i in range(9): for j in range(7): if (5 + 70 * j) < mx < (5 + 70 * (j + 1)) and ( 635 - 70 * i) > my > (635 - 70 * (i + 1)): click_row = i click_column = j break return click_row, click_column
def check_events(self): if stddraw.mousePressed(): x = stddraw.mouseX() y = stddraw.mouseY() localized = self._localize_click(x, y) if localized: avenue = localized[0] street = localized[1] location = localized[2] if constants.NORTH <= location <= constants.WEST: self._toggle_wall(avenue, street, location) elif location == TOP: self._toggle_beeper(avenue, street, 1) elif location == BOTTOM: self._toggle_beeper(avenue, street, -1) if stddraw.hasNextKeyTyped(): key = stddraw.nextKeyTyped() if key == 'p': print(self._world) elif key == 's': with open(self._filename, 'w') as file: file.write(str(self._world)) print('Saved Karel world to file:', self._filename)
#diagonal from bottom left to top right has all X game_won = True if global_variables_p1.marker_array [2][0] == 2 and global_variables_p1.marker_array [1][1] == 2 and global_variables_p1.marker_array [0][2] == 2: #diagonal from bottom left to top right has all O game_won = True if game_won: richardnorman_p1_drawing.draw_win(turn_number) global_variables_p1.init() turn_number = 1 richardnorman_p1_drawing.draw_board() game_won = False richardnorman_p1_drawing.draw_turn(turn_number) while not game_won: if stddraw.mousePressed(): valid_placement = richardnorman_p1_drawing.draw_piece(stddraw.mouseX(),stddraw.mouseY(),turn_number) if not valid_placement: continue check_if_player_won(turn_number) if game_won: break is_tie = check_if_tie() if is_tie: break turn_number += 1 richardnorman_p1_drawing.draw_turn(turn_number) stddraw.show(0.0)
def display(playing_field, x, y, lent, totalscore, finalscore, clickcoords, clicklocal, attempts, level, background, win): stddraw.clear() image(background) stddraw.setXscale(-lent, (2 * lent * x) - lent) stddraw.setYscale(-(2 * lent * y) - 4 * lent, lent) stddraw.setPenColor(stddraw.PINK) stddraw.filledRectangle(-lent, -(2 * lent * y) - 4 * lent, (2 * lent * x), 5 * lent) stddraw.setPenColor(stddraw.BOOK_LIGHT_BLUE) stddraw.filledRectangle(-lent, -(2 * lent * y) - 3 * lent, (2 * lent * x), lent) stddraw.setPenColor(stddraw.BOOK_LIGHT_BLUE) stddraw.filledRectangle(-lent, -(2 * lent * y) - 1.5 * lent, (2 * lent * x), lent) stddraw.setPenColor(stddraw.GRAY) stddraw.filledRectangle(-lent, -(2 * lent * y) - 2.2 * lent, (2 * lent * x), lent) if totalscore < finalscore: stddraw.setPenColor(stddraw.GREEN) stddraw.filledRectangle(-lent, -(2 * lent * y) - 2.2 * lent, ((2 * lent * x) - lent) / 1.7 * (totalscore / finalscore), lent) if totalscore >= finalscore: stddraw.setPenColor(stddraw.GREEN) stddraw.filledRectangle(-lent, -(2 * lent * y) - 2.2 * lent, ((2 * lent * x) - lent), lent) stddraw.setPenColor(stddraw.BOOK_LIGHT_BLUE) stddraw.filledRectangle(x * lent + lent, -(2 * lent * y) - 3.5 * lent, (lent * x), 3.5 * lent) stddraw.setPenRadius(0.010) stddraw.setPenColor(stddraw.BOOK_LIGHT_BLUE) stddraw.rectangle(-lent, -(2 * lent * y) - 4 * lent, (2 * lent * x), 5 * lent) stddraw.setFontSize(25) stddraw.setPenColor(stddraw.DARK_GREEN) stddraw.text((((2 * lent * x) - lent) / 1.3), -((2 * lent * y) + lent), 'Points: ' + str(totalscore) + ' / ' + str(finalscore)) stddraw.setPenColor(stddraw.RED) stddraw.setFontSize(20) stddraw.text((((2 * lent * x) - lent) / 1.3), -((2 * lent * y) + 2.7 * lent), 'Attempts Left: ' + str(attempts)) stddraw.setPenColor(stddraw.BLUE) stddraw.setFontSize(25) stddraw.text((((2 * lent * x) - lent) / 20), -((2 * lent * y) - 0.08 * lent), 'Level: ' + str(level)) for i in range(len(clickcoords) - 1): found = False reps = -1 while found == False and not reps >= (x * y - 1): reps += 1 if clicklocal[reps][0] < clickcoords[i] < clicklocal[reps][ 1] and clicklocal[reps][2] < clickcoords[ i + 1] < clicklocal[reps][3]: spotx = playing_field[reps][0] spoty = playing_field[reps][1] stddraw.setPenColor(stddraw.DARK_RED) stddraw.setPenRadius(0.05) stddraw.filledSquare(spotx, spoty, lent) found = True for i in range(x * y): spotx = playing_field[i][0] spoty = playing_field[i][1] if playing_field[i][2] == 1: stddraw.setPenColor(stddraw.MAGENTA) stddraw.setPenRadius(0.05) stddraw.filledCircle(spotx, spoty, lent / 1.2) if playing_field[i][2] == 2: stddraw.setPenColor(stddraw.YELLOW) stddraw.setPenRadius(0.05) stddraw.filledSquare(spotx, spoty, lent / 1.2) if playing_field[i][2] == 3: stddraw.setPenColor(stddraw.BLUE) stddraw.setPenRadius(0.05) stddraw.filledPolygon([(spotx - lent) + 0.2, (spotx - lent) + 0.3, (spotx - lent) + 0.7, (spotx - lent) + 0.9, (spotx - lent) + 0.6], [(spoty - lent) + 0.6, (spoty - lent) + 0.9, (spoty - lent) + 0.9, (spoty - lent) + 0.6, (spoty - lent) + 0.1]) if playing_field[i][2] == 4: stddraw.setPenColor(stddraw.GREEN) stddraw.setPenRadius(0.05) stddraw.filledPolygon([ (spotx - lent) + 0.1, (spotx - lent) + 0.4, (spotx - lent) + 0.9, (spotx - lent) + 0.4, ], [(spoty - lent) + 0.4, (spoty - lent) + 0.1, (spoty - lent) + 0.4, (spoty - lent) + 0.9]) if playing_field[i][2] == 5: stddraw.setPenColor(stddraw.BLACK) stddraw.setPenRadius(0.05) stddraw.filledPolygon([(spotx - lent) + 0.5, (spotx - lent) + 0.1, (spotx - lent) + 0.9], [(spoty - lent) + 0.8, (spoty - lent) + 0.1, (spoty - lent) + 0.1]) if playing_field[i][2] == 6: stddraw.setPenColor(stddraw.CYAN) stddraw.setPenRadius(0.05) stddraw.filledPolygon([(spotx - lent) + 0.5, (spotx - lent) + 0.1, (spotx - lent) + 0.9, (spotx - lent) + 0.3, (spotx - lent) + 0.6], [(spoty - lent) + 0.9, (spoty - lent) + 0.7, (spoty - lent) + 0.7, (spoty - lent) + 0.1, (spoty - lent) + 0.1]) if attempts == 0 and totalscore < finalscore: while stddraw.mousePressed() == False: stddraw.setPenColor(stddraw.BLACK) stddraw.filledRectangle(-lent, -(lent * y) - 2 * lent, (2 * lent * x), 3.5 * lent) stddraw.setFontSize(40) stddraw.setPenColor(stddraw.RED) stddraw.text(lent * x - lent, -(lent * y), 'YOU LOSE, CLICK TO EXIT') stddraw.show(0) if stddraw.mousePressed() == True: win = True return win if totalscore >= finalscore: while stddraw.mousePressed() == False: stddraw.setPenColor(stddraw.BOOK_BLUE) stddraw.filledRectangle(-lent, -(lent * y) - 2 * lent, (2 * lent * x), 3.5 * lent) stddraw.setFontSize(40) stddraw.setPenColor(stddraw.GREEN) stddraw.text(lent * x - lent, -(lent * y), 'YOU WIN, CLICK TO PROCEED') stddraw.show(0) if stddraw.mousePressed() == True: win = False return win stddraw.show(250) return win
winning_score = 80 def right(): if moves < 0 and score < winning_score: stddraw.text(5.2, 10.5, "You lose!") stddraw.show() elif score > winning_score: stddraw.text(5.2, 10.5, "You win!") stddraw.show() while game_over(): if turns == 1 and stddraw.mousePressed(): a = stdarray.create2D(9, 7, 0) select_first(a) first_position = select_first_position() right() if turns == 2 and stddraw.mousePressed(): select_second(a) score = juweimodule.creat_a_new_useful_game(game_board, score) print_remaining_moves() right() stddraw.show(15) stddraw.setFontSize(28) stddraw.setPenColor(stddraw.BLUE)
def waitForClick(): while (not stddraw.mousePressed()): stddraw.show(10)
stddraw.setCanvasSize(560, 880) # Tells user what the game is, and waits for a click on the window stddraw.setFontSize(160) stddraw.setPenColor(stddraw.BLUE) stddraw.text(0, 350, "TAFFY") stddraw.setPenColor(stddraw.BOOK_BLUE) stddraw.text(0, 180, "TANGLE") stddraw.setPenColor(stddraw.BLACK) stddraw.setFontSize(40) stddraw.text(0, 20, "Each taffy is 1 point.") stddraw.text(0, -60, "Reach 60 points as") stddraw.text(0, -120, "fast as you can!") stddraw.setPenColor(stddraw.DARK_GRAY) stddraw.setFontSize(30) while (not stddraw.mousePressed()): stddraw.text(0, -300, "Click anywhere to start!") stddraw.show(350) stddraw.setPenColor(stddraw.WHITE) stddraw.filledRectangle(-300, -350, 700, 100) stddraw.show(350) stddraw.setPenColor(stddraw.DARK_GRAY) # gets rid of everything except "TAFFY TANGLE" stddraw.setPenColor(stddraw.WHITE) stddraw.filledRectangle(-350, -350, 700, 400) stddraw.setFontSize(160) # cool transition into the game for i in range(130): stddraw.setPenColor(stddraw.BLUE)
def Game(self): turn = 0 turnCounter = 15 turnCondition = True key = True while turnCondition: stddraw.show(0) Graphics.drawTurnCounter(turnCounter) Graphics.drawWinThing() if turn == 0: if stddraw.mousePressed(): mx = stddraw.mouseX() my = stddraw.mouseY() if mx < 4.69 and my >= 1 and my < 10: Graphics.clickHelp() for i in range(self.x): if mx > i / 1.5 and mx < i / 1.5 + (2 / 3): mDrawX1 = i / 1.5 mEmojiX1 = i + 1 for i in range(self.y + 1): if my > i and my < i + 1: mDrawY1 = i mEmojiY1 = i + 1 / 2 for i in range(self.y): for j in range(self.x): if self.board[i][ j].x == mEmojiX1 and self.board[i][ j].y == mEmojiY1: e1emoji = self.board[i][j].emoji e1i, e1j = i, j Graphics.tileSelected(mDrawX1, mDrawY1) turn = 1 if turn == 1: if stddraw.mousePressed(): mx = stddraw.mouseX() my = stddraw.mouseY() if mx < 4.69 and my >= 1 and my < 10: for i in range(self.x): if mx > i / 1.5 and mx < i / 1.5 + (2 / 3): mEmojiX2 = i + 1 for i in range(self.y + 1): if my > i and my < i + 1: mEmojiY2 = i + 1 / 2 for i in range(self.y): for j in range(self.x): if self.board[i][ j].x == mEmojiX2 and self.board[i][ j].y == mEmojiY2: e2emoji = self.board[i][j].emoji e2i, e2j = i, j #Swapping the emojis """ NOTE THAT THE X POSITIONS ETC HAVE STILL NOT BEEN FIXED 11/18/2018 12:14 AM Conversion system new: when x == 1, emoji true position is 1/3, x == 2, 1, x == 3, 5/3 """ if mEmojiX2 == mEmojiX1 + 1 and mEmojiY2 == mEmojiY1 or mEmojiX2 == mEmojiX1 - 1 and mEmojiY2 == mEmojiY1 or mEmojiY2 == mEmojiY1 + 1 and mEmojiX2 == mEmojiX1 or mEmojiY2 == mEmojiY1 - 1 and mEmojiX2 == mEmojiX1: Graphics.clickHelpClear() self.board[e1i][e1j].emoji = e2emoji self.board[e2i][e2j].emoji = e1emoji counter = 0 while test.check(self.board) != 0: self.checkDraw(mDrawX1, mDrawY1) #Erase Vertical if test.getD() == 0: counter = 0 marker = self.board[test.getY()][ test.getX()].emoji while marker != 0: if test.getY() + counter != 9: if marker == self.board[test.getY( ) + counter][test.getX()].emoji: self.board[test.getY() + counter][test.getX( )].emoji = 0 Score.score += 1 counter += 1 else: marker = 0 else: marker = 0 self.checkDraw(mDrawX1, mDrawY1) #Vertical Drop count = 0 for j in range(9): if test.getY() + count + counter < 9: self.board[ test.getY() + count][test.getX( )].emoji = self.board[ test.getY() + count + counter][test.getX()].emoji self.board[ test.getY() + count + counter][test.getX()].emoji = 0 count += 1 self.checkDraw(mDrawX1, mDrawY1) temp = 9 - counter for i in range(counter): self.board[temp][ test.getX()].emoji = self.ranNum() temp += 1 self.checkDraw(mDrawX1, mDrawY1) #Erase Horizontal else: counter = 0 marker = self.board[test.getY()][ test.getX()].emoji while marker != 0: if test.getX() + counter != 7: if marker == self.board[test.getY( )][test.getX() + counter].emoji: self.board[test.getY()][ test.getX() + counter].emoji = 0 Score.score += 1 counter += 1 else: marker = 0 else: marker = 0 self.checkDraw(mDrawX1, mDrawY1) #Horizontal Drop count = 0 for i in range(counter): count = 0 for j in range(9): if test.getY() + count < 8: temp = count + 1 self.board[ test.getY() + count][ test.getX() + i].emoji = self.board[ test.getY() + temp][test.getX() + i].emoji self.board[test.getY() + temp][test.getX() + i].emoji = 0 count += 1 self.checkDraw(mDrawX1, mDrawY1) for i in range(counter): self.board[8][test.getX() + i].emoji = self.ranNum() self.checkDraw(mDrawX1, mDrawY1) turn = 0 #For when it is not a match 3 if counter == 0: self.board[e1i][e1j].emoji = e1emoji self.board[e2i][e2j].emoji = e2emoji Graphics.clickHelpClear() Graphics.drawInvalidMatch3() Graphics.clearInvalidSwitch() Graphics.tileSelectedClear(mDrawX1, mDrawY1) turn = 0 else: turnCounter -= 1 #For when you want to select the tile again elif mEmojiX1 == mEmojiX2 and mEmojiY1 == mEmojiY2: Graphics.clickHelpClear() Graphics.tileSelectedClear(mDrawX1, mDrawY1) turn = 0 #For when there is an invaid switch else: Graphics.clickHelpClear() Graphics.tileSelectedClear(mDrawX1, mDrawY1) Graphics.drawInvalidSwitch() Graphics.clearInvalidSwitch() turn = 0 else: turn = 1 #Note, mouse does not need to be pressed in order for this CheckWin if turnCounter == 0 and Score.score >= 75: Graphics.drawTurnCounter(turnCounter) turnCondition = False while key: Graphics.drawWinCondition() if stddraw.mousePressed(): key = False elif turnCounter == 0 and Score.score <= 75: Graphics.drawTurnCounter(turnCounter) turnCondition = False while key: Graphics.drawLossCondition() if stddraw.mousePressed(): key = False
def mouse_pressed(): if stddraw.mousePressed(): return True
score = 0 update() no_more_moves() first_click = True second_click = True channel1.play(bgm, loops=-1) mx1 = 0 my1 = 0 my2 = 0 mx2 = 0 while end == False and score < 700 and number_of_moves > 0: combo = -1 stddraw.show(0.0) while first_click: stddraw.show(0.0) if stddraw.mousePressed() and stddraw.mouseY() < 9 and stddraw.mouseX( ) > 0.5 and stddraw.mouseX() < 8.5: channel0.play(meow) if stddraw.mouseX() < 1.4: mx1 = 0 elif stddraw.mouseX() < 2.289: mx1 = 1 elif stddraw.mouseX() < 3.17777: mx1 = 2 elif stddraw.mouseX() < 4.0666: mx1 = 3 elif stddraw.mouseX() < 4.9555: mx1 = 4 elif stddraw.mouseX() < 5.8444: mx1 = 5 elif stddraw.mouseX() < 6.7333:
def win(score, startTime): t = round(time.time() - startTime, 2) winTime = "Time Elapsed: " + str(t) + " seconds" if (t <= 31 and score >= 73): rating = 7 text = "YOU ARE A CHAMPION -- YOU WIN!" elif (t <= 31 and score >= 69): rating = 6 text = "Incredible!! Masterfully done!!" elif (t <= 31): rating = 5 text = "Great job! Go get em' champ!!" elif (t <= 40): rating = 4 text = "Good. Not perfect, but not bad!" elif (t <= 48): rating = 3 text = "Sufficient, but could be better." elif (t <= 56): rating = 2 text = "What's taking so long, slowpoke?" elif (t <= 70): rating = 1 text = "Seriously, were you even trying?" else: rating = 0 text = "Exceptional. Exceptionally bad, that is." allErase() for i in range(210): showScore(score, 1 + i) stddraw.show(5) stddraw.show(1500) stddraw.setFontSize(40) stddraw.setPenColor(stddraw.DARK_GRAY) stddraw.text(0, 400, winTime) stddraw.show(1000) stddraw.setFontSize(60) stddraw.setPenColor(stddraw.BLACK) stddraw.text(0, 200, "Rating") stddraw._thickLine(-90, 167, 90, 167, 2) stddraw.show(1000) stddraw.setFontSize(30) stddraw.setPenColor(stddraw.DARK_GRAY) stddraw.text(0, -350, text) stddraw.setFontSize(300) if (rating >= 6): stddraw.setPenColor(stddraw.MAGENTA) stddraw.text(0, -50, str(rating) + "/5") elif (rating == 5): stddraw.setPenColor(stddraw.BLUE) stddraw.text(0, -50, str(rating) + "/5") elif (rating == 4): stddraw.setPenColor(stddraw.BOOK_BLUE) stddraw.text(0, -50, str(rating) + "/5") elif (rating == 3): stddraw.setPenColor(stddraw.YELLOW) stddraw.text(0, -50, str(rating) + "/5") elif (rating == 2): stddraw.setPenColor(stddraw.ORANGE) stddraw.text(0, -50, str(rating) + "/5") elif (rating == 1): stddraw.setPenColor(stddraw.RED) stddraw.text(0, -50, str(rating) + "/5") else: stddraw.setPenColor(stddraw.BOOK_RED) stddraw.text(0, -50, str(rating) + "/5") if (rating != 7): stddraw.show(1500) stddraw.setPenColor(stddraw.BLACK) stddraw.setFontSize(30) stddraw.text(170, -500, "Click anywhere to exit.") waitForClick() else: val = True count = 0 list = [stddraw.MAGENTA, stddraw.RED, stddraw.BLUE, stddraw.CYAN, stddraw.YELLOW, stddraw.GREEN] while (not stddraw.mousePressed()): count += 1 stddraw.setPenColor(stddraw.WHITE) stddraw.filledRectangle(-300, -200, 700, 300) stddraw.setPenColor(list[random.randint(0, 5)]) stddraw.text(0, -50, str(rating) + "/5") if (val and count >= 30): stddraw.setPenColor(stddraw.BLACK) stddraw.setFontSize(30) stddraw.text(170, -500, "Click anywhere to exit.") stddraw.setFontSize(300) val = False stddraw.show(45)
stddraw.show() return game_win game_win = True count = 0 mouse_clicked = False game_playerOne_click = [] game_playertwo_click = [] while game_win == True: """playerOne turn""" mouse_clicked = False while mouse_clicked == False: mouse_clicked = stddraw.mousePressed() # return boolean stddraw.clear() stddraw.setFontSize(30) stddraw.text(1, 3.5, "Is playerOne's turn") draw_the_picture(game_array) if mouse_clicked: game_array = player_two_draw(game_array) stddraw.show(1) game_playertwo_click = [] game_playertwo_click = expend_the_player_array(game_playertwo_click, 2) game_win = determine_the_winner(game_playertwo_click, 1, game_win)
return True play = True click = 1 score_count = 0 score = [0] * 3 for i in range(3): score[i] = [0] * 3 tictacdraw.draw_board() tictacdraw.first_turn() while play: mouse_click = stddraw.mousePressed() if mouse_click: x = stddraw.mouseX() y = stddraw.mouseY() click *= -1 score_count += 1 if click == -1: tictacdraw.X(score, x, y) tictacdraw.player_two_turn() if click == 1: tictacdraw.O(score, x, y) tictacdraw.player_one_turn() wins(score) if score_count == 9: no_win(score) stddraw.show(1000)