得分:95
import mcpi.minecraft as minecraft
import mcpi.minecraftstuff as minecraftstuff
import mcpi.block as block
import time
import random
try_time = 20
point = 10
mc = minecraft.Minecraft.create()
pos = mc.player.getTilePos()
start_pos = pos
y_pos = pos.y
mc.setBlocks(pos.x-5,pos.y-1,pos.z-1,pos.x+5,pos.y+5,pos.z+31,block.GLASS.id)
count = 10
for i in range(10):
mc.setBlocks(pos.x-4,pos.y,pos.z,pos.x+4,pos.y+5,pos.z+30,block.AIR.id)
time.sleep(0.5)
count -= 1
mc.postToChat(count)
mc.player.setTilePos(start_pos)
mc.setBlocks(pos.x-5,pos.y-10,pos.z-1,pos.x+5,pos.y-1,pos.z+31,block.GRASS.id)
mc.setBlocks(pos.x-5,pos.y-1,pos.z+7,pos.x+5,pos.y-1,pos.z+7,block.STONE.id)
mc.setBlocks(pos.x-5,pos.y-1,pos.z+30,pos.x+5,pos.y-1,pos.z+30,block.DIAMOND_BLOCK.id)
while True:
try_time -= 0.1
pos = mc.player.getTilePos()
mc.postToChat(try_time)
if y_pos > pos.y:
mc.player.setTilePos(start_pos)
point -= random.randint(3,5)
try_time += 3
if mc.getBlock(pos.x,pos.y-1,pos.z) == block.STONE.id:
mc.setBlocks(pos.x-20,pos.y-2,pos.z+3,pos.x+20,pos.y-1,pos.z+6,block.AIR.id)
mc.setBlock(pos.x+random.randint(-3,3),pos.y-1,pos.z+5,block.COBBLESTONE.id)
mc.setBlocks(pos.x-20,pos.y-1,pos.z,pos.x+20,pos.y-1,pos.z,block.GRASS.id)
while not mc.getBlock(pos.x,pos.y-1,pos.z) == 57:
pos = mc.player.getTilePos()
mc.postToChat(try_time)
try_time -= 0.1
if y_pos > pos.y:
mc.player.setTilePos(start_pos)
point -= random.randint(3,5)
try_time += 3
point += try_time
mc.postToChat("Clearance!")
mc.postToChat("your score:%s"% int(round(point)))
point = int(round(point))
if point >= 22:
mc.postToChat("Very Good~")
mc.postToChat("Crafty Corssing")
break
此段程序在mc中建造了空間,倒計(jì)時(shí)10秒結(jié)束后缅刽,玩家往前移動(dòng)到達(dá)終點(diǎn),在這個(gè)過程中蠢络,玩家必須要經(jīng)過一排石頭路面衰猛,此時(shí)石頭路面會(huì)小時(shí),同時(shí)在前方生成一個(gè)鴻溝和一個(gè)石塊刹孔,玩家必須利用石塊加速跳躍過鴻溝到達(dá)終點(diǎn)才為勝利啡省。
系統(tǒng)最終會(huì)給出得分和評(píng)級(jí)。
此段程序yijing非常完備,可以看出已經(jīng)具有了一個(gè)程序員應(yīng)該有的基本思維卦睹。