import turtle import random import math from Bonus import * screen = turtle.Screen() screen.setup(1024, 720) screen.tracer(0, 0) # test() t = turtle.Turtle() t.speed(0) t.hideturtle() t.penup() t.width(2) angle = bestangle() x_start = -250 ground = -150 # draw the ground gt = turtle.Turtle() gt.speed(0) # gt.hideturtle() gt.penup() gt.goto(-300, ground) gt.pendown() gt.goto(300, ground) # draw the house house_turtle = turtle.Turtle() # house_turtle.hideturtle() # You can uncomment this line to hide the turtle head house_turtle.speed(2) screen.tracer(1, None) draw_house(house_turtle) screen.tracer(0, 0) x = x_start y = ground velocity = 10 ay = -setgravity() / 20 theta = math.radians(angle) vx = velocity * math.cos(theta) vy = velocity * math.sin(theta) name = "" name = namerocket() t.write("This is " + name + "'s rocket!", font=("Arial", 20, "normal")) t.goto(x, y) t.pendown() while True: t.goto(x, y) x += vx y += vy vy += ay screen.update() if stoprocket(y, ground): # stop the turtle print("I travelled", int(x - x_start), "units!") break angles = [] ts = [] xs = [] ys = [] vxs = [] vys = [] def launch_rocket(angle): angles.append(angle) ts.append(turtle.Turtle()) xs.append(x_start) ys.append(ground + 0.01) theta = math.radians(angle) vxs.append(velocity * math.cos(theta)) vys.append(velocity * math.sin(theta)) def launch_rockets(): for i in range(len(ts)): t = ts[i] x = xs[i] y = ys[i] vx = vxs[i] vy = vys[i] angle = angles[i] t.speed(0) t.color( "rgb(" + str(random.randint(0, 255)) + ", " + str(random.randint(0, 255)) + ", " + str(random.randint(0, 255)) + ")" ) # t.hideturtle() t.penup() t.width(5) t.goto(x, y) t.pendown() while True: screen.update() for i in range(len(ts)): t = ts[i] x = xs[i] y = ys[i] vx = vxs[i] vy = vys[i] angle = angles[i] t.goto(x, y) xs[i] += vxs[i] ys[i] += vys[i] vys[i] += ay if stoprocket(y, ground): vxs[i] = 0 vys[i] = 0 turtle.done()