資源簡介
基于python的小游戲,休閑娛樂,雙人同時玩耍。。。。。
代碼片段和文件信息
import?random
import?pygame
pygame.init()
def?moveAnimation(image1?image2?count):
????if?10?????????return?image2
????else:
????????return?image1
def?upClear(x?y):
????canMove?=?True
????if?verticalDoorLeft?<=?x?<=?verticalDoorRight?and?y?-?1?????????canMove?=?True
????elif?y?-?1?????????canMove?=?False
????elif?(x??rightWall)?and?y?-?1?????????canMove?=?False
????if?canMove:
????????return?1
????else:
????????return?0
def?downClear(x?y):
????canMove?=?True
????if?verticalDoorLeft?<=?x?<=?verticalDoorRight?and?bottomWall?????????canMove?=?True
????elif?bottomWall?????????canMove?=?False
????elif?(x??rightWall)?and?y?+?1?>?middleDoorsBottom:
????????canMove?=?False
????if?canMove:
????????return?1
????else:
????????return?0
def?leftClear(x?y):
????canMove?=?True
????if?middleDoorsTop?<=?y?<=?middleDoorsBottom?and?x?-?1?????????canMove?=?True
????elif?x?-?1?????????canMove?=?False
????elif?(y?>?bottomWall?or?y?????????canMove?=?False
????if?canMove:
????????return?1
????else:
????????return?0
def?rightClear(x?y):
????canMove?=?True
????if?middleDoorsTop?<=?y?<=?middleDoorsBottom?and?x?+?1?>?rightWall:
????????canMove?=?True
????elif?x?+?1?>?rightWall:
????????canMove?=?False
????elif?(y?>?bottomWall?or?y??verticalDoorRight:
????????canMove?=?False
????if?canMove:
????????return?1
????else:
????????return?0
def?checkOffscreen(x?y):
????if?x?-14:
????????x?=?windowSize[0]?-?14
????elif?x?>?windowSize[0]?-?14:
????????x?=?-14
????if?y?-20:
????????y?=?windowSize[1]?-?20
????elif?y?>?windowSize[1]?-?20:
????????y?=?-20
????return?x?y
def?playersTouching():
????global?pOneX?pOneY?pTwoX?pTwoY
????if?-32?????????xDiff?=?pOneX?-?pTwoX
????????yDiff?=?pOneY?-?pTwoY
????????for?dist?in?range(abs(xDiff)?/?2):
????????????pOneMove?=?leftClear(pOneX?pOneY)?+?rightClear(pOneX?pOneY)
????????????pTwoMove?=?leftClear(pTwoX?pTwoY)?+?rightClear(pTwoX?pTwoY)
????????????if?xDiff?>?0:
????????????????pOneX?+=?pOneMove?/?2?*?xDiff?/?xDiff
????????????????pTwoX?-=?pTwoMove?/?2?*?xDiff?/?xDiff
????????????else:
????????????????pOneX?-=?pOneMove?/?2?*?xDiff?/?xDiff
????????????????pTwoX?+=?pTwoMove?/?2?*?xDiff?/?xDiff
????????for?dist?in?range(abs(yDiff)?/?2):
????????????pOneMove?=?upClear(pOneX?pOneY)?+?downClear(pOneX?pOneY)
????????????pTwoMove?=?upClear(pTwoX?pTwoY)?+?downClear(pTwoX?pTwoY)
????????????if?yDiff?>?0:
????????????????pOneY?+=?pOneMove?/?2?*?yDiff?/?yDiff
????????????????pTwoY?-=?pTwoMove?/?2?*?yDiff?/?yDiff
????????????else:
????????????????pOneY?-=?pOneMove?/?2?*?yDiff?/?yDiff
????????????????pTwoY?+=?pTwoMove?/?2?*?yDiff?/?yDiff
def?touchingCoin(x?y):
????return?-32?
def?randomPosition():
????#?return?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????34164??2014-10-14?22:10??adventure10\background.png
?????文件????????454??2014-10-11?00:03??adventure10\coin.png
?????文件??????50766??2015-01-21?05:34??adventure10\coin.wav
?????文件???11253421??2018-03-17?16:38??adventure10\coinGameStart.exe
?????文件???????7253??2014-10-16?22:00??adventure10\coinGameStart.py
?????文件????????169??2015-01-21?05:32??adventure10\copyright.txt
?????文件???????6892??2018-03-17?16:31??adventure10\game.py
?????文件???????5107??2014-10-14?22:11??adventure10\light.png
?????文件????1392256??2015-01-21?01:16??adventure10\music.mp3
?????文件????????329??2014-10-14?21:41??adventure10\sprite1_standing.png
?????文件????????347??2014-10-14?21:28??adventure10\sprite1_walking1.png
?????文件????????345??2014-10-14?21:28??adventure10\sprite1_walking2.png
?????文件????????428??2014-10-14?21:49??adventure10\sprite2_standing.png
?????文件????????441??2014-10-14?21:50??adventure10\sprite2_walking1.png
?????文件????????440??2014-10-14?21:51??adventure10\sprite2_walking2.png
?????目錄??????????0??2018-03-17?16:40??adventure10
-----------?---------??----------?-----??----
?????????????12752812????????????????????16
評論
共有 條評論