import turtle as t
import random as r
s = t.Screen()
#s.tracer(0)

#MAKE BG!!!!!!!!!!!!!!!!!!!!
t.speed(0)
#t.screensize(9000,9000)
t.bgcolor("black")
t.hideturtle()
t.pencolor("white")
for i in range(30):
  rand_x = r.randint(-8900,8900)
  rand_y = r.randint(-8900,8900)
  t.pu()
  t.goto(rand_x, rand_y)
  t.pd()
  t.dot(3)

class planet(): #PLANET CLASS
  def __init__(self, name, color, planet_r, orbit_r, place, speed):
      self.name = name
      self.color = color
      self.planet_r = planet_r
      self.orbit_r = orbit_r
      self.place = place
      self.speed = speed

  def make_planet(self, planet_t): #FUNCTION TO MAKE THE PLANET
    planet_t.speed(0)
    planet_t.shape("circle")
    planet_t.color(self.color)
    planet_t.shapesize(self.planet_r)

    planet_t.pu()
    planet_t.hideturtle()
    planet_t.goto(0,-self.orbit_r)
    planet_t.showturtle()
    planet_t.pd()
    planet_t.pensize(1)
    planet_t.pencolor("white")
    planet_t.write(self.name)
    planet_t.pencolor(self.color)
    planet_t.circle(self.orbit_r)
    planet_t.pu()
    planet_t.circle(self.orbit_r, self.place)
    
#SUN !!
t.pu()
t.goto(0,-268)
t.pd()
t.color("#f5ce42") #beautiful pineapple color
t.begin_fill()
t.circle(268)
t.end_fill()

#SCALE KEY (ITS IN THE SUN)
t.pu()
t.goto(-200,-50)
t.pd()
t.color("#915429")
t.write("Scale Factors: \nPlanet Radius: 1 px = 425 km\nSun Radius: 1 px = 5200 km\nDistance from Sun: 1 px = 0.01 AU", font = ['Arial', 16, 'normal'])

#MERCURY
mer_inst = planet("Mercury","#848587", 6/10, 268+38, 0, 47.9/7) 
mercury = t.Turtle()
mer_inst.make_planet(mercury)

#VENUS
ven_inst = planet("Venus","#b56722", 14/10, 268+72, 275, 35/7) 
venus = t.Turtle()
ven_inst.make_planet(venus)

#EARTH :D
ear_inst = planet("Earth", "#6e84db", 15/10, 268+100, 335, 29.8/7)
earth = t.Turtle()
ear_inst.make_planet(earth)

#MARS 
mar_inst = planet("Mars", "#b53524", 8/10, 268+150, 300, 24.1/7)
mars = t.Turtle()
mar_inst.make_planet(mars)

#JUPITER
jup_inst = planet("Jupiter", "#d1845a", 168/10, 268+520, 127, 13.1/7)
jupiter = t.Turtle()
jup_inst.make_planet(jupiter)

#SATURN !!
sat_inst = planet("Saturn", "#b3a666", 142/10, 268+950, 75, 9.7/7)
saturn = t.Turtle()
sat_inst.make_planet(saturn)
#saturn's rings


#URANUS
ura_inst = planet("Uranus", "#c5effa", 61/10, 268+1920, 145, 6.8/7)
uranus = t.Turtle()
ura_inst.make_planet(uranus)

#NEPTUNE !!!!!!!!!!!!!!!!!!!!
nep_inst = planet("Neptune", "#4854d9", 58/10, 268+3010, 87, 5.4/7)
neptune = t.Turtle()
nep_inst.make_planet(neptune)

#s.update()
#s.mainloop() 

#ORBIT ANIMATION
while True:
  mercury.circle(mer_inst.orbit_r, mer_inst.speed)
  venus.circle(ven_inst.orbit_r, ven_inst.speed)
  earth.circle(ear_inst.orbit_r, ear_inst.speed)
  mars.circle(mar_inst.orbit_r, mar_inst.speed)
  jupiter.circle(jup_inst.orbit_r, jup_inst.speed)
  saturn.circle(sat_inst.orbit_r, sat_inst.speed)
#  satRing.circle(inst_satRing.orbit_r, inst_satRing.speed)
  uranus.circle(ura_inst.orbit_r, ura_inst.speed)
  neptune.circle(nep_inst.orbit_r, nep_inst.speed)
