id int64 0 25.6k | text stringlengths 0 4.59k |
|---|---|
10,500 | five appendices using error messages you can expect to make some errors while coding idle provides information about the location and type of errors in several waysdepending on the kind of error to be most usefulyou want to be able to decode the error feedback idle developers keep updating error messages to make them m... |
10,501 | realize it was at the end of statement when can statement go on to the next linewhen there are unmatched grouping charactersmost commonly it is very easy to have unmatched parenthesesparticularly when there are many levels of pairs of parentheses recall that when you type in idle it shows you what closing parentheses m... |
10,502 | can now try to run again this time we do not get pop-up syntax error window this means the interpreter did not find any errors reading the program many errors are only found when running the programso execution starts in the shellleading to run-time error the program first prompts for numberand enter we see red error t... |
10,503 | int(input("enter number")note that the error was suggesting fix that you do not wantending up with string concatenation when something does not make sensethe interpreter does not know what you mean it tries to make suggestion that is likely to be helpfulthough in this case it is wrong at least in this case it was sugge... |
10,504 | chose common simple errorsso hopefully you would have been able to figure out the meaning of the error message that is lot to expect in general we are only gradually adding explanations of bits of python syntax you can easily make an error that the python interpreter guesses as being based on more advanced featureso th... |
10,505 | appendices |
10,506 | some special windows instructions while the python language changes slowlyoperating systems and setup methods change more rapidly with succeeding versions the attempt here is to keep all such information in one place for the windows operating system it may become out of date at any time last checked this on windows and... |
10,507 | you are strongly suggested to change the viewing default in file explorer to show extensions cgi instructions you can skip this until you are starting on cgi files opening cgi files in idle by convention the server programs that you will be writing end in cgithat is not an extension that is automatically associated wit... |
10,508 | versions will use python to mean the current version of pythonwith version number at least make sure you have the latest recommended version installed from click to execute editing by default in idle you will be working mostly with files ending in py python source files most of the time you will be editing them and run... |
10,509 | for getting py files to open in idle by defaultexcept choose cgi file in my www folderand go through the same procedure setupmaking cgi scripts executable complication on maclike any unix derived systemis that programs that you run must be explicitly marked executable (on windows it follows from the file extensionlike ... |
10,510 | cd desktop here is sequence on my computer after starting terminal (skipping most of the output from lslast loginsat may : : on ttys anh@lucky (anh@lucky ):~pwd /users/anh anh@lucky (anh@lucky ):~ls desktop documents downloads anh@lucky (anh@lucky ):~cd desktop anh@lucky (anh@lucky ):~/desktoppwd /users/anh/desktop anh... |
10,511 | mac users textedityou can also edit raw html with the included mac app texteditbut with several steps to change the defaults (the initial defaults are to show no html source since textedit does not do syntax coloringan editor like sublime text is likely betteras long as you do not mind doing one extra download if you d... |
10,512 | about this book hellothis book will teach you how to make graphical computer games with the pygame framework (also called the pygame libraryin the python programming language pygame makes it easy to create programs with graphics both python and the pygame framework can be downloaded for free from and this book to begin... |
10,513 | iii table of contents who is this book fori about this book ii installing python and pygame what you should know before you begin downloading and installing python windows instructions mac os instructions ubuntu and linux instructions starting python installing pygame how to use this book the featured programs download... |
10,514 | reminder about functionsmethodsconstructor functionsand functions in modules (and the difference between them surface objects and the window colors transparent colors pygame color objects rect objects primitive drawing functions pygame pixelarray objects the pygame display update(function animation frames per second an... |
10,515 | one item tuples need trailing comma converting between lists and tuples the global statementand why global variables are evil data structures and lists the --start game|animation the game loop the event handling loop checking which box the mouse cursor is over handling the first clicked box handling mismatched pair of ... |
10,516 | why bother having main(function why bother with readability summaryand hacking suggestion slide puzzle how to play slide puzzle source code to slide puzzle second versesame as the first setting up the buttons being smart by using stupid code the main game loop clicking on the buttons sliding tiles with the mouse slidin... |
10,517 | vii drawing the buttons animating the tile slides the copy(surface method creating new puzzle animating the board reset time vs memory tradeoffs nobody cares about few bytes nobody cares about few million nanoseconds summary simulate how to play simulate source code to simulate the usual starting stuff setting up the b... |
10,518 | converting from pixel coordinates to buttons explicit is better than implicit wormy how to play wormy source code to wormy the grid the setup code the main(function separate rungame(function the event handling loop collision detection detecting collisions with the apple moving the worm the insert(list method drawing th... |
10,519 | ix setting up timing constants for holding down keys more setup code setting up the piece templates splitting --line of code|across multiple lines the main(function the start of new game the game loop the event handling loop pausing the game using movement variables to handle user input checking if slide or rotation is... |
10,520 | drawing the score and level text drawing piece on the board or elsewhere on the screen drawing the --next|piece summary squirrel eat squirrel how to play squirrel eat squirrel the design of squirrel eat squirrel source code to squirrel eat squirrel the usual setup code describing the data structures the main(function t... |
10,521 | xi the game over screen winning drawing graphical health meter the same old terminate(function the mathematics of the sine function backwards compatibility with python version the getrandomvelocity(function finding place to add new squirrels and grass creating enemy squirrel data structures flipping the squirrel image ... |
10,522 | the flood fill algorithm drawing the map checking if the level is finished summary four extra games flippyan --othello|clone source code for flippy ink spilla --flood it|clone source code for ink spill four-in- -rowa --connect four|clone source code for four-in- -row gemgema --bejeweled|clone source code for gemgem sum... |
10,523 | xiii this page intentionally left blank except for the above text and the above text and the above text and the above text and the above text and the above text and the above text and the above text and the above text traceback (most recent call last)file ""line in blankpage def blankpage()blankpage(runtimeerrormaximum... |
10,524 | email questions to the authoral@inventwithpython com |
10,525 | installing python and pygame what you should know before you begin it might help if you know bit about python programming (or how to program in another language besides pythonbefore you read through this bookhowever even if you haven' you can still read this book anyway programming isn' nearly as hard as people think i... |
10,526 | download pagethen look for the file called --python windows installer (windows binary -does not include source)|and click on its link to download python for windows double-click on the python- msi file that you've just downloaded to start the python installer (if it doesn' starttry right-clicking the file and choosing ... |
10,527 | if your operating system is ubuntu or linuxstart idle by opening terminal window and then type --idle |and press enter you may also be able to click on applications at the top of the screenand then select programmingthen idle the window that appears when you first run idle is called the interactive shell shell is progr... |
10,528 | if nothing appears after you hit the enter keythen you know pygame has successfully been installed if the error importerrorno module named pygame appearsthen try to install pygame again (and make sure you typed import pygame correctlythis has five small programs that demonstrate how to use the different features that p... |
10,529 | number random randint( spam print('hello world!'you do not need to type the -- |on the left sideor the space that immediately follows it just type it like thisnumber random randint( spam print('hello world!'those numbers are only used so that this book can refer to specific lines in the code they are not part of the ac... |
10,530 | checking your code online some of the programs in this book are little long although it is very helpful to learn python by typing out the source code for these programsyou may accidentally make typos that cause your programs to crash it may not be obvious where the typo is you can copy and paste the text of your source... |
10,531 | pygame basics just like how python comes with several modules like randommathor time that provide additional functions for your programsthe pygame framework includes several modules with functions for drawing graphicsplaying soundshandling mouse inputand other things this will cover the basic modules and functions that... |
10,532 | rememberdo not type the numbers or the periods at the beginning of each line (that' just for reference in this book import pygamesys from pygame locals import pygame init( displaysurf pygame display set_mode(( ) pygame display set_caption('hello world!' while truemain game loop for event in pygame event get() if event ... |
10,533 | line is simple import statement that imports the pygame and sys modules so that our program can use the functions in them all of the pygame functions dealing with graphicssoundand other features that pygame provides are in the pygame module note that when you import the pygame module you automatically import all the mo... |
10,534 | remember to pass tuple of two integers to set_mode()not just two integers themselves the correct way to call the function is like thispygame display set_mode(( ) function call like pygame display set_mode( will cause an error that looks like thistypeerrorargument must be -item sequencenot int the pygame surface object ... |
10,535 | taking damage (which lowers their health value)or an enemy moves somewhereor something happens in the game world we say that the game state has changed if you've ever played game that let you savedthe --save state|is the game state at the point that you've saved it in most gamespausing the game will prevent the game st... |
10,536 | while truemain game loop for event in pygame event get()line is for loop that will iterate over the list of event objects that was returned by pygame event get(on each iteration through the for loopa variable named event will be assigned the value of the next event object in this list the list of event objects returned... |
10,537 | line calls the pygame display update(functionwhich draws the surface object returned by pygame display set_mode(to the screen (remember we stored this object in the displaysurf variablesince the surface object hasn' changed (for exampleby some of the drawing functions that are explained later in this the same black ima... |
10,538 | the pygame framework often represents cartesian coordinates as tuple of two integerssuch as ( or ( the first integer is the coordinate and the second is the coordinate (cartesian coordinates are covered in more detail in of --invent your own computer games with python|at reminder about functionsmethodsconstructor funct... |
10,539 | egg wombat(egg bluhbluh(whammy spam(even though these names are all made upyou can tell which is function calla method calland call to function inside method the name whammy refers to modulesince you can see it is being imported on the first line the fizzy name has nothing before it and parentheses after itso you know ... |
10,540 | colors there are three primary colors of lightredgreen and blue (redblueand yellow are the primary colors for paints and pigmentsbut the computer monitor uses lightnot paint by combining different amounts of these three colors you can form any other color in pygamewe represent colors with tuples of three integers the f... |
10,541 | transparent colors when you look through glass window that has deep red tintall of the colors behind it have red shade added to them you can mimic this effect by adding fourth to integer value to your color values this value is known as the alpha value it is measure of how opaque (that isnot transparenta color is norma... |
10,542 | (above is screenshot of drawing of the invisible pink unicorn pygame color objects you need to know how to represent color because pygame' drawing functions need way to know what color you want to draw with tuple of three or four integers is one way another way is as pygame color object you can create color objects by ... |
10,543 | the coordinate of the top left corner the width (in pixelsof the rectangle then height (in pixelsof the rectangle the second way is as pygame rect objectwhich we will call rect objects for short for examplethe code below creates rect object with top left corner at ( that is pixels wide and pixels tallimport pygame spam... |
10,544 | attribute name description myrect left the int value of the -coordinate of the left side of the rectangle myrect right the int value of the -coordinate of the right side of the rectangle myrect top the int value of the -coordinate of the top side of the rectangle myrect bottom the int value of the -coordinate of the bo... |
10,545 | pygame init( set up the window displaysurf pygame display set_mode(( ) pygame display set_caption('drawing' set up the colors black white ( red ( green blue draw on the surface object displaysurf fill(white pygame draw polygon(displaysurfgreen(( )( )( )( )( )) pygame draw line(displaysurfblue( )( ) pygame draw line(dis... |
10,546 | notice how we make constant variables for each of the colors doing this makes our code more readablebecause seeing green in the source code is much easier to understand as representing the color green than ( is the drawing functions are named after the shapes they draw the parameters you pass these functions tell them ... |
10,547 | pygame draw line(surfacecolorstart_pointend_pointwidththis function draws line between the start_point and end_point parameters pygame draw lines(surfacecolorclosedpointlistwidththis function draws series of lines from one point to the nextmuch like pygame draw polygon(the only difference is that if you pass false for ... |
10,548 | functions can still be called on itbut it cannot have images like png or jpg images drawn on it with the blit(method (the blit(method is explained later in this if you want to see if surface object is lockedthe get_locked(surface method will return true if it is locked and false if it is not the pixelarray object that ... |
10,549 | if you changed the window so that was black and , was whiteit would look like thisto the userit looks like the black pixel has --moved|over to the left if you redrew the window to have the black pixel at it would continue to look like the black pixel is moving leftit may look like the black pixel is movingbut this is j... |
10,550 | import pygamesys from pygame locals import pygame init( fps frames per second setting fpsclock pygame time clock( set up the window displaysurf pygame display set_mode(( ) pygame display set_caption('animation' white ( catimg pygame image load('cat png' catx caty direction 'right while truethe main game loop displaysur... |
10,551 | fpsclock tick(fpslook at that animated cat gothis program will be much more of commercial success than my game--look at this rock different rock|frames per second and pygame time clock objects the frame rate or refresh rate is the number of pictures that the program draws per secondand is measured in fps or frames per ... |
10,552 | drawing images with pygame image load(and blit(the drawing functions are fine if you want to draw simple shapes on the screenbut many games have images (also called spritespygame is able to load images onto surface objects from pngjpggifand bmp image files the differences between these image file formats is described a... |
10,553 | pygame draw line(calls and figure out all the xy coordinatesand probably wouldn' look very good the above message would take forty one calls to the pygame draw line(function to make insteadpygame provides some much simpler functions for fonts and creating text here is small hello world program using pygame' font functi... |
10,554 | set the position of the rect object by changing one of its attributes on line we set the center of the rect object to be at blit the surface object with the text onto the surface object returned by pygame display set_mode((line call pygame display update(to make the display surface appear on the screen (line the parame... |
10,555 | pygame draw lines()except they will draw anti-aliased (smoothlines instead of aliased (blockylines playing sounds playing sounds that are stored in sound files is even simpler than displaying images from image files firstyou must create pygame mixer sound object (which we will call sound objects for shortby calling the... |
10,556 | to stop playing the background music immediatelycall the pygame mixer music stop(function this function has no arguments here is some example code of the sound methods and functionsloading and playing sound effectsoundobj pygame mixer sound('beepingsound wav'soundobj play(loading and playing background musicpygame mixe... |
10,557 | memory puzzle how to play memory puzzle in the memory puzzle gameseveral icons are covered up by white boxes there are two of each icon the player can click on two boxes to see what icon is behind them if the icons matchthen those boxes remain uncovered the player wins when all the boxes on the board are uncovered to g... |
10,558 | there are several times in the memory puzzle code that we need to iterate through every possible and coordinate on the board we'll use nested for loops to make sure that we get every combination note that the inner for loop (the for loop inside the other for loopwill go through all of its iterations before going to the... |
10,559 | message and check your code for any typos you can also copy and paste your code into the web form at code in the book you'll probably pick up few ideas about how the program works just by typing it in once and when you're done typing it inyou can then play the game for yourself memory puzzle by al sweigart al@inventwit... |
10,560 | square 'square diamond 'diamond lines 'lines oval 'oval allcolors (redgreenblueyelloworangepurplecyan allshapes (donutsquarediamondlinesoval assert len(allcolorslen(allshapes >boardwidth boardheight"board is too big for the number of shapes/colors defined def main() global fpsclockdisplaysurf pygame init( fpsclock pyga... |
10,561 | if boxx !none and boxy !none the mouse is currently over box if not revealedboxes[boxx][boxy] drawhighlightbox(boxxboxy if not revealedboxes[boxx][boxyand mouseclicked revealboxesanimation(mainboard[(boxxboxy)] revealedboxes[boxx][boxytrue set the box as "revealed if firstselection =nonethe current box was the first bo... |
10,562 | fpsclock tick(fps def generaterevealedboxesdata(val) revealedboxes [ for in range(boardwidth) revealedboxes append([valboardheight return revealedboxes def getrandomizedboard() get list of every possible shape in every possible color icons [ for color in allcolors for shape in allshapes icons append(shapecolor random s... |
10,563 | top boxy (boxsize gapsizeymargin return (lefttop def getboxatpixel(xy) for boxx in range(boardwidth) for boxy in range(boardheight) lefttop lefttopcoordsofbox(boxxboxy boxrect pygame rect(lefttopboxsizeboxsize if boxrect collidepoint(xy) return (boxxboxy return (nonenone def drawicon(shapecolorboxxboxy) quarter int(box... |
10,564 | color value for xy spot is stored in board[ ][ ][ return board[boxx][boxy][ ]board[boxx][boxy][ def drawboxcovers(boardboxescoverage) draws boxes being covered/revealed "boxesis list of two-item listswhich have the spot of the box for box in boxes lefttop lefttopcoordsofbox(box[ ]box[ ] pygame draw rect(displaysurfbgco... |
10,565 | def drawhighlightbox(boxxboxy) lefttop lefttopcoordsofbox(boxxboxy pygame draw rect(displaysurfhighlightcolor(left top boxsize boxsize ) def startgameanimation(board) randomly reveal the boxes at time coveredboxes generaterevealedboxesdata(false boxes [ for in range(boardwidth) for in range(boardheight) boxes append(xy... |
10,566 | main(credits and imports memory puzzle by al sweigart al@inventwithpython com released under "simplified bsdlicense import randompygamesys from pygame locals import at the top of the program are comments about what the game iswho made itand where the user could find more information there' also note that the source cod... |
10,567 | much betterespecially since we might use the integer value for something else besides the size of the white boxesand changing that accidentally would cause bugs in our program secondit makes the code more readable go down to the next section and look at line this sets up calculation for the xmargin constantwhich is how... |
10,568 | the assert statement on line ensures that the board width and height we've selected will result in an even number of boxes (since we will have pairs of icons in this gamethere are three parts to an assert statementthe assert keywordan expression whichif falseresults in crashing the program the third part (after the com... |
10,569 | file " :\book svn\src\memorypuzzle py"line in main(file " :\book svn\src\memorypuzzle py"line in main mainboard getrandomizedboard(file " :\book svn\src\memorypuzzle py"line in getrandomizedboard columns append(icons[ ]indexerrorlist index out of range we could spend lot of time looking at getrandomizedboard(trying to ... |
10,570 | tuples are called rgb values notice the spacing of the tuples on lines to are such that the rgand integers line up in python the indentation (that isthe space at the beginning of the lineis needs to be exactbut the spacing in the rest of the line is not so strict by spacing the integers in the tuple outwe can clearly s... |
10,571 | making sure we have enough icons allcolors (redgreenblueyelloworangepurplecyan allshapes (donutsquarediamondlinesoval assert len(allcolorslen(allshapes >boardwidth boardheight"board is too big for the number of shapes/colors defined in order for our game program to be able to create icons of every possible color and sh... |
10,572 | there is silly benefit and an important benefit to tuple' immutability the silly benefit is that code that uses tuples is slightly faster than code that uses lists (python is able to make some optimizations knowing that the values in tuple will never change but having your code run few nanoseconds faster is not importa... |
10,573 | if you forget this comma (and it is very easy to forget)then python won' be able to tell the difference between this and set of parentheses that just change the order of operations for examplelook at the following two lines of codevariablea ( variableb ( the value that is stored in variablea is just the integer however... |
10,574 | variables inside the main(functionthose names are not for local variables that might just happen to have the same name as global variables they are the global variables any values assigned to them in the main(function will persist outside the main(function we are marking the fpsclock and displaysurf variables as global... |
10,575 | data structures and lists mainboard getrandomizedboard(revealedboxes generaterevealedboxesdata(falsethe getrandomizedboard(function returns data structure that represents the state of the board the generaterevealedboxesdata(function returns data structure that represents which boxes are coveredrespectively the return v... |
10,576 | meanwhilethe --revealed boxes|data structure is also listexcept instead of two-item tuples like the board data structureit has boolean valuestrue if the box at that xy coordinate is revealedand false if it is covered up passing false to the generaterevealedboxesdata(function sets all of the boolean values to false (thi... |
10,577 | the game loop is an infinite loop that starts on line that keeps iterating for as long as the game is in progress remember that the game loop handles eventsupdates the game stateand draws the game state to the screen the game state for the memory puzzle program is stored in the following variablesmainboard revealedboxe... |
10,578 | if the event object was either quit event or keyup event for the esc keythen the program should terminate otherwisein the event of mousemotion event (that isthe mouse cursor has movedor mousebuttonup event (that isa mouse button was pressed earlier and now the button was let up)the position of the mouse cursor should b... |
10,579 | "revealed revealedboxes[boxx][boxytrue set the box as on line we check if the mouse cursor is not only over covered up box but if the mouse has also been clicked in that casewe want to play the --reveal|animation for that box by calling our revealboxesanimation(function (which isas with all the other functions main(cal... |
10,580 | handling mismatched pair of icons if icon shape !icon shape or icon color !icon color icons don' match re-cover up both selections pygame time wait( milliseconds sec coverboxesanimation(mainboard[(firstselection[ ]firstselection[ ])(boxxboxy)] revealedboxes[firstselection[ ]][firstselection [ ]false revealedboxes[boxx]... |
10,581 | if that is the casewe want to play the --game won|animation by calling gamewonanimation()then pause slightly to let the player revel in their victoryand then reset the data structures in mainboard and revealedboxes to start new game line plays the --start game|animation again after thatthe program execution will just l... |
10,582 | 've kept saying that the other functions would be explained later in the now that we've gone over the main(function and you have an idea for how the general program workslet' go into the details of all the other functions that are called from main(creating the "revealed boxesdata structure def generaterevealedboxesdata... |
10,583 | step shuffling and truncating the list of all icons random shuffle(iconsrandomize the order of the icons list numiconsused int(boardwidth boardheight calculate how many icons are needed icons icons[:numiconsused make two of each random shuffle(iconsbut rememberthere may be more possible combinations than spaces on the ... |
10,584 | del mylist[ mylist ['dog''mouse''lizard'del mylist[ mylist ['mouse''lizard'del mylist[ mylist ['lizard'del mylist[ mylist [because we are deleting the item at the front of the listthe other items shift forward so that the next item in the list becomes the new --first|item this is the same way line works splitting list ... |
10,585 | note that even though the largest index of thelist would be in our examplethelist[ : won' raise an indexerror error even though is larger than it will just create list slice with the remaining items in the list list slicing doesn' destroy or change the original list stored in thelist it just copies portion of it to eva... |
10,586 | the lefttopcoordsofbox(function will take box coordinates and return pixel coordinates because box takes up multiple pixels on the screenwe will always return the single pixel at the top left corner of the box this value will be returned as two-integer tuple the lefttopcoordsofbox(function will often be used when we ne... |
10,587 | in order to find which box the mouse coordinates are overwe will go through each box' coordinates and call the collidepoint(method on rect object with those coordinates when collidepoint(returns truewe know we have found the box that was clicked on or moved over and will return the box coordinates if none of them retur... |
10,588 | pygame draw circle(displaysurfcolor(left halftop half)half pygame draw circle(displaysurfbgcolor(left halftop half)quarter elif shape =square pygame draw rect(displaysurfcolor(left quartertop quarterboxsize halfboxsize half) elif shape =diamond pygame draw polygon(displaysurfcolor((left halftop)(left boxsize top half)(... |
10,589 | lefttop lefttopcoordsofbox(box[ ]box[ ] pygame draw rect(displaysurfbgcolor(lefttopboxsizeboxsize) shapecolor getshapeandcolor(boardbox[ ]box[ ] drawicon(shapecolorbox[ ]box[ ] if coverage only draw the cover if there is an coverage pygame draw rect(displaysurfboxcolor(lefttopcoverageboxsize) pygame display update( fps... |
10,590 | for coverage in range( boxsize revealspeedrevealspeed)drawboxcovers(boardboxestocovercoverageremember that an animation is simply just displaying different images for brief moments of timeand together they make it seem like things are moving on the screen the revealboxesanimation(and coverboxesanimation(only need to dr... |
10,591 | drawicon(shapecolorboxxboxythe drawboard(function makes call to drawicon(for each of the boxes on the board the nested for loops on lines and will loop through every possible and coordinate for the boxesand will either draw the icon at that location or draw white square instead (to represent covered up boxdrawing the h... |
10,592 | the first boxes in this list (and each group of boxes afterwards)it will be random group of boxes to get the lists of boxeswe call our splitintogroupsof(functionpassing and the list in boxes the list of lists that the function returns will be stored in variable named boxgroups revealing and covering the groups of boxes... |
10,593 | on line this way the program will alternate between drawing two different background colors remember that this function needs to call pygame display update(to actually make the displaysurf surface appear on the screen telling if the player has won def haswon(revealedboxes) returns true if all the boxes have been reveal... |
10,594 | secondthis also lets you import the program so that you can call and test individual functions if the memorypuzzle py file is in the :\python folderthen you can import it from the interactive shell type the following to test out the splitintogroupsof(and getboxatpixel(functions to make sure they return the correct retu... |
10,595 | as the code at the beginning of this but if there was bug with this codeit would be impossible to read the code and understand what' going onmuch less fix the bug the computer doesn' mind code as unreadable as this it' all the same to it import randompygamesys from pygame locals import def hhh()global ab pygame init( p... |
10,596 | if ! or fff !gggpygame time wait( ( [( [ ] [ ])(bbee)]hh[ [ ]][ [ ]false hh[bb][eefalse elif ii(hh)jj(ipygame time wait( (hh (falsef(ihhpygame display update(pygame time wait( (ih none pygame display update( tick( def (ccc)hh [for in range( )hh append([ccc return hh def ()rr [for tt in (( )( )( )( )( )( )( ))for ss in ... |
10,597 | for bb in range( )for ee in range( )ooddd aa(bbeeaaa pygame rect(ooddd if aaa collidepoint(xy)return (bbeereturn (nonenonedef (ssttbbee)ooddd aa(bbeeif ss =' 'pygame draw circle(btt(oo ddd ) pygame draw circle( ( )(oo ddd ) elif ss =' 'pygame draw rect(btt(oo ddd )elif ss =' 'pygame draw polygon(btt((oo ddd)(oo ddd )(o... |
10,598 | elsesstt (bbbbbeew(ssttbbeedef (bbee)ooddd aa(bbeepygame draw rect( ( )(oo ddd ) def (bbb)mm (falseboxes [for in range( )for in range( )boxes append(xyrandom shuffle(boxeskk ( boxesf(bbbmmfor nn in kko(bbbnnp(bbbnndef jj(bbb)mm (truett ( tt ( for in range( )tt tt tt tt fill(tt (bbbmmpygame display update(pygame time wa... |
10,599 | and different coordinate systems in the same programso they won' be explained again to keep this book short one idea to try out to understand how the code works is to intentionally break it by commenting out random lines doing this to some of the lines will probably cause syntactic error that will prevent the script fr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.