资源简介
一个小孩子在上方左右移动,不断地往下面扔香蕉皮和糖果,下面有一个小孩子由玩家操作来接糖果
代码片段和文件信息
“““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
- 上一篇:网页设计毕业设计范例
- 下一篇:病毒样本!!!!!!!
相关资源
-
WumpusWorld 使用 Knowledgeba
se的AI 实现 - glut搭建glut32bit和64bit
- Pygame游戏源代码:坦克大战
- 打字案例.zip
- tensorflow实现猫狗识别
- 万有引力算法GSA-master.zip
- 点云数据ply格式
- PyQt5快速开发与实践
- Arcgis批量裁剪
- Regression回归算法代码
- PyQt5系列教程(二)利用QtDesigner设计
- 简单贝叶斯实现垃圾邮件分类
- Opencv+Tensorflow入门人工智能处理无密完
- 运用ID3算法训练决策树
- BPNet多层网络学习算法可以实现有效的
- 文书网最新版getKey.js(获取vl5x值)
- djangol实现学生管理网站
- 基于西瓜书的聚类代码和介绍
- Sublime3护眼主题
- tensorflow-2.1.0-cp37-cp37m-win_amd64.whl
- 12306爬虫源码
-
failed to execute sc
ript 解决方案+命令行 - 一次性口令身份认证
- XGboost训练印第安人糖尿病数据
- 查找两幅图中不同
- 基于openGL、pygame增强现实的视频实现
- PyQt5:简单视频播放器
- Machine learning DecisionTree
- Face-tracking.zip
- [MIT][计算机科学及编程导论][6.00][课程
评论
共有 条评论