资源简介
一个小孩子在上方左右移动,不断地往下面扔香蕉皮和糖果,下面有一个小孩子由玩家操作来接糖果

代码片段和文件信息
“““This program is made up of four characters: Me Partner Candy and Rubbish.
Partner moves to left or right on the top of the screen dropping candies and rubbshes.
Me can move to up down right and left controlled by the mouse.
If Me get a candy score increases.
If Me get a rubbish score decreases and lives decrease.
The game will end when live is zero.
Attention: ‘lives‘ here is equal to ‘chances‘ ‘score‘ is equal to ‘candies‘
Xuelai Zhang
2012/7/3“““
#initialize and import
import pygamecharacters random
pygame.init()
#display
screen = pygame.display.set_mode((640480))
pygame.display.set_caption(“Catch the candies“)
#functions
#game
def game():
#entites
#bachground
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill((000))
screen.blit(background(00))
#partner
partner = characters.Partner()
“““
#candies
candy1 = characters.Candy(partner.rect.centerx)
candy2 = characters.Candy(partner.rect.centerx)
candy3 = characters.Candy(partner.rect.centerx)
#rubbishes
rubbish1 = characters.Rubbish(partner.rect.centerx)
rubbish2 = characters.Rubbish(partner.rect.centerx)
rubbish3 = characters.Rubbish(partner.rect.centerx)
“““
#candies
candies = []
#rubbishes
rubbishes = []
#me
me = characters.Me()
#score
scoreboard = characters.Scoreboard()
#define groups
#friendSprites including Me Partner
friendSprites = pygame.sprite.Group(me partner)
#candySprites including Candy
candySprites = pygame.sprite.Group()
#rubbishSprites including Rubbish
rubbishSprites = pygame.sprite.Group()
#scoreSprites including scoreboard
scoreSprites = pygame.sprite.Group(scoreboard)
#time
clock = pygame.time.Clock()
#assign
keepgoing = True
#set a counter to drop something every 0.1 second
counter = 0
#Act
while keepgoing:
#set tick
clock.tick(30)
pygame.mouse.set_visible(False)
#set a flag whether to drop something
drop = random.randint(01)
#set up a flag whether to drop candy or rubbish
drpCandy = random.randint(0 1)
#decide whether to drop candy rubbish or nothing
if counter == 6:
counter =0
if drop == 1:
#add a new rubbish in rubbishSprites
if drpCandy == 0:
rubbish = characters.Rubbish(partner.rect.centerx)
rubbishSprites.add(rubbish)
#add a new candy in candySprites
else:
candy = characters.Candy(partner.rect.centerx)
candySprites.add(candy)
counter += 1
#check if it ends by user
for event in pygame.event.get():
if event.type == pygame.QUIT:
keepgoing = False
#check collision
#collision
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-07-04 00:09 catchCandy\
文件 10144 2012-07-04 00:03 catchCandy\ao.ogg
文件 3782 2012-07-03 23:46 catchCandy\candy.png
文件 7834 2012-07-04 03:11 catchCandy\catchCandy.py
文件 7807 2012-07-04 03:09 catchCandy\catchCandy.py.bak
文件 5447 2012-07-04 03:11 catchCandy\characters.py
文件 5531 2012-07-04 02:56 catchCandy\characters.py.bak
文件 6391 2012-07-04 03:12 catchCandy\characters.pyc
文件 10897 2012-07-03 23:55 catchCandy\me.png
文件 12156 2012-07-04 00:05 catchCandy\ohno.ogg
文件 11325 2012-07-03 23:58 catchCandy\partner.png
文件 3126 2012-07-03 23:48 catchCandy\rubbish.png
文件 9304 2012-07-04 00:02 catchCandy\yohoo.ogg
- 上一篇:网页设计毕业设计范例
- 下一篇:病毒样本!!!!!!!
相关资源
- Pythonamp;课堂amp;笔记(高淇amp;400;集第
- Python中Numpy库最新教程
- 用python编写的移动彩信的发送程序
- Python全栈学习笔记面向对象大作业:
- python实现的ftp自动上传、下载脚本
- Python版的A*寻路算法
- IronPython IDE
- pip-10.0.1.tar.gz
- Data Science from Scratch 2nd Edition
- shape_predictor_68_face_landmarks.dat.bz2 68个标
- 爬取豆瓣电影TOP250程序,包含非常详
- 中文维基百科语料库百度网盘网址.
- MSCNN_dehaze.rar
- 爬取豆瓣排行榜电影数据(含GUI界面
- 字典文本资源
- Brainfuck / OoK 解码脚本
- 案例实战信用卡欺诈检测数据集
- 招商策略_抱团启示录那些年我们一起
- sip-4.19.zip
- 树莓派3b+学习使用教程
- numpy 中文学习手册
- pytorch-1.4.0-py3.7_cpu_0.tar.bz2
- 机器学习实战 高清完整版PDF
- 泰坦尼克号0.81准确率实验报告.docx
-
abaqus sc
ripting reference manual.pdf - 网页版聊天程序--网络程序设计课程大
- Give Me Some Credit
-
ba
semap安装出错时,正确得pyproj文件 - 微信头像拼接工具
- 统计思维:程序员数学之概率统计第
评论
共有 条评论