Exemplo n.º 1
0
    def __init__(self, mc, pos):

        self.mc = mc
        self.pos = pos

        self.time = None
        self.cputemperature = None
        self.temperature = None
        self.humidity = None
        self.pressure = None
        self.orientation = {"yaw": 0, "pitch": 0, "roll": 0}
        self.joystick = {"up": 0, "down": 0, "left": 0, "right": 0, "button": 0}
        
        #calculate the positions of the towers, iss, clock and stairs
        temppos = pos.clone()
        temppos.x += 2

        humiditypos = pos.clone()
        humiditypos.x -= 2

        pressurepos = pos.clone()
        pressurepos.z += 2

        cputemppos = pos.clone()
        cputemppos.z -= 2

        isspos = pos.clone()
        isspos.y += 40

        clockpos = pos.clone()
        clockpos.x -= 30
        clockpos.z -= 10
        clockpos.y += 11

        rocketpos = pos.clone()
        rocketpos.x += 15
        rocketpos.z -= 10

        stairspos = pos.clone()
        stairspos.z -= 5

        #create the clock
        self.clock = Clock(mc, clockpos, block.WOOL.id, 11)

        #clear an area for the tubes
        self.mc.setBlocks(
            self.pos.x - 3,
            self.pos.y,
            self.pos.z - 3,
            self.pos.x + 3,
            self.pos.y + 20,
            self.pos.z + 3,
            block.AIR.id)
        
        #create the tubes
        self.tempTube = DisplayTube(
            mc, temppos, 20,
            10, 40,
            block.LAVA.id)

        self.humidityTube = DisplayTube(
            mc, humiditypos, 20,
            20, 50,
            block.WATER)

        self.pressureTube = DisplayTube(
            mc, pressurepos, 20,
            950, 1050,
            block.OBSIDIAN)

        self.cputempTube = DisplayTube(
            mc, cputemppos, 20,
            30, 50,
            block.WOOL.id, 14)

        #create the ISS
        self.iss = ISS(mc, isspos)
        
        #create the stairs
        self.stairs = Stairs(mc, stairspos, 6, 38, block.DIAMOND_BLOCK.id)

        #create the launch pad and rocket
        self.launchpad = LaunchPad(mc, rocketpos)
        self.rocket = Rocket(mc, rocketpos, cleararea = False)
Exemplo n.º 2
0
class ISSTowerMinecraftDisplay():
    """
    Hannah's vision of how we would display the data in Minecraft
    
    A minecraft display which is 3 towers showing sensor data leading up to
    the ISS, with a clock and rocket launch tower
    """
    def __init__(self, mc, pos):

        self.mc = mc
        self.pos = pos

        self.time = None
        self.cputemperature = None
        self.temperature = None
        self.humidity = None
        self.pressure = None
        self.orientation = {"yaw": 0, "pitch": 0, "roll": 0}
        self.joystick = {"up": 0, "down": 0, "left": 0, "right": 0, "button": 0}
        
        #calculate the positions of the towers, iss, clock and stairs
        temppos = pos.clone()
        temppos.x += 2

        humiditypos = pos.clone()
        humiditypos.x -= 2

        pressurepos = pos.clone()
        pressurepos.z += 2

        cputemppos = pos.clone()
        cputemppos.z -= 2

        isspos = pos.clone()
        isspos.y += 40

        clockpos = pos.clone()
        clockpos.x -= 30
        clockpos.z -= 10
        clockpos.y += 11

        rocketpos = pos.clone()
        rocketpos.x += 15
        rocketpos.z -= 10

        stairspos = pos.clone()
        stairspos.z -= 5

        #create the clock
        self.clock = Clock(mc, clockpos, block.WOOL.id, 11)

        #clear an area for the tubes
        self.mc.setBlocks(
            self.pos.x - 3,
            self.pos.y,
            self.pos.z - 3,
            self.pos.x + 3,
            self.pos.y + 20,
            self.pos.z + 3,
            block.AIR.id)
        
        #create the tubes
        self.tempTube = DisplayTube(
            mc, temppos, 20,
            10, 40,
            block.LAVA.id)

        self.humidityTube = DisplayTube(
            mc, humiditypos, 20,
            20, 50,
            block.WATER)

        self.pressureTube = DisplayTube(
            mc, pressurepos, 20,
            950, 1050,
            block.OBSIDIAN)

        self.cputempTube = DisplayTube(
            mc, cputemppos, 20,
            30, 50,
            block.WOOL.id, 14)

        #create the ISS
        self.iss = ISS(mc, isspos)
        
        #create the stairs
        self.stairs = Stairs(mc, stairspos, 6, 38, block.DIAMOND_BLOCK.id)

        #create the launch pad and rocket
        self.launchpad = LaunchPad(mc, rocketpos)
        self.rocket = Rocket(mc, rocketpos, cleararea = False)

    def update(self, time, cpuTemperature, temperature, humidity, pressure, orientation, joystick):        
        #update the clock
        self.clock.setTime(time)

        #update the towers
        self.cputempTube.setValue(cpuTemperature)
        self.tempTube.setValue(temperature)
        self.humidityTube.setValue(humidity)
        self.pressureTube.setValue(pressure)

        #rotate the ISS
        yaw, pitch, roll = orientation["yaw"], orientation["pitch"], orientation["roll"]
        yaw, pitch, roll = roundDegrees(yaw), roundDegrees(pitch), roundDegrees(roll)
        if self.iss.rotate(yaw, pitch, roll):
            #if the iss was rotated, redraw the stairs as the ISS might have destroyed them
            self.stairs.draw()

        #has the joystick been pressed?
        if joystick["button"] == 1 or joystick["left"] == 1 or joystick["right"] == 1 or joystick["up"] == 1 or joystick["down"] == 1:
            #launch the rocket and then redraw it and the launch pad
            self.rocket.launch(75)
            self.launchpad.redraw()
            self.rocket.reset()
                    
        #update the values
        self.time = time
        self.cpuTemperature = cpuTemperature
        self.temperature = temperature
        self.humidity = humidity
        self.pressure = pressure
        self.orientation = orientation
        self.joystick = joystick

    def clear(self):
        #clear the display
        self.tempTube.clear()
        self.humidityTube.clear()
        self.pressureTube.clear()
        self.cputempTube.clear()
        self.iss.clear()
        self.clock.clear()
        self.stairs.clear()
        self.rocket.clear()
        self.launchpad.clear()
Exemplo n.º 3
0
#testing models
from mcmodels import Rocket, Arrow
from mcpi.minecraft import Minecraft
from time import sleep

mc = Minecraft.create()

pos = mc.player.getTilePos()
pos2 = pos.clone()
pos2.y + 10

print("create rocket")
r = Rocket(mc, pos)

sleep(5)

print("create rocket")
a = Arrow(mc, pos2)

sleep(5)

print("clear arrow")
a.clear()

sleep(5)

print("clear rocket")
r.clear()


Exemplo n.º 4
0
    def __init__(self, mc, pos):

        self.mc = mc
        self.pos = pos

        self.time = None
        self.cputemperature = None
        self.temperature = None
        self.humidity = None
        self.pressure = None
        self.orientation = {"yaw": 0, "pitch": 0, "roll": 0}
        self.joystick = {
            "up": 0,
            "down": 0,
            "left": 0,
            "right": 0,
            "button": 0
        }

        #calculate the positions of the towers, iss, clock and stairs
        temppos = pos.clone()
        temppos.x += 2

        humiditypos = pos.clone()
        humiditypos.x -= 2

        pressurepos = pos.clone()
        pressurepos.z += 2

        cputemppos = pos.clone()
        cputemppos.z -= 2

        isspos = pos.clone()
        isspos.y += 40

        clockpos = pos.clone()
        clockpos.x -= 30
        clockpos.z -= 10
        clockpos.y += 11

        rocketpos = pos.clone()
        rocketpos.x += 15
        rocketpos.z -= 10

        stairspos = pos.clone()
        stairspos.z -= 5

        #create the clock
        self.clock = Clock(mc, clockpos, block.WOOL.id, 11)

        #clear an area for the tubes
        self.mc.setBlocks(self.pos.x - 3, self.pos.y, self.pos.z - 3,
                          self.pos.x + 3, self.pos.y + 20, self.pos.z + 3,
                          block.AIR.id)

        #create the tubes
        self.tempTube = DisplayTube(mc, temppos, 20, 10, 40, block.LAVA.id)

        self.humidityTube = DisplayTube(mc, humiditypos, 20, 20, 50,
                                        block.WATER)

        self.pressureTube = DisplayTube(mc, pressurepos, 20, 950, 1050,
                                        block.OBSIDIAN)

        self.cputempTube = DisplayTube(mc, cputemppos, 20, 30, 50,
                                       block.WOOL.id, 14)

        #create the ISS
        self.iss = ISS(mc, isspos)

        #create the stairs
        self.stairs = Stairs(mc, stairspos, 6, 38, block.DIAMOND_BLOCK.id)

        #create the launch pad and rocket
        self.launchpad = LaunchPad(mc, rocketpos)
        self.rocket = Rocket(mc, rocketpos, cleararea=False)
Exemplo n.º 5
0
class ISSTowerMinecraftDisplay():
    """
    Hannah's vision of how we would display the data in Minecraft
    
    A minecraft display which is 3 towers showing sensor data leading up to
    the ISS, with a clock and rocket launch tower
    """
    def __init__(self, mc, pos):

        self.mc = mc
        self.pos = pos

        self.time = None
        self.cputemperature = None
        self.temperature = None
        self.humidity = None
        self.pressure = None
        self.orientation = {"yaw": 0, "pitch": 0, "roll": 0}
        self.joystick = {
            "up": 0,
            "down": 0,
            "left": 0,
            "right": 0,
            "button": 0
        }

        #calculate the positions of the towers, iss, clock and stairs
        temppos = pos.clone()
        temppos.x += 2

        humiditypos = pos.clone()
        humiditypos.x -= 2

        pressurepos = pos.clone()
        pressurepos.z += 2

        cputemppos = pos.clone()
        cputemppos.z -= 2

        isspos = pos.clone()
        isspos.y += 40

        clockpos = pos.clone()
        clockpos.x -= 30
        clockpos.z -= 10
        clockpos.y += 11

        rocketpos = pos.clone()
        rocketpos.x += 15
        rocketpos.z -= 10

        stairspos = pos.clone()
        stairspos.z -= 5

        #create the clock
        self.clock = Clock(mc, clockpos, block.WOOL.id, 11)

        #clear an area for the tubes
        self.mc.setBlocks(self.pos.x - 3, self.pos.y, self.pos.z - 3,
                          self.pos.x + 3, self.pos.y + 20, self.pos.z + 3,
                          block.AIR.id)

        #create the tubes
        self.tempTube = DisplayTube(mc, temppos, 20, 10, 40, block.LAVA.id)

        self.humidityTube = DisplayTube(mc, humiditypos, 20, 20, 50,
                                        block.WATER)

        self.pressureTube = DisplayTube(mc, pressurepos, 20, 950, 1050,
                                        block.OBSIDIAN)

        self.cputempTube = DisplayTube(mc, cputemppos, 20, 30, 50,
                                       block.WOOL.id, 14)

        #create the ISS
        self.iss = ISS(mc, isspos)

        #create the stairs
        self.stairs = Stairs(mc, stairspos, 6, 38, block.DIAMOND_BLOCK.id)

        #create the launch pad and rocket
        self.launchpad = LaunchPad(mc, rocketpos)
        self.rocket = Rocket(mc, rocketpos, cleararea=False)

    def update(self, time, cpuTemperature, temperature, humidity, pressure,
               orientation, joystick):
        #update the clock
        self.clock.setTime(time)

        #update the towers
        self.cputempTube.setValue(cpuTemperature)
        self.tempTube.setValue(temperature)
        self.humidityTube.setValue(humidity)
        self.pressureTube.setValue(pressure)

        #rotate the ISS
        yaw, pitch, roll = orientation["yaw"], orientation[
            "pitch"], orientation["roll"]
        yaw, pitch, roll = roundDegrees(yaw), roundDegrees(
            pitch), roundDegrees(roll)
        if self.iss.rotate(yaw, pitch, roll):
            #if the iss was rotated, redraw the stairs as the ISS might have destroyed them
            self.stairs.draw()

        #has the joystick been pressed?
        if joystick["button"] == 1 or joystick["left"] == 1 or joystick[
                "right"] == 1 or joystick["up"] == 1 or joystick["down"] == 1:
            #launch the rocket and then redraw it and the launch pad
            self.rocket.launch(75)
            self.launchpad.redraw()
            self.rocket.reset()

        #update the values
        self.time = time
        self.cpuTemperature = cpuTemperature
        self.temperature = temperature
        self.humidity = humidity
        self.pressure = pressure
        self.orientation = orientation
        self.joystick = joystick

    def clear(self):
        #clear the display
        self.tempTube.clear()
        self.humidityTube.clear()
        self.pressureTube.clear()
        self.cputempTube.clear()
        self.iss.clear()
        self.clock.clear()
        self.stairs.clear()
        self.rocket.clear()
        self.launchpad.clear()
Exemplo n.º 6
0
    y = cy + math.cos(math.radians(angle)) * radius
    return((int(x + 0.5),int(y + 0.5)))

if __name__ == "__main__":

    mc = Minecraft.create()

    mc.postToChat("SpaceCRAFT - Minecraft Rocket Launch")
    mc.postToChat("Hit the launch pad")
    
    #create the rocket next to the player at ground level
    rocketPos = mc.player.getTilePos()
    rocketPos.x += 5
    rocketPos.y = mc.getHeight(rocketPos.x, rocketPos.z) - 1
    launchpad = LaunchPad(mc, rocketPos)
    rocket = Rocket(mc, rocketPos)
    
    try:
        #wait till the launch tnt is hit
        launch = False
        while not launch:
            for hit in mc.events.pollBlockHits():
                shapeblockhit = launchpad.getShapeBlock(
                    hit.pos.x, hit.pos.y, hit.pos.z)
                
                if shapeblockhit != None:
                    
                    if shapeblockhit.tag == "launch":
                        launch = True
                
        #count down to blast off