资源简介
本项目共分为三个主界面,开始主界面实现全屏控制、满天星动态背景、背景动态开关控制等,运行主界面实现挡板控制,小球碰撞控制,分数控制系统等,结束界面实现分数信息显示等,以供交流借鉴之用。
代码片段和文件信息
import pygame
import random
import sys
import time
from pygame.locals import *
speed = 5
ballmax= 1
windows_height = 850
windows_width = 1390
Fullscreen = 0
bgcolor = (2 36 61)
switch = 1
onoff = 0
fen = 0
live = 5
level = 1
Bolck_row = 5
Block_column = 7
Bolck_height = 150
Bolck_width = 20
paddle = {
“rect“ : pygame.Rect(windows_width / 2 - 75 windows_height - 20 150 20)
“color“ : (24024080)
“moveonoff“ : 0
“paddlespeed“ : 8
}
class Ball(object):
lanball = [“Image/color9/120.png“ “Image/color9/220.png“ “Image/color9/320.png“ “Image/color9/420.png“
“Image/color9/520.png“ “Image/color9/620.png“ “Image/color9/720.png“ “Image/color9/820.png“
“Image/color9/920.png“]
depot = [1 -1]
speedonoff = 0
ball_x = paddle[“rect“].left + 65
ball_y = windows_height - 40
ball_color = random.randint(08)
ball_dir_x = depot[random.randint(0 1)]
ball_dir_y = 1
ball_speed = speed * speedonoff
imgball = pygame.image.load(lanball[ball_color])
def main():
pygame.init()
screnn = pygame.display.set_mode((windows_widthwindows_height)Fullscreen32)
screnn.fill(bgcolor)
pygame.display.set_caption(“急速碰撞“)
begin_info(screnn)
while True:
running(screnn)
begin_info(screnn)
def running(screen):
global ballmax
balllist = []
for i in range(100):
ball = Ball()
balllist.append(ball)
balllist[i].ball_color = random.randint(0 8)
balllist[i].ball_dir_x = balllist[i].depot[random.randint(0 1)]
balllist[i].imgball = pygame.image.load(balllist[i].lanball[balllist[i].ball_color])
while True:
pygame.display.update()
drawball(screenballlist)
score(screen)
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
elif event.type == KEYUP:
if (event.key == K_SPACE):
for j in range(ballmax):
# balllist[j].ball_x = paddle[“rect“].left + 65
balllist[j].speedonoff = 1
balllist[j].ball_speed = speed * balllist[ballmax-1].speedonoff
elif (event.key == K_a or event.key == K_d):
paddle[“moveonoff“] = 0
elif event.type == KEYDOWN:
if (event.key == K_ESCAPE):
return
elif (event.key == K_a):
paddle[“moveonoff“] = -1
elif (event.key == K_d):
paddle[“moveonoff“] = 1
# elif (event.key == K_UP):
# ballmax = ballmax + 1
# balllist[ballmax].ball_x = paddle[“rect“].left + 65
# elif (event.key == K_DOWN):
# ballmax = ballmax - 1
# balllist[ballmax].ball_x = paddle[“rect“].left + 65
# elif (event.key == K_RIGHT):
# Ball.ball_speed = Ball.ball_speed + 1
# elif (event.key == K_LEFT):
# Ball.ball_speed = Ball.ball_speed - 1
elif (event.key == K_f):
change_2(screen)
if (paddle[“moveonoff“] != 0 and balllist[0].ball_speed != 0):
paddle[‘rect‘].left = paddle[“rect“].left + ( paddle[“paddlespeed“] * paddle[“moveonoff“] )
if paddle[‘rect‘].left < 0:
paddl
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-11-03 11:47 Tanteball2\
文件 2729 2018-10-28 15:52 Tanteball2\130.png
文件 2870 2018-10-28 15:53 Tanteball2\230.png
文件 2748 2018-10-28 15:54 Tanteball2\330.png
文件 2731 2018-10-28 15:55 Tanteball2\430.png
文件 2884 2018-10-28 15:55 Tanteball2\530.png
文件 2662 2018-10-28 15:56 Tanteball2\630.png
文件 2803 2018-10-28 15:56 Tanteball2\730.png
文件 2874 2018-10-28 15:57 Tanteball2\830.png
文件 2805 2018-10-28 15:59 Tanteball2\930.png
目录 0 2018-11-03 11:47 Tanteball2\Image\
文件 29864 2018-10-28 14:14 Tanteball2\Image\026b7b54f59db88a38c07876ae92bef6.png
文件 23043 2018-10-28 14:15 Tanteball2\Image\041235a254f43febc51d3cc4acead048.jpg
文件 36982 2018-10-28 14:14 Tanteball2\Image\12ebf340f518bb07e63eb28fd8f41414.jpg
文件 53221 2018-10-28 14:16 Tanteball2\Image\21ab51888a5bdc50061d00590549f205.jpg
文件 14163 2018-10-28 14:15 Tanteball2\Image\22c68018478bb6518b37ad33c85399ca.jpg
文件 55654 2018-10-28 14:16 Tanteball2\Image\3783a410a3c65c12de2165c3b9fd2008.jpg
文件 19883 2018-10-28 14:16 Tanteball2\Image\52621055a514b282c339e14b36a86af8.jpg
文件 38088 2018-10-28 14:15 Tanteball2\Image\54ee8b0b82c1bd6e3788bd6c22162bd3.jpg
文件 26382 2018-10-28 14:13 Tanteball2\Image\6e2f525e8164c648caf32167dcdfe5f9.jpg
文件 17965 2018-10-28 14:14 Tanteball2\Image\84697b891016f18748565bf8fdd159d0.jpg
文件 22747 2018-10-28 14:15 Tanteball2\Image\9d7f3917eb735d7ae0544e81a99e173c.jpg
文件 28999 2018-10-28 14:15 Tanteball2\Image\9efb49c642240e7466e47dc369d58d5f.jpg
文件 20394 2018-10-28 14:15 Tanteball2\Image\a92091acb1145523eb4ad48204b4c0a6.jpg
文件 28661 2018-10-28 14:17 Tanteball2\Image\acf5f67ad9d44d48c20e2b95befe3d68.jpg
目录 0 2018-11-03 11:47 Tanteball2\Image\changball\
文件 63480 2018-10-28 15:43 Tanteball2\Image\changball\5paiball.png
文件 472 2018-10-28 15:44 Tanteball2\Image\changball\5paiball10.png
文件 1210 2018-10-28 15:44 Tanteball2\Image\changball\5paiball20.png
文件 2036 2018-10-28 15:44 Tanteball2\Image\changball\5paiball30.png
文件 3087 2018-10-28 15:44 Tanteball2\Image\changball\5paiball40.png
............此处省略47个文件信息
相关资源
- Python通讯录程序代码
- Python编程从入门到实践(图灵程序设
- python-pygame-消消乐
- An Introduction to Statistics with Python.pdf
- 李飞飞深度学习全部作业python源代码
- Python编程:从入门到实践(高清完整
- Python飞机大战代码括音效,图片,字
- python3+实现视频转图片和图片转视频
- Python语言程序设计基础(第2版)-嵩天
- “笨办法”学python(第3版).pdf
- Python飞机大战 图片+音乐
- 廖雪峰python3 高清完整
- 基于Python的图像分类
- Djangopython实现数据挖掘和分析.doc
- 使用python实现人工智能算法
- GBDT单机版Python实现源代码
- Python实现跟踪、光流、前景检测
- 多元线性回归python实现
- seleniumwebdriverpython第三版.pdf
- IEDriverServer_64位操作系统,支持selen
- 编写高质量代码:改善Python程序的91个
- 基于python的新冠疫情数据分析.zip
- python 机器学习 scikit-learn 手册 高清完
- 深度学习入门:基于 Python 的理论与实
- python数学实验与建模程序及数据.zip
- python 金融大数据分析代码与数据
- Python编程入门经典源代码
- python自动登陆该网站并网站内容
- 泰坦尼克号0.81准确率python源代码.py
- python随机子空间法.py
评论
共有 条评论