Explode

# tickle squirm explode
# i call this program "poke-a-jen." every time you click on the circle
#you are tickling it. it squirms more each time. then it gets really
#hyper/mad and it explodes because it is so excited.
import math
g.norefresh()
def distance (a,b,c,d):
return math.sqrt(pow(c-a, 2)+pow(d-b, 2))
c=0
x1=35
y1=0
d=30
def fillCircle (x, y, d,c):
for i in range (x, x+d):
for j in range (y, y+d):
if distance (i, j, (x+(d/2)), (y+(d/2))) < (d/2):
g.setPixel(i,j, c)
def Squirm (x, y, n ):
for a in range (0, n):
fillCircle(x+a%3, y + 2 - a%3, 30, 100)
g.refresh()
g.paper(0)
def Explode (a, n, h):
n=100/n
for d in range (0, 50):
x=50-d
y=int(abs(a*math.sin(math.pi/n*(x)))+h)
fillCircle(x,y, 22, 100)
fillCircle(d+50, y, 22, 100)
g.refresh()
g.pause(3)
g.paper(0)
fillCircle(x1, y1, d, 100)
while c<7:
if g.getMouse(3) :
mx=g.getMouse(1)
my=g.getMouse(2)
if distance (mx, my, (x1+(d/2)), (y1+(d/2))) < (d/2):
c=c+1
Squirm(35, 0, c*2)
Squirm (35, 0, 20)
Explode(60,2 , 0)