import pygame
from screen import *


#----------------------------------------------------------------------
class Point:
  def __init__(self,name,x,y):
    self.name = name
    self.x = x
    self.y = y
 
  def __str__(self):
    return self.name + ":" + str(self.x) + "," + str(self.y)
 
  def draw(self,screen,pos):
    return pygame.draw.circle(screen,(0,0,0),pos,10,0)
 
  def move(self,dx,dy):
    self.x = self.x + dx
    self.y = self.y + dy

  def jump(self,x,y):
    print str(self), " \n jumps to ..."
    self.move(x - self.x, y - self.y)
    print str(self)


#----------------------------------------------------------------------

points = []

p1 = Point("p1",50,50)
p2 = Point("p2",100,200)

points1 = [p1, p2]
#go(points)















#----------------------------------------------------------------------
class ColorPoint(Point):
  color = (0,0,255)
  
  def setColor(self,color):
    self.color = color

  def __str__(self):
    return Point.__str__(self) + " color : " + str(self.color)

  def draw(self,screen,pos):
    return pygame.draw.circle(screen,self.color,pos,10,0)






#---------------------------------------------------------------------


p3 = ColorPoint("p3",300,300)
p3.setColor((0,255,0))
p4 = ColorPoint("p4",250,200)
p4.setColor((0,0,255))

points2 = points1 + [p3,p4]
#go(points2)






#----------------------------------------------------------------------
class ColorBox(ColorPoint):
  height = 20
  width = 30 
  
  def setHeight(self,h):
    self.height = h

  def setWidth(self,w):
    self.width = w

  def draw(self,screen,pos):
    x,y = (pos[0] + self.width),(pos[1] + self.height) 
    r = pygame.draw.line(screen,self.color,pos,(x,y))
    return pygame.draw.rect(screen,self.color,r)
  
  def __str__(self):
    return ColorPoint.__str__(self) + " width: " + str(self.width) + " height : " + str(self.height)



#----------------------------------------------------------------------



p5 = ColorBox("p5",200,200)
p5.setColor((100,100,100))
p5.setWidth(50)


p6 = ColorBox("p5",200,200)
p6.setColor((200,100,0))
p6.setHeight(50)


points3 = points2 + [p5,p6] 

#go(points)







#----------------------------------------------------------------------
class TextPoint(Point):
  text = ""
  def setText(self,text):
    self.text = text
  
  def draw(self,screen,pos):
    return write(screen,self.text,pos)

  def __str__(self):
    return Point.__str__(self) + " text: " + str(self.text)

#----------------------------------------------------------------------


p7 = TextPoint("p6",200,200)
p7.setText("SUN GOD FESTIVAL!")
points4 = points3 + [p7]
#go(points)



#----------------------------------------------------------------------

class ColorTextBox(ColorBox,TextPoint):
  def draw(self,screen,pos):
    ColorBox.draw(self,screen,pos)
    r=TextPoint.draw(self,screen,pos)
    return r

  def __str__(self):
    return ColorBox.__str__(self) + " text: " + str(self.text)
           #str(self)

#----------------------------------------------------------------------

p8 = ColorTextBox("p7",200,200)
p8.setText("Splash-o-Color")
p8.setColor((0,0,255))

points5 = points4 + [p8]
#go(points)


#----------------------------------------------------------------------

#factories

##def addPoints(c,base=0,n=4):
##  newpoints = [c(base+i,0,0) for i in range(n)]
##  points.append(newpoints)
##  go(points)
##
##addPoints(Point)
##
##addPoints(ColorPoint)
##
##addPoints(ColorBox)
##
##addPoints(ColorTextBox)
