from random import * from kandinsky import * from time import * class Point(): def __init__(self,coords,vect,colors): self.coords=coords self.vect=vect self.colors=colors self.color_act=[0,1] def draw(self): fill_rect(self.coords[0]-5,self.coords[1]-5,10,10,tuple(self.colors)) def move(self): self.coords[0]+=self.vect[0] self.coords[1]+=self.vect[1] def rejump(self): if not 0<self.coords[0]<320: self.vect[0]*=-1 if not 0<self.coords[1]<220: self.vect[1]*=-1 def change_color(self): self.colors[self.color_act[0]]+=self.color_act[1] def change_action(self): if self.colors[self.color_act[0]]==[None,255,0][self.color_act[1]]: self.color_act[1]*=-1 while True: r=(self.color_act[0]+2)%3 if self.colors[r]==[None,0,255][self.color_act[1]]: self.color_act[0]=r break p=Point([0,0],[1,1],[230,0,255]) fill_rect(0,0,320,222,(0,)*3) while True: p.move() p.draw() p.rejump() p.change_color() p.change_action() sleep(0.01)