import icons

class Soccerball:
    
    def __init__(self, p1, p2, color="black"):
    	self.ball = icons.Futbol(width=30, height=30,
                                 x=100-p2, y=p1, color=color)
    	self.points = [(p1, p2), (p2, p1),
                       (p1, 100-p2), (100-p2, p1)]
    	self.position = 0
        
    def change_location(self):
        self.ball.x = self.points[self.position][0]
        self.ball.y = self.points[self.position][1]
        self.position = self.position + 1

ball1 = Soccerball(50, 85)
ball2 = Soccerball(50, 15, color="red")
ball3 = Soccerball(20, 10, color="blue")
ball4 = Soccerball(60, 30, color="aquamarine")

for i in range(4):
    with animation(duration=0.8):
        ball1.change_location()
        ball2.change_location()
        ball3.change_location()
        ball4.change_location()

Object Example 4

by merrilyn

Created 4 years, 4 months ago.
Based on Object Example 4 by jamie.