;ò ;Bc@sQdZdkZdkZdkZdkZdkZdkZdkZdkTdk l Z l Z l Z l Z lZlZlZdklZlZlZdklZlZdfd„ƒYZdfd „ƒYZd fd „ƒYZd fd „ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdS(iN(s*(s load_images load_soundsMyErrors get_filess load_musics font2surfsChildsplayGoodies(sCPSpritesCPGroupsCPinit(ssqrtsacossImgcBstZRS(N(s__name__s __module__(((s./lib/billiard.pysImg!ssMisccBstZRS(N(s__name__s __module__(((s./lib/billiard.pysMisc$ssSoundcBstZRS(N(s__name__s __module__(((s./lib/billiard.pysSound'ssHolecBstZRS(N(s__name__s __module__(((s./lib/billiard.pysHole*ssBallcBs_tZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z RS( sX A ball that can move on the table, collide with other ball and enter the hole. cCsÇti|ƒ||_|iƒi|ƒ|_|_ |i d|i df|_ |i i |i i |i i |i if|_|iddd|_d|_ddf|_d|_||_dS(Niiif0.94999999999999996f0.90000000000000002(sCPSprites__init__sselfspicsimagesget_rectsmovesstartsrectsposintsposrealsrightsleftsbottomstopssizessqradiusssmthnssdirecsthknsskind(sselfspicsstartskind((s./lib/billiard.pys__init__1s  /  cCs |iSdS(N(sselfskind(sself((s./lib/billiard.pys__str__=scGs|iƒ}|SdS(s& This is called on every refresh call.N(sselfsmadeholesv(sselfsargssv((s./lib/billiard.pys on_update@s cCsZ|id|id|id|idf|_t|idƒt|idƒf\|i_|i_|iidjoUd|id|i_|ii|idf|_|id |idf|_n|ii djoUd|id|i_|id|iif|_|id|id f|_n|iidjoDd|i_d|idf|_|id |idf|_n|iidjoDd|i_|iddf|_|id|id f|_n|id|i |id|i f|_|idd|idddjoddf|_dSndSdS(s Moves the ball iiiiìiiN( sselfsposrealsdirecsintsposintsleftstopsrightssizesbottomssmthns(sself((s./lib/billiard.pysmoveitDs038"" " "+'cCsG|id||id|f|_|idd|iddSdS(s# changes the direction of the ball iiiN(sselfsdirecsxsy(sselfsxsy((s./lib/billiard.pysaddtodirbs%cCsM|id||id|f|_|ii|7_|ii|7_dS(s changes position of the ball iiN(sselfsposrealsxsysposintsleftstop(sselfsxsy((s./lib/billiard.pysaddtoposfs%cCsÌ|ii|idd|d|idd|dƒ}t|dd|ddƒ}d|jo|iddjno:d}|djo#|d||d|f|_ qÄnd}|SdS(sx What to do under mouse button pressed. This is not a callback like the ones used in a typical CPSprite object.iiiN( sselfsposintsmovessizesmousepossdiffssqrtsdists valtoreturnsmousebutsdirec(sselfsmousepossmousebutsdists valtoreturnsdiff((s./lib/billiard.pyscallbackks; ) 'c Cs^|id|id|id|idf\}}|d|d} t| ƒ}||id|idd}|djoÒ|i d|i d|i d|i df}|i ||d||d| }|i| || |ƒ}|i| ||| ||ƒ|iƒ|i||||ƒ} |iƒd|| fSndfSdS(s$ checks whether two objects collide iiiN(sselfsposrealsotherobjsxsys squaredistssqrtsdistssizesoverlapsdirecsdiffvelsthknsscoefsaddtodirsnewvelsaddtopossmoveitsnewvelotherobj( sselfsotherobjsdistscoefsnewvelsoverlapsdiffvelsysxsnewvelotherobjs squaredist((s./lib/billiard.pyscheckcollisionys6   0%"  cCsp|idtid|idtidf}|dd|dd}||ijo|dfSndSdS(s! checks if ball entered the hole iiiN(sselfsposrealsHolespossdiffssqdistssqradius(sselfsdiffssqdist((s./lib/billiard.pysmadeholeŠs 0( s__name__s __module__s__doc__s__init__s__str__s on_updatesmoveitsaddtodirsaddtoposscallbackscheckcollisionsmadehole(((s./lib/billiard.pysBall-s        sStickcBs5tZd„Zd„Zd„Zd„Zd„ZRS(NcCsyti|ƒ||_|_|iƒ|_d|_||_ |iƒi |ƒ|_ |_ ddg|_ d|_dS(NiiP(sCPSprites__init__sselfspicsimagesorigpicsget_rectsorigsizesanglesstartsmovesrectsposintsdisps maxstrength(sselfspicsstart((s./lib/billiard.pys__init__”s   cCs ||_|d|d|d|df}t|dd|ddƒ}|d||d|f}t|dƒdd|_|ddjod|i|_nt i i |i |iƒ|_ |_|ddjo |ii |d|idt#ddƒD])}tt i ƒi ƒt iidƒqÒWqq|i%|it&ƒndS(Nisblueièiÿÿÿÿiis You won!!iPidi,iixs spointsiÈ('sselfslevelsstrsobjsremovesMiscsgroups remove_sprites load_musicsSoundshurrasplayslenspygamestimeswaitsints pointstoaddsthrowssssChildsplayGoodiess scorethingsscores maxscoressstopsscreensblitsbackgrs moving_signs_s font2surfstxtsszsdisplaysupdatesrangesisstartsNone(sselfsobjsszsissstxt((s./lib/billiard.pys _made_holehs2#     C8 cCsd|_|i oùx|D]ê}|itjoitti ƒoqn|i djo˜|i i |i |i ƒox|ii|i |i id|i idd|i id|i iddfƒtii|iƒtiiƒq–qš|i i |i |i ƒoŠd|_d|_|ii|i |i id|i idd|i id|i iddfƒtii|iƒtiiƒqšn|itjo |idjo|i|itƒn|itjo$tii|iƒtiiƒqqWnt|ƒoÅxþ|D]¶}|itjo |i djo|iitiƒd|_ti i|i ƒ|id}|i id||i id|f|i _|id7_t t!i"ƒi#ƒq!q!Wn=|i|ii$jo&|id7_|ii%|iƒnti i&ƒoa|i'ƒtiidƒ}|o:|ddddjo|i)|dddƒqˆqŒn|idfSdS(Niiiiq(*sselfsstops buttonpressedseventsseventstypesMOUSEBUTTONDOWNslensMiscsactivessbuttonsball1scallbackspossstickspreparesposrealssizesgroupsaddsrefreshs timepressedsKEYDOWNskeysstartslevelsNones MOUSEBUTTONUPsremovesstrengthsdirecsthrowss load_musicsSoundsthrowsplays maxstrengthsgrowsspritess movethingssvs _made_hole(sselfseventsseventsstrengthsv((s./lib/billiard.pysloop†sX  T  T     . %cCstdƒSdS(s6This will become the title of the game used to displaysBilliardN(s_(sself((s./lib/billiard.pys helptitleËscCsdSdS(sxMust return the original, not translated, title of this game. It's needed by the high score class of childsplay.sBilliardN((sself((s./lib/billiard.pys__str__Ïsc Cs_tdƒdtdƒtdƒtdƒtdƒtdƒdtdƒdtd ƒg }|SdS( NsThe aim of the game:s s:You have to make the blue ball enter the hole (in level 1)s#and the red ones in levels 2 and 3.sEUse the right mousebutton to aim and the left button to hit the ball.sDThe longer you hold the left button the harder it will hit the ball.sMThe fewer hits you need to get the ball in the hole, the more points you get.sDifficulty : 4-7 yearssNumber of levels : 3(s_stext(sselfstext((s./lib/billiard.pyshelpÔsW ( s__name__s __module__s__doc__s__init__ssetupsstartstoocloses movethingss _made_holesloops helptitles__str__shelp(((s./lib/billiard.pysGameÒs    R    E  ( sRCFILEsosssyssoperatorsrandomsstringslocalespygamespygame.constantssutilss load_images load_soundsMyErrors get_filess load_musics font2surfsChildsplayGoodiess SpriteUtilssCPSpritesCPGroupsCPinitsmathssqrtsacossImgsMiscsSoundsHolesBallsSticks moving_signsGame(sImgslocalesrandomssqrtsoperators load_musics load_imagesCPGroupsBallsGamesCPSprites font2surfspygames load_soundsSticksSoundsMyErrorsstringssyssRCFILEsCPinits get_filessHolesChildsplayGoodiessMiscs moving_signsacossos((s./lib/billiard.pys?s6 1f*