##################################
#offroadwarrior
#physik
##################################

#dependency
##################################
import ball, spring

#function
##################################

#none left



                

#test code
##################################

if __name__ == "__main__":
        import pyg, math
        
        ballLst = []
        springLst = []
        center = ball.ball(250,250)
        ballLst.append(center)
        r = 0.0
        l = 5
        c,e = None,None
        first = None
        first2 = None
        for i in range(5):
                r = i*2*math.pi/l
                x = (math.sin(r) * 50)+center.x
                y = (math.cos(r) * 50)+center.y
                b = ball.ball(x,y)
                x = (math.sin(r) * 60)+center.x
                y = (math.cos(r) * 60)+center.y
                d = ball.ball(x,y)
                ballLst.append(b)
                ballLst.append(d)
                springLst.append(spring.new(center,b))
                springLst.append(spring.new(b,d))
                if c:
                        springLst.append(spring.new(b,c))
                        springLst.append(spring.new(d,e))
                        springLst.append(spring.new(c,d))
                else:
                        first = b
                        first2 = d
                c = b
                e = d
        springLst.append(spring.new(c,first))
        springLst.append(spring.new(e,first2))
        springLst.append(spring.new(c,first2))

        while pyg.main():
                for i in ballLst:
                        ball.reset_force(i)
                        
                for i in springLst:
                        spring.force(i)
                        
                        

                        
                for i in ballLst:
                        ball.gravity(i)
                        ball.viscous_drag(i)    
                        ball.terminal_force(i)          

                for i in ballLst:
                        ball.move(i)             
                        ball.terminal_velocity(i)
                      
                        ball.wall(i,pyg.width,pyg.height)

                        pyg.circle(i.x,i.y)

                for i in springLst:
                        pyg.line(i.b1.x, i.b1.y, i.b2.x, i.b2.y)

                
                        
