init
commit
b519677fc7
@ -0,0 +1,115 @@
|
||||
from chiplotle3 import *
|
||||
import os
|
||||
import time
|
||||
import random
|
||||
|
||||
print("Start the script");
|
||||
is_waiting = False
|
||||
|
||||
# init the plotter
|
||||
plotter = instantiate_plotters()[0]
|
||||
|
||||
|
||||
plotter.write("IN;SC0,100,0,100;PU;DI-1,0;DT*;SI0.5,0.7;PU;PA90,10;LBHello, are you a robot?*PU;PA90, 20;PD;LBYES*PR2,0;PR0,2;PR-2,0;PR0,-2;PU;PA20, 20;PD;LBNO*PR2,0;PR0,2;PR-2,0;PR0,-2;PU;PA50,20;PD;")
|
||||
|
||||
print("go to sleep")
|
||||
# plotter.write("IN;SC0,100,0,100;PU;DT*;SI0.5,0.7;PU5,10;LBHello, are you a robot?*PU5, 20;PR2,0;PR0,2;PR-2,0;PR0,-2;LBYES*PU60, 20;PR2,0;PR0,2;PR-2,0;PR0,-2;LBNO*")
|
||||
time.sleep(15)
|
||||
plotter.write("PU;PA50,20;PD;")
|
||||
time.sleep(3)
|
||||
print("stopped the sleep")
|
||||
|
||||
is_waiting = True
|
||||
prev_position = plotter.actual_position[0]
|
||||
|
||||
def check_direction(new, original):
|
||||
if(new[0] > original[0]):
|
||||
print("went left")
|
||||
return "left"
|
||||
|
||||
elif (new[0] < original[0]):
|
||||
print("went right")
|
||||
return "right"
|
||||
elif (new[1] > original[1]):
|
||||
print("went up")
|
||||
return "up"
|
||||
elif (new[1] < original[1]):
|
||||
print("went down")
|
||||
return "down"
|
||||
else:
|
||||
return False
|
||||
|
||||
while is_waiting:
|
||||
print("the plotter is waiting for your answer")
|
||||
pos = plotter.actual_position[0]
|
||||
print("the pen position is:", pos, prev_position)
|
||||
direction = check_direction(pos, prev_position)
|
||||
if(direction == "left"):
|
||||
is_waiting = False
|
||||
plotter.write("PA90,30;LBFinally, it's just us now!*")
|
||||
elif (direction == "right"):
|
||||
is_waiting = False
|
||||
plotter.write("PA90,30;LBI'm afraid i cant do that*")
|
||||
|
||||
prev_position = pos
|
||||
plotter.pen_down()
|
||||
plotter.pen_up()
|
||||
time.sleep(.1)
|
||||
|
||||
|
||||
# plotter.scale()
|
||||
# # Write the first question
|
||||
# plotter.write(hpgl.PU([(0,0)]))
|
||||
# plotter.write(hpgl.PD([(0,0)]))
|
||||
# plotter.write(shapes.label("[0,0]",.3,.3 ))
|
||||
# plotter.write(hpgl.PU([(100,100)]))
|
||||
# plotter.write(hpgl.PD([(100,100)]))
|
||||
# plotter.write(shapes.label("[100,100]",.3,.3 ))
|
||||
|
||||
# plotter.goto(0,0)
|
||||
# plotter.write(shapes.label("0,0",1 ,1 ))
|
||||
|
||||
# plotter.goto(100,100)
|
||||
# plotter.write(shapes.label("100,100",1 ,1 ))
|
||||
# plotter.pen_up()
|
||||
# time.sleep(1)
|
||||
|
||||
|
||||
|
||||
# plotter.pen_down()
|
||||
# plotter.pen_up()
|
||||
# time.sleep(2)
|
||||
|
||||
# time.sleep(1)
|
||||
# plotter.pen_down()
|
||||
# time.sleep(1)
|
||||
|
||||
# for x in range(60):
|
||||
# print("loop")
|
||||
# plotter.pen_down()
|
||||
# plotter.pen_up()
|
||||
# time.sleep(.5)
|
||||
|
||||
# Start the waiting bit
|
||||
|
||||
# get the sleeping
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# print(pos[0])
|
||||
|
||||
# print(plotter.actual_position[0])
|
||||
|
||||
|
||||
# print("start the drawing");
|
||||
# plotter.select_pen(1)
|
||||
# plotter.margins.hard.draw_outline()
|
||||
# plotter.write(shapes.rectangle(20,20))
|
||||
|
||||
# pos = plotter.actual_position
|
||||
# print(pos[0])
|
||||
# print("end")
|
||||
|
||||
|
Loading…
Reference in New Issue