keronboutique.blogg.se

Slidepuzzle
Slidepuzzle










ResetAnimation(mainBoard, allMoves) # clicked on Reset button # check if the user clicked on an option button Spotx, spoty = getSpotClicked(mainBoard, event.pos, event.pos) Msg = 'Click tile or press arrow keys to slide.' # contains the message to show in the upper left corner.įor event in (): # event handling loop SlideTo = None # the direction, if any, a tile should slide SOLVEDBOARD = getStartingBoard() # a solved board is the same as the board in a start state.ĪllMoves = # list of moves made from the solved configuration MainBoard, solutionSeq = generateNewPuzzle(80) SOLVE_SURF, SOLVE_RECT = makeText('Solve', TEXTCOLOR, TILECOLOR, WINDOWWIDTH - 120, WINDOWHEIGHT - 30) NEW_SURF, NEW_RECT = makeText('New Game', TEXTCOLOR, TILECOLOR, WINDOWWIDTH - 120, WINDOWHEIGHT - 60) RESET_SURF, RESET_RECT = makeText('Reset', TEXTCOLOR, TILECOLOR, WINDOWWIDTH - 120, WINDOWHEIGHT - 90) # Store the option buttons and their rectangles in OPTIONS. _caption('Slide Puzzle')īASICFONT = ('freesansbold.ttf', BASICFONTSIZE) Global FPSCLOCK, DISPLAYSURF, BASICFONT, RESET_SURF, RESET_RECT, NEW_SURF, NEW_RECT, SOLVE_SURF, SOLVE_RECTĭISPLAYSURF = _mode((WINDOWWIDTH, WINDOWHEIGHT)) YMARGIN = int((WINDOWHEIGHT - (TILESIZE * BOARDHEIGHT + (BOARDHEIGHT - 1))) / 2) XMARGIN = int((WINDOWWIDTH - (TILESIZE * BOARDWIDTH + (BOARDWIDTH - 1))) / 2) # Create the constants (go ahead and experiment with different values)īOARDWIDTH = 4 # number of columns in the boardīOARDHEIGHT = 4 # number of rows in the board

slidepuzzle

# Released under a "Simplified BSD" license

#Slidepuzzle code

You can also copy and paste your code into the web form at to see if the differences between your code and the code in the book. If you get any error messages, look at the line number that is mentioned in the error message and check your code for any typos.










Slidepuzzle