Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def pool_bounce(pool_x, pool_y, pos_x, pos_y, angle_init, nbr_bounce):
- assert(pool_x >= 0), "The width of the pool (the x size) must be a positive number"
- assert(pool_y >= 0), "The height of the pool (the y size) must be a positive number"
- # Drawing the pool (only the edges)
- teleport(pool_x/2, 0)
- pencolor("red")
- left(90)
- forward(pool_y/2)
- left(90)
- forward(pool_x)
- left(90)
- forward(pool_y)
- left(90)
- forward(pool_x)
- left(90)
- forward(pool_y/2)
- right(90)
- pencolor("black")
- teleport(pos_x, pos_y) # Placing the point at the specified coordinates
- left(angle_init) # Inputting the beginning angle to the turtle
- forward((pool_x/2)/cos(radians(angle_init)))
- left(180-2*angle_init)
- idx = 1
- for idx in range (1, nbr_bounce):
- v = pos()
- d1 = pool_x/cos(radians(angle_init))
- opposed = d1*sin(radians(angle_init))
- if(opposed > floor(pool_y/2 - v[1])):
- d = floor(pool_y/2 - v[1])/sin(radians(angle_init))
- else:
- d = d1
- forward(d)
- if(heading() > 90.0):
- right(180-2*angle_init)
- else:
- left(180-2*angle_init)
- pool_bounce(400, 400, 0, 0, 12, 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement