Ejemplo n.º 1
0
def init_man(x, y, scale):
    # define the man shapes and put them into a list

    # Head: Create a circle with the color brown
    head = gr.Circle(gr.Point(x + scale * 10, y - scale * 50), 20 * scale)
    head.setFill('brown')

    # arms : Create a rectangle with the color blue for the arms
    arms = gr.Rectangle(gr.Point(x + scale * 110, y),
                        gr.Point(x - scale * 80, y - scale * 30))
    arms.setFill('blue')

    # stomach : Create a rectangle with the color blue for the sh
    stomach = gr.Rectangle(gr.Point(x + scale * 70, y + scale * 60),
                           gr.Point(x - scale * 50, y))
    stomach.setFill('blue')

    # # leg2 : Create a rectangle with the color red for pants
    leg1 = gr.Rectangle(gr.Point(x - scale * 20, y + scale * 60),
                        gr.Point(x - scale * 40, y + scale * 180))
    leg1.setFill('red')

    #   # leg2 : Create a rectangle with the color red for pants
    leg2 = gr.Rectangle(gr.Point(x + scale * 60, y + scale * 60),
                        gr.Point(x + scale * 40, y + scale * 180))
    leg2.setFill('red')

    # man creates the list of all the basic shapes created by zelle
    man = [head, arms, leg1, leg2, stomach]
    return man
Ejemplo n.º 2
0
def steam_init(x, y, scale):
    '''
    Creates a list of objets needed to draw a steam plant at position (x,y) 
    with given scale
    '''

    shapes = []
    plant = gr.Rectangle(gr.Point(x, y),
                         gr.Point(x + scale * 100, y - scale * 30))
    grey = gr.color_rgb(185, 185, 185)
    plant.setFill(grey)
    shapes.append(plant)

    roof = gr.Rectangle(gr.Point(x - scale * 1, y - scale * 30),
                        gr.Point(x + scale * 101, y - scale * 40))
    ltbrown = gr.color_rgb(176, 133, 85)
    roof.setFill(ltbrown)
    shapes.append(roof)

    smokestack = gr.Rectangle(gr.Point(x, y),
                              gr.Point(x + scale * 10, y - scale * 100))
    rstbrwn = gr.color_rgb(136, 96, 90)
    smokestack.setFill(rstbrwn)
    shapes.insert(0, smokestack)

    return shapes
Ejemplo n.º 3
0
def witchArms_init(x, y, scale):
    '''Creates and returns a list of graphics objects to make up a witcharms and stick'''
    shapes = []

    #witch arm
    r = gr.Rectangle(gr.Point(x - scale * 15, y - scale * 25),
                     gr.Point(x - scale * 2, y - scale * 20))
    r.setFill(gr.color_rgb(0, 205, 0))
    shapes.append(r)
    r = gr.Rectangle(gr.Point(x + scale * 15, y - scale * 25),
                     gr.Point(x + scale * 2, y - scale * 20))
    r.setFill(gr.color_rgb(0, 205, 0))
    shapes.append(r)

    #sleeves
    r = gr.Rectangle(gr.Point(x - scale * 15, y - scale * 25),
                     gr.Point(x - scale * 5, y - scale * 20))
    r.setFill(gr.color_rgb(128, 0, 128))
    shapes.append(r)
    r = gr.Rectangle(gr.Point(x + scale * 15, y - scale * 25),
                     gr.Point(x + scale * 5, y - scale * 20))
    r.setFill(gr.color_rgb(128, 0, 128))
    shapes.append(r)

    #spoon
    r = gr.Rectangle(gr.Point(x - scale * 2, y - scale * 35),
                     gr.Point(x + scale * 2, y + scale * 10))
    r.setFill(gr.color_rgb(139, 62, 47))
    shapes.append(r)

    return shapes
Ejemplo n.º 4
0
def potion_init(x, y, scale):
    '''Creates and returns a list of graphics objects to make up a potion'''
    shapes = []

    p = gr.Polygon(gr.Point(x + scale * 30, y + scale * 80),
                   gr.Point(x + scale * 40, y + scale * 60),
                   gr.Point(x + scale * 40, y + scale * 40),
                   gr.Point(x + scale * 50, y + scale * 40),
                   gr.Point(x + scale * 50, y + scale * 60),
                   gr.Point(x + scale * 60, y + scale * 80))
    p.setFill(gr.color_rgb(198, 226, 255))
    shapes.append(p)
    p = gr.Polygon(gr.Point(x + scale * 30, y + scale * 80),
                   gr.Point(x + scale * 40, y + scale * 60),
                   gr.Point(x + scale * 40, y + scale * 50),
                   gr.Point(x + scale * 50, y + scale * 50),
                   gr.Point(x + scale * 50, y + scale * 60),
                   gr.Point(x + scale * 60, y + scale * 80))
    p.setFill(gr.color_rgb(255, 62, 150))
    shapes.append(p)
    r = gr.Rectangle(gr.Point(x + scale * 42, y + scale * 35),
                     gr.Point(x + scale * 48, y + scale * 40))
    r.setFill(gr.color_rgb(139, 71, 38))
    shapes.append(r)

    return shapes
Ejemplo n.º 5
0
def init_pool(x, y, scale):

    # # diving board : Create a rectangle with the color brown
    diving_board = gr.Rectangle(gr.Point(x + scale * 180, y + scale * 180),
                                gr.Point(x - scale * 260, y + scale * 250))
    diving_board.setFill('brown')

    # create a swiming pool with the color skyblue
    water = gr.Rectangle(gr.Point(x + scale * 780, y + scale * 880),
                         gr.Point(x - scale * 260, y + scale * 250))
    water.setFill('skyblue')

    # create a list of the complex shapes
    pool = [diving_board, water]

    return pool
Ejemplo n.º 6
0
def spaceship_init(x, y, scale):
    '''Creates and returns a list of graphics objects to make up a spaceship'''

    shapes = []

    r = gr.Rectangle(gr.Point(x - scale * 10, y),
                     gr.Point(x + scale * 10, y - scale * 80))
    r.setFill(gr.color_rgb(185, 150, 185))
    shapes.append(r)

    p = gr.Polygon(gr.Point(x - scale * 10, y - scale * 80),
                   gr.Point(x, y - scale * 100),
                   gr.Point(x + scale * 10, y - scale * 80))
    p.setFill(gr.color_rgb(150, 170, 200))
    shapes.append(p)

    p = gr.Polygon(gr.Point(x - scale * 10, y),
                   gr.Point(x - scale * 10, y - scale * 20),
                   gr.Point(x - scale * 25, y))
    p.setFill(gr.color_rgb(200, 170, 150))
    shapes.append(p)

    p = gr.Polygon(gr.Point(x + scale * 10, y),
                   gr.Point(x + scale * 10, y - scale * 20),
                   gr.Point(x + scale * 25, y))
    p.setFill(gr.color_rgb(200, 170, 150))
    shapes.append(p)

    return shapes
Ejemplo n.º 7
0
def bullet_init(x, y, scale):
    shapes3 = []
    bullet = gr.Rectangle(gr.Point(x + scale * 100, y - scale * 39),
                          gr.Point(x + scale * 115, y - scale * 44))
    yellowbullet = gr.color_rgb(200, 200, 0)
    bullet.setFill(yellowbullet)
    shapes3.append(bullet)

    return shapes3
Ejemplo n.º 8
0
def catArm_init(x, y, scale):
    '''Creates and returns a list of graphics objects to make up a cat arm'''
    shapes = []

    r = gr.Rectangle(gr.Point(x + scale * 170, y + scale * 68),
                     gr.Point(x + scale * 200, y + scale * 73))
    r.setFill(gr.color_rgb(0, 0, 0))
    shapes.append(r)

    return shapes
Ejemplo n.º 9
0
def init_card(win):
    cards = []
    #create Rectangle objects for cards and exit button
    for i in range(6):
        for j in range(7):
            card = gr.Rectangle(gr.Point(60 + 100 * j, 50 + 120 * i),
                                gr.Point(140 + 100 * j, 150 + 120 * i))
            cards.append(card)

    exit = gr.Rectangle(gr.Point(600, 10), gr.Point(650, 30))

    #draw cards
    for card in cards:
        card.setFill("white")
        card.draw(win)

    #show text for exit button
    exit.setFill("white")
    exit.draw(win)
    text = gr.Text(gr.Point(625, 20), "Exit")
    text.setFill("black")
    text.draw(win)
    return cards, exit
Ejemplo n.º 10
0
def tank_init(x, y, scale):
    '''
	Creates list of objects needed to draw a tank at position (x,y) with given scale
	'''

    shapes1 = []
    base = gr.Rectangle(gr.Point(x, y),
                        gr.Point(x + scale * 100, y - scale * 30))
    green = gr.color_rgb(0, 150, 0)
    base.setFill(green)
    shapes1.append(base)
    cannonhouse = gr.Rectangle(gr.Point(x + scale * 1.1, y - scale * 30),
                               gr.Point(x + scale * 95, y - scale * 50))
    darkergreen = gr.color_rgb(0, 120, 0)
    cannonhouse.setFill(darkergreen)
    shapes1.append(cannonhouse)
    cannon = gr.Rectangle(gr.Point(x + scale * 95, y - scale * 37),
                          gr.Point(x + scale * 120, y - scale * 45))
    darkestgreen = gr.color_rgb(0, 90, 0)
    cannon.setFill(darkestgreen)
    shapes1.append(cannon)

    return shapes1
Ejemplo n.º 11
0
def steam_init(x,y,scale):
	'''
	  Creates the list of objects needed to draw a steam plant
	  at position (x,y) with the given scale.
	'''
	shapes = []
	
	#steam plant
	r = gr.Rectangle(gr.Point(x,y),gr.Point(x+scale*100,y-scale*30))
	r.setFill(gr.color_rgb(185,185,185))
	shapes.append(r)
	
	#roof
	r = gr.Rectangle(gr.Point(x-scale*1,y-scale*30),gr.Point(x+scale*101,y-scale*40))
	r.setFill(gr.color_rgb(176,133,85))
	shapes.append(r)
	
	#smokestack
	r = gr.Rectangle(gr.Point(x,y),gr.Point(x+scale*10,y-scale*100))
	r.setFill(gr.color_rgb(136,96,90))
	shapes.insert(0,r)
	
	return shapes
Ejemplo n.º 12
0
def cat_init(x, y, scale):
    '''Creates and returns a list of graphics objects to make up a cat'''
    shapes = []
    #cat
    p = gr.Polygon(gr.Point(x + scale * 180, y + scale * 40),
                   gr.Point(x + scale * 190, y + scale * 35),
                   gr.Point(x + scale * 190, y + scale * 50))
    p.setFill(gr.color_rgb(30, 30, 30))
    shapes.append(p)
    p = gr.Polygon(gr.Point(x + scale * 180, y + scale * 40),
                   gr.Point(x + scale * 170, y + scale * 35),
                   gr.Point(x + scale * 170, y + scale * 50))
    p.setFill(gr.color_rgb(30, 30, 30))
    shapes.append(p)
    c = gr.Circle(gr.Point(x + scale * 180, y + scale * 50), scale * 10)
    c.setFill(gr.color_rgb(0, 0, 0))
    shapes.append(c)

    c = gr.Circle(gr.Point(x + scale * 175, y + scale * 50), scale * 2)
    c.setFill(gr.color_rgb(67, 205, 128))
    shapes.append(c)
    c = gr.Circle(gr.Point(x + scale * 185, y + scale * 50), scale * 2)
    c.setFill(gr.color_rgb(67, 205, 128))
    shapes.append(c)

    #body
    r = gr.Rectangle(gr.Point(x + scale * 155, y + scale * 60),
                     gr.Point(x + scale * 185, y + scale * 80))
    r.setFill(gr.color_rgb(0, 0, 0))
    shapes.append(r)
    c = gr.Circle(gr.Point(x + scale * 155, y + scale * 70), scale * 10)
    c.setFill(gr.color_rgb(0, 0, 0))
    shapes.append(c)

    r = gr.Rectangle(gr.Point(x + scale * 120, y + scale * 65),
                     gr.Point(x + scale * 155, y + scale * 70))
    r.setFill(gr.color_rgb(0, 0, 0))
    shapes.append(r)
    r = gr.Rectangle(gr.Point(x + scale * 120, y + scale * 40),
                     gr.Point(x + scale * 125, y + scale * 70))
    r.setFill(gr.color_rgb(0, 0, 0))
    shapes.append(r)
    #legs
    r = gr.Rectangle(gr.Point(x + scale * 150, y + scale * 80),
                     gr.Point(x + scale * 155, y + scale * 100))
    r.setFill(gr.color_rgb(0, 0, 0))
    shapes.append(r)
    r = gr.Rectangle(gr.Point(x + scale * 165, y + scale * 80),
                     gr.Point(x + scale * 170, y + scale * 100))
    r.setFill(gr.color_rgb(0, 0, 0))
    shapes.append(r)
    r = gr.Rectangle(gr.Point(x + scale * 180, y + scale * 80),
                     gr.Point(x + scale * 185, y + scale * 100))
    r.setFill(gr.color_rgb(0, 0, 0))
    shapes.append(r)

    return shapes
Ejemplo n.º 13
0
def cauldron_init(x, y, scale):
    '''Creates and returns a list of graphics objects to make up a cauldron'''
    shapes = []

    o = gr.Oval(gr.Point(x - scale * 35, y + scale * 13),
                gr.Point(x + scale * 35, y + scale * 63))
    o.setFill(gr.color_rgb(56, 56, 56))
    shapes.append(o)

    r = gr.Rectangle(gr.Point(x - scale * 25, y + scale * 10),
                     gr.Point(x + scale * 25, y + scale * 20))
    r.setFill(gr.color_rgb(56, 56, 56))
    a(r)

    return shapes
Ejemplo n.º 14
0
def village(x, y, scale):  # define the village
    b1 = g.Rectangle(
        g.Point(x + 100 * scale, y - 10 * scale),  # house box point list
        g.Point(x + 150 * scale, y - 50 * scale))
    b1.setFill("orange")
    c1 = g.Circle(g.Point(x + 125 * scale, y - 60 * scale),
                  30 * scale)  # house roof box point list
    c1.setFill("pink")

    b2 = g.Rectangle(
        g.Point(x + 300 * scale, y - 10 * scale),  # house box point list
        g.Point(x + 350 * scale, y - 50 * scale))
    b2.setFill("grey")
    c2 = g.Circle(g.Point(x + 325 * scale, y - 60 * scale),
                  30 * scale)  # house roof box point list
    c2.setFill("yellow")

    b3 = g.Rectangle(
        g.Point(x + 200 * scale, y - 10 * scale),  # tree box point list
        g.Point(x + 220 * scale, y - 150 * scale))
    b3.setFill("brown")
    c3 = g.Circle(g.Point(x + 210 * scale, y - 150 * scale),
                  50 * scale)  # tree roof box point list
    c3.setFill("green")

    b4 = g.Rectangle(
        g.Point(x + 250 * scale, y - 10 * scale),  # tree box point list
        g.Point(x + 270 * scale, y - 130 * scale))
    b4.setFill("black")
    c4 = g.Circle(g.Point(x + 260 * scale, y - 130 * scale),
                  50 * scale)  # tree roof box point list
    c4.setFill("light green")

    test2 = [b1, b2, c1, c2, b3, c3, b4, c4]

    return test2
Ejemplo n.º 15
0
def init_rocket(x, y, scale):
    # define the rocket shapes here and put them in a list

    #Body: Create a Rectangle using points (x-scale*10, y) and (x+scale*10, y-scale*80).
    #Set the Rectangle fill color to be a grey color (185, 185, 185).
    body = gr.Rectangle(gr.Point(x - scale * 10, y),
                        gr.Point(x + scale * 10, y - scale * 80))
    body.setFill(gr.color_rgb(185, 185, 185))

    #Nose: Create a Polygon, with points (x-scale*10, y-scale*80), (x, y-scale*100 ), and (x+scale*10, y-scale*80 ).
    #Set the Polygon fill color to be a grey-blue color (150, 170, 200 ).

    #L Fin: Create a Polygon, with points (x-scale*10, y), (x-scale*10, y-scale*20 ), and (x- scale*25, y+scale*5 ).
    #Set the Polygon fill color to be a grey-red color (200, 170, 150 ).

    #R Fin: Create a Polygon, with points (x+scale*10, y), (x+scale*10, y-scale*20 ), and (x+scale*25, y+scale*5 ).
    #Set the Polygon fill color to be a grey-red color (200, 170, 150 ).
    return [body]
Ejemplo n.º 16
0
def interactive():

    win = gr.GraphWin( 'interactive demo', 500, 500, False )
    r = gr.Rectangle( gr.Point( 220, 260 ), gr.Point( 280, 240 ) )
    r.setOutline( 'purple' )
    r.setFill( 'pink' )
    r.setWidth( 3 )
    r.draw( win )

    counter = 0
    falling = None

    # begin event loop
    while True: # infinite loop

        if counter % 100 == 0:
            if falling != None:
                falling.undraw()
            falling = gr.Circle( gr.Point( random.randint(0, 500), 0 ), 10 )
            falling.setFill( 'blue' )
            falling.draw(win)

        if falling != None:
            falling.move( random.randint(-3, 3), 5 )

        counter += 1

        key = win.checkKey()
        if key == 'q':
            break
        elif key == 'a': # move left
            r.move( -20, 0 )
        elif key == 'w': # move up
            r.move( 0, -20 )
        elif key == 's': # move down
            r.move( 0, 20 )
        elif key == 'd': # move right
            r.move( 20, 0 )

        win.update() # manually update the window

    print("Terminating")
    win.close()
Ejemplo n.º 17
0
def thumbStack(x, y, scale, win):
    #wrist:rectangle objects
    wrist = gr.Rectangle(gr.Point(x + 60 * scale, y + 105 * scale),
                         gr.Point(x + 120 * scale, y + 215 * scale))
    points = [
        gr.Point(x + 120 * scale, y + 125 * scale),
        gr.Point(x + 142 * scale, y + 115 * scale),
        gr.Point(x + 183 * scale, y + 56 * scale),
        gr.Point(x + 190 * scale, y + 16 * scale),
        gr.Point(x + 210 * scale, y + 16 * scale),
        gr.Point(x + 220 * scale, y + 56 * scale),
        gr.Point(x + 204 * scale, y + 105 * scale),
        gr.Point(x + 262 * scale, y + 104 * scale),
        gr.Point(x + 259 * scale, y + 124 * scale),
        gr.Point(x + 245 * scale, y + 126 * scale),
        gr.Point(x + 259 * scale, y + 124 * scale),
        gr.Point(x + 258 * scale, y + 144 * scale),
        gr.Point(x + 244 * scale, y + 144 * scale),
        gr.Point(x + 258 * scale, y + 144 * scale),
        gr.Point(x + 256 * scale, y + 164 * scale),
        gr.Point(x + 243 * scale, y + 164 * scale),
        gr.Point(x + 256 * scale, y + 164 * scale),
        gr.Point(x + 254 * scale, y + 181 * scale),
        gr.Point(x + 241 * scale, y + 179 * scale),
        gr.Point(x + 254 * scale, y + 181 * scale),
        gr.Point(x + 251 * scale, y + 204 * scale),
        gr.Point(x + 120 * scale, y + 195 * scale),
        gr.Point(x + 120 * scale, y + 125 * scale)
    ]
    #thumb:polygon objects
    thumb = gr.Polygon(points)
    #set color for both objects
    wrist.setFill("dodgerblue")
    thumb.setFill("goldenrod")
    #set the termination condition
    if scale < 0.4:
        return
    #draw wrist and thumb
    wrist.draw(win)
    thumb.draw(win)
    #call thumbStack recursively
    thumbStack(x, y + scale * 200, scale * 0.8, win)
Ejemplo n.º 18
0
def vehicle_init(x, y, scale):
    '''
	Creates list of objects needed to draw a tan armored vehicle at posiiton (x,y)
	with given scale
	'''
    shapes2 = []
    vehicle = gr.Rectangle(gr.Point(x * scale + 100, y + scale * 30),
                           gr.Point(x + scale * 30, y - scale * 1))
    tan = gr.color_rgb(255, 239, 219)
    vehicle.setFill(tan)
    shapes2.append(vehicle)
    leftwheel = gr.Circle(gr.Point(x + scale * 44, y + scale * 40), 9 * scale)
    black = gr.color_rgb(0, 0, 0)
    leftwheel.setFill(black)
    shapes2.append(leftwheel)
    rightwheel = gr.Circle(gr.Point(x + scale * 88, y + scale * 40), 9 * scale)
    rightwheel.setFill(black)
    shapes2.append(rightwheel)

    return shapes2
Ejemplo n.º 19
0
def plant_init(x, y, scale):
    '''Creates and returns a list of graphics objects to make up a plant'''
    shapes = []

    #pot
    r = gr.Rectangle(gr.Point(x + scale * 70, y + scale * 50),
                     gr.Point(x + scale * 100, y + scale * 60))
    r.setFill(gr.color_rgb(255, 130, 71))
    shapes.append(r)
    p = gr.Polygon(gr.Point(x + scale * 80, y + scale * 80),
                   gr.Point(x + scale * 75, y + scale * 60),
                   gr.Point(x + scale * 95, y + scale * 60),
                   gr.Point(x + scale * 90, y + scale * 80))
    p.setFill(gr.color_rgb(255, 130, 71))
    shapes.append(p)
    #leaves
    p = gr.Polygon(gr.Point(x + scale * 70, y + scale * 50),
                   gr.Point(x + scale * 60, y + scale * 30),
                   gr.Point(x + scale * 80, y + scale * 50))
    p.setFill(gr.color_rgb(152, 251, 152))
    shapes.append(p)
    p = gr.Polygon(gr.Point(x + scale * 75, y + scale * 50),
                   gr.Point(x + scale * 80, y + scale * 20),
                   gr.Point(x + scale * 85, y + scale * 50))
    p.setFill(gr.color_rgb(152, 251, 152))
    shapes.append(p)
    p = gr.Polygon(gr.Point(x + scale * 85, y + scale * 50),
                   gr.Point(x + scale * 90, y + scale * 20),
                   gr.Point(x + scale * 100, y + scale * 50))
    p.setFill(gr.color_rgb(152, 251, 152))
    shapes.append(p)
    p = gr.Polygon(gr.Point(x + scale * 90, y + scale * 50),
                   gr.Point(x + scale * 110, y + scale * 30),
                   gr.Point(x + scale * 100, y + scale * 50))
    p.setFill(gr.color_rgb(152, 251, 152))
    shapes.append(p)

    return shapes
Ejemplo n.º 20
0
def background_init(x, y, scale):
    '''Creates and returns a list of graphics objects to make up a background'''
    shapes = []

    r = gr.Rectangle(gr.Point(x, y), gr.Point(x + scale * 500,
                                              y + scale * 400))
    r.setFill(gr.color_rgb(205, 170, 125))
    shapes.append(r)
    r = gr.Rectangle(gr.Point(x, y + scale * 300),
                     gr.Point(x + scale * 500, y + scale * 400))
    r.setFill(gr.color_rgb(139, 71, 38))
    shapes.append(r)

    #shelf
    r = gr.Rectangle(gr.Point(x + scale * 20, y + scale * 80),
                     gr.Point(x + scale * 120, y + scale * 90))
    r.setFill(gr.color_rgb(139, 71, 38))
    shapes.append(r)
    r = gr.Rectangle(gr.Point(x + scale * 120, y + scale * 100),
                     gr.Point(x + scale * 250, y + scale * 110))
    r.setFill(gr.color_rgb(139, 71, 38))
    shapes.append(r)
    r = gr.Rectangle(gr.Point(x + scale * 250, y + scale * 130),
                     gr.Point(x + scale * 340, y + scale * 140))
    r.setFill(gr.color_rgb(139, 71, 38))
    shapes.append(r)

    r = gr.Rectangle(gr.Point(x + scale * 340, y + scale * 170),
                     gr.Point(x + scale * 450, y + scale * 180))
    r.setFill(gr.color_rgb(139, 71, 38))
    shapes.append(r)

    #CrystalBallholder
    p = gr.Polygon(gr.Point(x + scale * 210, y + scale * 100),
                   gr.Point(x + scale * 220, y + scale * 90),
                   gr.Point(x + scale * 240, y + scale * 90),
                   gr.Point(x + scale * 250, y + scale * 100))
    p.setFill(gr.color_rgb(108, 123, 139))
    shapes.append(p)

    return shapes
Ejemplo n.º 21
0
def background_init(x,y,scale):
	'''
	  Creates the list of objects needed to draw the background
	  scene at position (x,y) with the given scale.
	'''
	shapes = []
	
	#sky IDX 0
	r = gr.Rectangle(gr.Point(x,y),gr.Point(x+scale*400,y+scale*400))
	r.setFill(gr.color_rgb(107,142,35))
	shapes.append(r)
	
	#ground IDX 1
	r = gr.Rectangle(gr.Point(x,y+300*scale),gr.Point(x+scale*400,y-scale*400))
	r.setFill(gr.color_rgb(0,191,255))
	shapes.append(r)
	
	#sun IDX 2
	c = gr.Circle(gr.Point(x+325*scale,y+75*scale),20*scale)
	c.setFill(gr.color_rgb(255,255,0))
	shapes.append(c)
	
	#yellow rays IDX 3-6
	t = gr.Polygon(gr.Point(x+325*scale,y+40*scale),gr.Point(x+327*scale,y+50*scale),
		gr.Point(x+323*scale,y+50*scale))
	t.setFill(gr.color_rgb(255,255,0))
	shapes.append(t)
	
	t = gr.Polygon(gr.Point(x+360*scale,y+75*scale),gr.Point(x+350*scale,y+73*scale),
		gr.Point(x+350*scale,y+77*scale))
	t.setFill(gr.color_rgb(255,255,0))
	shapes.append(t)
	
	t = gr.Polygon(gr.Point(x+325*scale,y+110*scale),gr.Point(x+327*scale,y+100*scale),
		gr.Point(x+323*scale,y+100*scale))
	t.setFill(gr.color_rgb(255,255,0))
	shapes.append(t)
	
	t = gr.Polygon(gr.Point(x+290*scale,y+75*scale),gr.Point(x+300*scale,y+73*scale),
		gr.Point(x+300*scale,y+77*scale))
	t.setFill(gr.color_rgb(255,255,0))
	shapes.append(t)
	
	#orange rays IDX 7-10
	t = gr.Polygon(gr.Point(x+352*scale,y+50*scale),gr.Point(x+341*scale,y+57*scale),
		gr.Point(x+344*scale,y+60*scale))
	t.setFill(gr.color_rgb(255,150,0))
	shapes.append(t)
	
	t = gr.Polygon(gr.Point(x+352*scale,y+100*scale),gr.Point(x+341*scale,y+93*scale),
		gr.Point(x+344*scale,y+90*scale))
	t.setFill(gr.color_rgb(255,150,0))
	shapes.append(t)
	
	t = gr.Polygon(gr.Point(x+298*scale,y+100*scale),gr.Point(x+309*scale,y+93*scale),
		gr.Point(x+306*scale,y+90*scale))
	t.setFill(gr.color_rgb(255,150,0))
	shapes.append(t)
	
	t = gr.Polygon(gr.Point(x+298*scale,y+50*scale),gr.Point(x+309*scale,y+57*scale),
		gr.Point(x+306*scale,y+60*scale))
	t.setFill(gr.color_rgb(255,150,0))
	shapes.append(t)
	
	return shapes
Ejemplo n.º 22
0
import graphicsPlus as gr
import random

# create a window
win = gr.GraphWin("My window", 500, 500)
r = gr.Rectangle(gr.Point(220, 260), gr.Point(280, 240))
r.setOutline('purple')
r.setFill('pink')
r.setWidth(3)
r.draw(win)

# create a circle
while True:

    key = win.checkKey()
    if key == 'q':
        break
    elif key == 'a':  # move left
        r.move(-20, 0)
    elif key == 'w':  # move up
        r.move(0, -20)
    elif key == 's':  # move down
        r.move(0, 20)
    elif key == 'd':  # move right
        r.move(20, 0)

    # y=0
    # c = gr.Circle( gr.Point( random.randint(0, 500), y ), 10 )
    # c.setFill('green')
    # c.draw( win ) # draw into the window
    #
Ejemplo n.º 23
0
def citywhale(x, y, scale):

    # define a polygon for the body, list of points
    bodylist = [
        gr.Point(x + 5 * scale,
                 y - 5 * scale),  # starts at lower left of the whale body
        gr.Point(x + 25 * scale, y - 2 * scale),
        gr.Point(x + 45 * scale, y - 8 * scale),
        gr.Point(x + 70 * scale, y - 15 * scale),
        gr.Point(x + 100 * scale, y - 6 * scale),
        gr.Point(x + 90 * scale, y - 20 * scale),
        gr.Point(x + 100 * scale, y - 34 * scale),
        gr.Point(x + 80 * scale, y - 25 * scale),
        gr.Point(x + 55 * scale, y - 27 * scale),
        gr.Point(x + 45 * scale, y - 30 * scale),
        gr.Point(x + 30 * scale, y - 30 * scale),
        gr.Point(x + 24 * scale, y - 27 * scale),
        gr.Point(x + 8 * scale, y - 24 * scale),
        gr.Point(x - 8 * scale, y - 25 * scale)
    ]
    whalebody = gr.Polygon(bodylist)
    whalebody.setFill("purple")
    whalebody.setOutline("dark blue")
    whalebody.setWidth(4)

    # define a polygon for the mouth
    mouthlist = [
        gr.Point(x + 24 * scale, y - 27 * scale),
        gr.Point(x + 8 * scale, y - 24 * scale),
        gr.Point(x - 8 * scale, y - 25 * scale),
        gr.Point(x + 8 * scale, y - 30 * scale)
    ]
    whalemouth = gr.Polygon(mouthlist)
    whalemouth.setFill("grey")
    whalemouth.setOutline("dark blue")
    whalemouth.setWidth(2)

    c1 = gr.Circle(gr.Point(x + 20 * scale, y - 20 * scale), 5)
    c1.setFill("black")

    # define four rectangles for the city
    b1 = gr.Rectangle(gr.Point(x + 30 * scale, y - 30 * scale),
                      gr.Point(x + 34 * scale, y - 44 * scale))
    b1.setFill('turquoise')

    b2 = gr.Rectangle(gr.Point(x + 34 * scale, y - 30 * scale),
                      gr.Point(x + 38 * scale, y - 50 * scale))
    b2.setFill('red')

    b3 = gr.Rectangle(gr.Point(x + 38 * scale, y - 30 * scale),
                      gr.Point(x + 42 * scale, y - 40 * scale))
    b3.setFill('green')

    b4 = gr.Rectangle(gr.Point(x + 42 * scale, y - 30 * scale),
                      gr.Point(x + 46 * scale, y - 38 * scale))
    b4.setFill('orange')

    # put all of these objects into a list
    whale = [whalebody, whalemouth, c1, b1, b2, b3, b4]

    # return the list
    return whale
Ejemplo n.º 24
0
def witch_init(x, y, scale):
    '''Creates and returns a list of graphics objects to make up a witch'''
    shapes = []

    #hat
    p = gr.Polygon(gr.Point(x, y - scale * 120),
                   gr.Point(x + scale * 25, y - scale * 80),
                   gr.Point(x - scale * 35, y - scale * 80),
                   gr.Point(x - scale * 35, y - scale * 70),
                   gr.Point(x + scale * 35, y - scale * 70),
                   gr.Point(x + scale * 35, y - scale * 80),
                   gr.Point(x - scale * 25, y - scale * 80))
    p.setFill(gr.color_rgb(30, 30, 30))
    shapes.append(p)

    #hatribbon
    p = gr.Polygon(gr.Point(x - scale * 25, y - scale * 80),
                   gr.Point(x - scale * 23, y - scale * 85),
                   gr.Point(x + scale * 23, y - scale * 85),
                   gr.Point(x + scale * 25, y - scale * 80))
    p.setFill(gr.color_rgb(128, 0, 128))
    shapes.append(p)

    #witch's hair
    r = gr.Rectangle(gr.Point(x - scale * 15, y - scale * 70),
                     gr.Point(x - scale * 25, y - scale * 30))
    r.setFill(gr.color_rgb(0, 0, 0))
    shapes.append(r)

    r = gr.Rectangle(gr.Point(x + scale * 25, y - scale * 70),
                     gr.Point(x + scale * 15, y - scale * 30))
    r.setFill(gr.color_rgb(0, 0, 0))
    shapes.append(r)

    r = gr.Rectangle(gr.Point(x - scale * 15, y - scale * 70),
                     gr.Point(x + scale * 15, y - scale * 60))
    r.setFill(gr.color_rgb(0, 0, 0))
    shapes.append(r)

    #witch's face
    r = gr.Rectangle(gr.Point(x - scale * 15, y - scale * 60),
                     gr.Point(x + scale * 15, y - scale * 40))
    r.setFill(gr.color_rgb(0, 205, 0))
    shapes.append(r)
    c = gr.Circle(gr.Point(x - scale * 10, y - scale * 50), 1)
    c.setFill(gr.color_rgb(0, 0, 0))
    shapes.append(c)
    c = gr.Circle(gr.Point(x + scale * 10, y - scale * 50), 1)
    c.setFill(gr.color_rgb(0, 0, 0))
    shapes.append(c)
    p = gr.Polygon(gr.Point(x, y - scale * 43),
                   gr.Point(x - scale * 3, y - scale * 47),
                   gr.Point(x + scale * 3, y - scale * 47))
    p.setFill(gr.color_rgb(255, 182, 193))
    shapes.append(p)

    #witch body
    p = gr.Polygon(gr.Point(x, y - scale * 40),
                   gr.Point(x - scale * 15, y + scale * 10),
                   gr.Point(x + scale * 15, y + scale * 10))
    p.setFill(gr.color_rgb(30, 30, 30))
    shapes.append(p)
    p = gr.Polygon(gr.Point(x, y - scale * 40),
                   gr.Point(x - scale * 15, y + scale * 10),
                   gr.Point(x - scale * 25, y + scale * 10))
    p.setFill(gr.color_rgb(128, 0, 128))
    shapes.append(p)
    p = gr.Polygon(gr.Point(x, y - scale * 40),
                   gr.Point(x + scale * 15, y + scale * 10),
                   gr.Point(x + scale * 25, y + scale * 10))
    p.setFill(gr.color_rgb(128, 0, 128))
    shapes.append(p)

    return shapes