mc = Minecraft.create()

try:
    playerPos = mc.player.getTilePos()
    craftPos = playerPos.clone()
    craftPos.y += 10
    craftPos.z += 20
    craft = XWingFighter(craftPos)
    bomb = Bomb()
    
    while True:
        x, y, z, a, b = read_microbit_data()
        if a:
            if craft.flying:
                craft.stop()
            else:
                craft.fly(0.15)
        if b:
            bpos = craft.craftShape.position
            bpos.y - 2
            bomb.drop(bpos.x, bpos.y, bpos.z, 0.1)
        if x > 750:
            craft.turn(10)
        if x > 500:
            craft.turn(5)
        if x < -750:
            craft.turn(-10)
        if x < -500:
            craft.turn(-5)
        if x > -500 and x < 500:
Exemple #2
0
mc = Minecraft.create()

try:
    playerPos = mc.player.getTilePos()
    craftPos = playerPos.clone()
    craftPos.y += 10
    craftPos.z += 20
    craft = XWingFighter(craftPos)
    bomb = Bomb()

    while True:
        x, y, z, a, b = read_microbit_data()
        if a:
            if craft.flying:
                craft.stop()
            else:
                craft.fly(0.15)
        if b:
            bpos = craft.craftShape.position
            bpos.y - 2
            bomb.drop(bpos.x, bpos.y, bpos.z, 0.1)
        if x > 750:
            craft.turn(10)
        if x > 500:
            craft.turn(5)
        if x < -750:
            craft.turn(-10)
        if x < -500:
            craft.turn(-5)
        if x > -500 and x < 500: