资源简介
基于python的小游戏,休闲娱乐,双人同时玩耍。。。。。
代码片段和文件信息
import random
import pygame
pygame.init()
def moveAnimation(image1 image2 count):
if 10 < count % 20 <= 20:
return image2
else:
return image1
def upClear(x y):
canMove = True
if verticalDoorLeft <= x <= verticalDoorRight and y - 1 < topWall:
canMove = True
elif y - 1 < topWall:
canMove = False
elif (x < leftWall or x > rightWall) and y - 1 < middleDoorsTop:
canMove = False
if canMove:
return 1
else:
return 0
def downClear(x y):
canMove = True
if verticalDoorLeft <= x <= verticalDoorRight and bottomWall < y + 1:
canMove = True
elif bottomWall < y + 1:
canMove = False
elif (x < leftWall or 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 < leftWall:
canMove = True
elif x - 1 < leftWall:
canMove = False
elif (y > bottomWall or y < topWall) and x - 1 < verticalDoorLeft:
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 < topWall) and x + 1 > 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 < pOneX - pTwoX < 32 and -40 < pOneY - pTwoY < 40:
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 < x - coinPos[0] < 20 and -40 < y - coinPos[1] < 20
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
相关资源
- Python3入门必备chm帮助手册和思维导图
- Python编程:从入门到实践超高清中文
- python3标准库试看版.pdf
- python基础教程英文第三版-高清可复制
- Python编程:从入门到实践.7z
- python.rar
- 12364241Python编程:从入门到实践.rar
- tensorflow操作mnist数据集源代码
- 基于Python开发的学生信息管理系统源
- python深度学习(Chollet中文版)
- Python数据处理中文版带书签高清文字
- 零起点Python大数据与量化交易.pdf.zi
- numpy-1.18.1-cp37-cp37m-win_amd64.whl
- 流利的Python英语原版高清带书签.pdf
- 《python进阶》,《Intermediate Python》的
- 全本正式版 learn python 3 the hard way
- Python-Opencv自定义训练器识别任意物体
- Python机器学习经典 源代码
- Python-TensorFlow快速入门与实战课件与参
- Anaconda3 5.2.0
- numpy-1.18.4+mkl-cp38-cp38-win_amd64.whl
- Python数据分析与挖掘实战_数据及程序
- python3.6.5.zip
- numpy-1.18.4+mkl-cp38-cp38-win_amd64.zip
- python面向对象编程指南高清最新版
- 基于phash图像特征的图像聚类-kmeans-
- 跟老齐学Python Django实战_带书签_高清
- youdaoHelper成品.rar
- python快排全套带环境前后端.rar
- Maya Python游戏与影视编程指南
评论
共有 条评论