def __init__(self): """ Sets all the variables to control the Solar System. Such as the rotation speed or if the light or textures are on or off. Also all the textures are loaded here and saved as Objects. """ # control variables self.r_speed = 1 self.light = False self.textures = False self.stop = False # camera controlling self.mid = True self.top = False self.bot = False self.cam_y = 25. self.cam_z = -25. # planet textures i = LoadImages() self.sun_tex = i.load("pics/sunmap.jpg") self.earth_tex = i.load("pics/earthmap.jpg") self.moon_tex = i.load("pics/moonmap.jpg") self.mars_tex = i.load("pics/marsmap.jpg") self.saturn_tex = i.load("pics/saturnmap.jpg") # button textures self.b1_tex = i.load("pics/b1.jpg") self.b2_tex = i.load("pics/b2.jpg") self.legend_tex = i.load("pics/legend.jpg") self.rb1_tex = i.load("pics/rb1.jpg") self.rb2_tex = i.load("pics/rb2.jpg") # speed of the different planets self.earth_r_speed = 0 self.moon_r_speed = 0 self.mars_r_speed = 0 self.saturn_r_speed = 0 self.saturn_ring_speed = -1*self.r_speed # mouse coordinates self.x = .0 self.y = .0
def main(): pygame.init() display = (1600, 900) pygame.display.set_mode(display, DOUBLEBUF | OPENGL) glShadeModel(GL_SMOOTH) glClearColor(.0, .0, .0, .0) glClearDepth(1.0) glEnable(GL_DEPTH_TEST) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(30, (display[0]/display[1]), 1.0, 50.0) #glTranslatef(.0, 0.0, -10.0) #glRotatef(45, 1, 0, 0) glMatrixMode(GL_MODELVIEW) glLoadIdentity() gluLookAt(.0, 25, -10.0, .0, .0, .0, .0, 1.0, .0) glutInit() rotate = 1 i = LoadImages() texture = i.load("../planets/pics/earthmap.jpg") q = gluNewQuadric() p1 = Sphere(1.0, 30, 30, q) while True: for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_UP: rotate += 1 if event.key == pygame.K_DOWN: rotate -= 1 if event.type == pygame.QUIT: pygame.quit() quit() glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glRotatef(rotate, .0, 1.0, .0) # glDisable(GL_LIGHTING) i.place_image(texture) # glutSolidSphere(1.0, 30, 30) # p1.draw_sphere() glPushMatrix() glRotatef(270, 1., .0, .0) p1.draw_sphere2() glPopMatrix() # p1.light() # repaint pygame.display.flip() pygame.time.wait(10)