Python Bubble Blaster

from graphics import*

from time import sleep

from random import randint


W, H = 400, 400

r = 10


win = GraphWin('bubble blaster', W, H)

#win.setCoords(-100, -100, 100, 100)

win.setBackground('black')

p1 = win.getMouse()

for i in range(10):

    p2 = win.getMouse()

    x1, y1 = p1.getX(), p1.getY()

    x2, y2 = p2.getX(), p2.getY()

    

    dx, dy = x2- x1, y2 - y1

    N = 10

    

    bubble = Circle(p1, r)

    bubble.setFill('lightblue')

    bubble.draw(win)

    xi, yi = x1, y1

    

    for i in range(10):

        xi, yi = xi +dx/N, yi+ dy/N

        pi =Point(xi + randint(-10, 10), yi + randint(-10,10) )

        bubble = Circle(pi, r)

        bubble.setFill('lightblue')

        bubble.draw(win)

        p1 = p2


point = win.getMouse()

win.close()



0 Kudos

Comments

Displaying 0 of 0 comments ( View all | Add Comment )