Shuttle Space(穿越太空)
标签:microbit
冰儿burning 发布于 2017-11-24 15:59
2333年,地球能源枯竭,人类为寻找新能,开启了大航天时代。
宇航员zka,在利益的驱使下独身前往m78星云探索永恒的能源。但由于技术(智商)的限制,zka误入可陨石海......
游戏流程: 1.屏幕出现shuttle space的滚动字幕(可按a或b跳过)
2.屏幕出现飞船向前飞行画面(可按a或b跳过)
3.屏幕出现模拟飞船躲避陨石(10次后自动跳入下一阶段,可按a或b跳过)
4.屏幕底部中央飞船,每隔5个时间间隔会随机出现1-3个陨石从顶部向下运动
5.为了躲避陨石,操作者可用a建控制飞船左移动,用b控制飞船向右移动
6.若飞船被陨石击中,则屏幕中出现“died”滚动字幕(可跳过)
7.屏幕出现飞船图标,若操作者按a会进入4. 若操作者按b进入8.
8.屏幕出现level滚动字幕(可跳过),屏幕中出现level的值。按a 可增加level大小,最大为3,若超过3则level回到1,按b则设定完成进入4.
登录以发表评论
想购买micro:bit的相关产品,可以搜索淘宝店“恩孚电子“,优惠多多哦!
本游戏编写作者:黄智梵(温州中学高三6班)
因为文件太大了,只能用mu下载,如果用BXY,得注释音乐。
from microbit import *
import random
#import music
def switch(List,num):
from random import randint
switchList=[]
alist = []
for i in List:
alist.append(i)
for i in range(num):
x = randint(0,len(alist)-1)
switchList.append(alist[x])
alist.pop(x)
return switchList
def waitAB(waitTime):
lastTime =running_time()
while True:
time =running_time()
if button_a.is_pressed() or button_b.is_pressed() :
break
if time - lastTime>=waitTime:
break
rocksTime=200
allTimes = 10
waitTime = 120
level = 1
lastTime = 0
times = 0
display.scroll('Shuttle Space',wait= False)
#music.play(music.NYAN,wait=False,loop=True)
waitAB(12000)
black = Image("00000:00000:00000:00000:00000")
CGList = [Image("00900:09990:09990:99999:09990"),black,Image("09990:09990:99999:09990:00500"),black,Image("09990:99999:09990:00500:00300"),black,Image("99999:09990:00500:00300:00100"),black,Image("09990:00500:00300:00100:00000"),black]
CGTime = [500,200,500,200,500,200,500,200,500,1000]
for i in range(10):
display.show(CGList[i])
sleep(CGTime[i])
if button_a.is_pressed() or button_b.is_pressed() :
break
y1 = -2
x1 = 0
xS = 2
time = 0
lastTime = 0
times = 0
display.set_pixel(xS-1,4,9)
display.set_pixel(xS,4,9)
display.set_pixel(xS+1,4,9)
display.set_pixel(xS,3,9)
while True:
if button_a.is_pressed() or button_b.is_pressed():
break
y1 = y1 + 1
try:
display.set_pixel(x1,y1,9)
display.set_pixel(x1+1,y1,9)
except:
None
try:
display.set_pixel(x1,y1+1,9)
display.set_pixel(x1+1,y1+1,9)
except:
None
try:
display.set_pixel(x1,y1-1,0)
display.set_pixel(x1+1,y1-1,0)
except:
None
if display.get_pixel(0,2)==9 or display.get_pixel(0,3)==9 :
if xS == 3:
pass
else:
xS=xS+1
display.set_pixel(xS-1,4,9)
display.set_pixel(xS,4,9)
display.set_pixel(xS+1,4,9)
display.set_pixel(xS,3,9)
try:
display.set_pixel(xS-1,3,0)
display.set_pixel(xS-2,4,0)
except:
None
elif display.get_pixel(4,2)==9 or display.get_pixel(4,3)==9 :
if xS == 1:
pass
else:
xS=xS-1
display.set_pixel(xS-1,4,9)
display.set_pixel(xS,4,9)
display.set_pixel(xS+1,4,9)
display.set_pixel(xS,3,9)
display.set_pixel(xS+1,3,0)
display.set_pixel(xS+2,4,0)
else:
pass
sleep(waitTime)
if y1 == 4:
display.set_pixel(x1,y1,0)
display.set_pixel(x1+1,y1,0)
x1 = 3*random.randint(0,1)
y1 = -2
times = times + 1
if times == allTimes:
break
display.show(black)
time = running_time()
lastTime = time
state = 0
lastPressed = 0
pressedTime = 0
sleep(500)
display.show(Image("00900:09990:09990:99999:09990"))
rocksList=[0,1,2,3,4]
while True:
#game begin
while state == 1 :
#rocks move
time = running_time()
if time - lastTime >=rocksTime:
if y == 4:
y = 0
for z in rocksY:
display.set_pixel(z,4,0)
rocksY = switch(rocksList,random.randint(1,3))
for z in rocksY:
display.set_pixel(z,y,5)
else:
y = y + 1
for z in rocksY:
display.set_pixel(z,y-1,0)
display.set_pixel(z,y,5)
lastTime = time
#ship move
if button_b.is_pressed():
if lastPressed =="b":
pass
else:
pressedTime = running_time()
lastPressed ="b"
if x == 4 :
pass
else:
x = x +1
display.set_pixel(x,4,9)
display.set_pixel(x-1,4,0)
if button_a.is_pressed():
if lastPressed ==1:
pass
else:
pressedTime = running_time()
lastPressed =1
if x == 0 :
pass
else:
x = x -1
display.set_pixel(x,4,9)
display.set_pixel(x+1,4,0)
if time -pressedTime >=200:
lastPressed = 0
# dead
if display.get_pixel(x,4) != 9:
display.scroll('DIED',wait=False)
waitAB(3600)
display.show(Image("00900:09990:09990:99999:09990"))
sleep(500)
state = 0
#setting
while state == 2:
display.show(str(level))
if button_a.is_pressed():
sleep(200)
level = level +1
if level == 4:
level = 1
if button_b.is_pressed():
sleep(200)
rocksTime = 250 -50*level
state = 1
display.show(black)
x = 2
y = 0
rocksY = switch(rocksList,random.randint(1,3))
display.set_pixel(x,4,9)
sleep(500)
# about state
if button_a.is_pressed():
#music.play(music.NYAN,wait=False,loop=True)
state = 1
display.show(black)
x = 2
y = 0
rocksY = switch(rocksList,random.randint(1,3))
display.set_pixel(x,4,9)
sleep(200)
if button_b.is_pressed():
display.scroll("level",wait= False)
waitAB(4200)
state = 2
sleep(300)
阅读数: 8062