How do I input collision?

42 Views Asked by At
from graphics import*
import time
import random 

def main():

    numx=random.randint(10,700)

    wn=GraphWin("AK",700,700)
    wn.setBackground("white")

    msg=Text(Point(25,30),"Score")
    msg.setSize(12)
    msg.setTextColor('blue')
    msg.draw(wn)

    inch=Entry(Point(60,30),2)
    inch.setFill('white')
    inch.draw(wn) 

    sqrg=Rectangle(Point(330,650),Point(430,665))
    sqrg.setFill("red")
    sqrg.draw(wn)

    xval=10
    yval=0
    wn.getMouse()
    for i in range(35):
        blx=Circle(Point(numx,100),20)
        blx.setFill("blue")
        blx.draw(wn)
        num=blx
        for k in range(35):
            numx=random.randint(10,700)
            blx.move(0,20)
            time.sleep(0.08)
            sqrg.move(xval,yval)
            symbl=wn.checkKey()
            if symbl=="Right":
                    xval=10
                    yval=0
            if symbl=="Left":
                    xval=-10
                    yval=0

main()

How to input collision into my program for when the circle hits the rectangle? Also how to make the score go up when that happens?

0

There are 0 best solutions below