資源簡介
安裝python,pip安裝pygame,打開Pycharm編輯器直接啟動py文件即可運行,本項目包含使用pyinstaller打包的c++驅(qū)動的exe文件,未安裝環(huán)境也可直接點exe文件開始游戲,exe文件可以在任何windows系統(tǒng)運行
代碼片段和文件信息
#?Star?Pusher?(a?Sokoban?clone)
#?By?Al?Sweigart?al@inventwithpython.com
#?http://inventwithpython.com/pygame
#?Released?under?a?“Simplified?BSD“?license
import?random?sys?copy?os?pygame
from?pygame.locals?import?*
FPS?=?30?#?frames?per?second?to?update?the?screen
WINWIDTH?=?800?#?width?of?the?program‘s?window?in?pixels
WINHEIGHT?=?600?#?height?in?pixels
HALF_WINWIDTH?=?int(WINWIDTH?/?2)
HALF_WINHEIGHT?=?int(WINHEIGHT?/?2)
#?The?total?width?and?height?of?each?tile?in?pixels.
TILEWIDTH?=?50
TILEHEIGHT?=?85
TILEFLOORHEIGHT?=?40
CAM_MOVE_SPEED?=?5?#?how?many?pixels?per?frame?the?camera?moves
#?The?percentage?of?outdoor?tiles?that?have?additional
#?decoration?on?them?such?as?a?tree?or?rock.
OUTSIDE_DECORATION_PCT?=?20
BRIGHTBLUE?=?(??0?170?255)
WHITE??????=?(255?255?255)
BGCOLOR?=?BRIGHTBLUE
TEXTCOLOR?=?WHITE
UP?=?‘up‘
DOWN?=?‘down‘
LEFT?=?‘left‘
RIGHT?=?‘right‘
def?main():
????global?FPSCLOCK?DISPLAYSURF?IMAGESDICT?TILEMAPPING?OUTSIDEDECOMAPPING?BASICFONT?PlayerIMAGES?currentImage
????#?Pygame?initialization?and?basic?set?up?of?the?global?variables.
????pygame.init()
????FPSCLOCK?=?pygame.time.Clock()
????#?Because?the?Surface?object?stored?in?DISPLAYSURF?was?returned
????#?from?the?pygame.display.set_mode()?function?this?is?the
????#?Surface?object?that?is?drawn?to?the?actual?computer?screen
????#?when?pygame.display.update()?is?called.
????DISPLAYSURF?=?pygame.display.set_mode((WINWIDTH?WINHEIGHT))
????pygame.display.set_caption(‘Star?Pusher‘)
????BASICFONT?=?pygame.font.Font(‘freesansbold.ttf‘?18)
????#?A?global?dict?value?that?will?contain?all?the?Pygame
????#?Surface?objects?returned?by?pygame.image.load().
????IMAGESDICT?=?{‘uncovered?goal‘:?pygame.image.load(‘RedSelector.png‘)
??????????????????‘covered?goal‘:?pygame.image.load(‘Selector.png‘)
??????????????????‘star‘:?pygame.image.load(‘Star.png‘)
??????????????????‘corner‘:?pygame.image.load(‘Wall_Block_Tall.png‘)
??????????????????‘wall‘:?pygame.image.load(‘Wood_Block_Tall.png‘)
??????????????????‘inside?floor‘:?pygame.image.load(‘Plain_Block.png‘)
??????????????????‘outside?floor‘:?pygame.image.load(‘Grass_Block.png‘)
??????????????????‘title‘:?pygame.image.load(‘star_title.png‘)
??????????????????‘solved‘:?pygame.image.load(‘star_solved.png‘)
??????????????????‘princess‘:?pygame.image.load(‘princess.png‘)
??????????????????‘boy‘:?pygame.image.load(‘boy.png‘)
??????????????????‘catgirl‘:?pygame.image.load(‘catgirl.png‘)
??????????????????‘horngirl‘:?pygame.image.load(‘horngirl.png‘)
??????????????????‘pinkgirl‘:?pygame.image.load(‘pinkgirl.png‘)
??????????????????‘rock‘:?pygame.image.load(‘Rock.png‘)
??????????????????‘short?tree‘:?pygame.image.load(‘Tree_Short.png‘)
??????????????????‘tall?tree‘:?pygame.image.load(‘Tree_Tall.png‘)
??????????????????‘ugly?tree‘:?pygame.image.load(‘Tree_Ugly.png‘)}
????#?These?dict?values?are?global?and?map?the?character?that?appears
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????6581??2011-06-12?02:33??starpusher\boy.png
?????文件?????733582??2018-08-10?15:42??starpusher\build\starpusher\ba
?????文件??????71246??2018-08-10?15:42??starpusher\build\starpusher\out00-Analysis.toc
?????文件??????17798??2018-08-10?15:42??starpusher\build\starpusher\out00-EXE.toc
?????文件???25427326??2018-08-10?15:42??starpusher\build\starpusher\out00-PKG.pkg
?????文件??????16758??2018-08-10?15:42??starpusher\build\starpusher\out00-PKG.toc
?????文件????3411033??2018-08-10?15:42??starpusher\build\starpusher\out00-PYZ.pyz
?????文件??????55419??2018-08-10?15:42??starpusher\build\starpusher\out00-PYZ.toc
?????文件???????1035??2018-08-10?15:42??starpusher\build\starpusher\starpusher.exe.manifest
?????文件??????12233??2018-08-10?15:42??starpusher\build\starpusher\warnstarpusher.txt
?????文件?????868696??2018-08-10?15:42??starpusher\build\starpusher\xref-starpusher.html
?????文件???????7270??2011-06-12?02:32??starpusher\catgirl.png
?????文件???????6581??2011-06-12?02:33??starpusher\dist\boy.png
?????文件???????7270??2011-06-12?02:32??starpusher\dist\catgirl.png
?????文件?????416116??2014-10-10?20:46??starpusher\dist\FreeSansBold.ttf
?????文件???????8244??2011-06-11?14:59??starpusher\dist\Grass_Block.png
?????文件???????7186??2011-06-12?02:32??starpusher\dist\horngirl.png
?????文件???????6924??2011-06-12?02:32??starpusher\dist\pinkgirl.png
?????文件???????3433??2011-06-11?22:23??starpusher\dist\Plain_Block.png
?????文件???????7411??2011-06-11?23:06??starpusher\dist\princess.png
?????文件??????10418??2011-06-11?22:55??starpusher\dist\RedSelector.png
?????文件???????7902??2011-06-12?01:00??starpusher\dist\Rock.png
?????文件??????10243??2011-06-11?22:55??starpusher\dist\Selector.png
?????文件???????9824??2011-06-11?22:55??starpusher\dist\Star.png
?????文件???25699198??2018-08-10?15:42??starpusher\dist\starpusher.exe
?????文件??????24894??2012-02-02?23:46??starpusher\dist\starpusher.py
?????文件??????59164??2012-01-10?17:53??starpusher\dist\starPusherLevels.txt
?????文件??????67300??2011-06-11?23:08??starpusher\dist\star_solved.png
?????文件??????93531??2011-06-11?23:08??starpusher\dist\star_ti
?????文件???????9771??2011-06-12?01:00??starpusher\dist\Tree_Short.png
............此處省略33個文件信息
評論
共有 條評論