游戏下载网址:
链接:https://pan.baidu.com/s/1F359-kUuGHYznrjXPfZoxw
提取码:fne9
""" 新型冠状病毒泡泡堂游戏.py 本程序借用了pygame的混音器模块,所以需要安装pygame模块。 需要精灵模块1.33版支持请卸载老版本,重新安装最新版本的精灵模块。 程序中迷宫房间是画出来的,当然虫子是不能穿越过去,也不能碰到病毒... 按上下左右键操作虫子移动,按空格键放炸弹。 """ from sprites import * from pygame import mixer def draw_frame(obj,margin): """用obj角色画边框,margin为边距 本函数用for循环直接画一个正方形也可以。 """ sw = obj.screen.window_width() sh = obj.screen.window_height() bug.topleft() # 移到左上角 bug.addy(-margin) x,y = bug.position() cors = [(x+sw,y),(x+sw,y+margin),(x,y+margin)] f1 = bug.polygon(cors) bug.bottomleft() # 移到左下角 x,y = bug.position() cors = [(x+sw,y),(x+sw,y+margin),(x,y+margin)] f2 = bug.polygon(cors) bug.addy(margin) x,y = bug.position() cors = [(x+margin,y),(x+margin,y+(sh-2*margin)),(x,y+(sh-2*margin))] f3 = bug.polygon(cors) bug.addx(sw-margin) x,y = bug.position() cors = [(x+margin,y),(x+margin,y+(sh-2*margin)),(x,y+(sh-2*margin))] f4 = bug.polygon(cors) return [f1,f2,f3,f4] def draw_cross(obj,length): """画十字架""" d = length/2 bug.goto(-d,d) x,y = bug.position() cors = [(x+length,y),(x+length,y+2*length),(x,y+2*length)] p1 = bug.polygon(cors) bug.goto(-d-2*length,-d) x,y = bug.position() cors = [(x+5*length,y),(x+5*length,y+length),(x,y+length)] p2 = bug.polygon(cors) bug.goto(-d,-d-2*length) x,y = bug.position() cors = [(x+length,y),(x+length,y+2*length),(x,y+2*length)] p3 = bug.polygon(cors) return [p1,p2,p3] def draw_squares(obj,length): """画4个正方形""" items = [] for _ in range(4): i = bug.polygon(4,length) items.append(i) bug.fd(length*5) bug.rt(90) return items width = 800 height = 600 screen = Screen() screen.bgcolor('black') screen.setup(width,height) screen.title('新型冠状病毒泡泡堂游戏') screen.bgpic('封面.png') leftkey = Key('Left') rightkey = Key('Right') upkey = Key('Up') downkey = Key('Down') spacekey = Key('space') screen.listen() PlaySound('audios/泡堂开场音乐.wav',SND_ASYNC) starttime = time.time() while time.time() - starttime < 6 : screen.update() if spacekey.down():break screen.bgpic('nopic') PlaySound(None,SND_PURGE) PlaySound('audios/泡泡堂小区音乐.wav',SND_ASYNC|SND_LOOP) mixer.init() # 初始化混音器 bombsound = mixer.Sound('audios/BOMB1.wav') placesound = mixer.Sound('audios/zoop.wav') bomb = Sprite('bombs',visible=False) bomb.scale(0.5) 以下代码省略......
下载完整源代码与素材,请
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)