#Imports
import pygame
from pygame.locals import *

from OpenGL.GL import *
from OpenGL.GLU import *

from shapes import Shape, Cube

#Create a game class
class Game(object):
	
	#Constructor
	def __init__(self, title, width, height, bgcolour):
		
		#Initialise pygame
		pygame.init()
		
		#Set the window caption
		pygame.display.set_caption(title)

		#Set the size of the window
		self.size = self.width, self.height = width, height
		
		#Set the default perspective and clipping distances
		self.fov = 45.0
		self.aspectratio = width / height
		self.minrender = 0.1
		self.maxrender = 80
		
		#Set the pygame mode to use double buffering and open gl
		pygame.set_mode(self.size, DOUBLEBUF|OPENGL)
		
		#Set the perspective
		self.setperspective()
		
		#Create an empty list of shapes to render
		self.shapes = []
		
	#Create a function to update the perspective
	def setperspective(self):
		
		#Set the perspective
		gluPerspective(self.fov, self.aspectratio, self.minrender, self.maxrender)
		
	#Create a function to add a shape
	def addshape(self, s):
		self.shapes.append(s)
		
	#Create a function to render the shapes
	def render(self):
		#For each of the shapes, check the type and render it
		for s in shapes:
			#If the shape is a cube, call the rendercube method
			if s.type == Shape.CUBE:
				rendercube(s)
				
	#Create a function to render a cube
	def rendercube(self, cube):
	
		#Start the gl drawing specifying a type of lines
		glBegin(GL_QUADS)
		
		#Set the colour
		glColor3fv((1, 0, 1))
		
		#For each of the surfaces
		for surface in cube.surfaces:
			#For each of the vertices in the surface
			for vertex in surface:
				#Draw the vertex
				glVertex3fv(cube.vertices[vertex])
				
		#End the gl drawinf
		glEnd()
		
		#Start the gl drawing specifying a type of lines
		glBegin(GL_LINES)
		
		#Set the colour
		glColor3fv((1, 1, 1))
		
		#For each of the edges
		for edge in cube.edges:
			#For each of the vertices in the edge
			for vertex in edge:
				#Draw the vertex
				glVertex3fv(cube.vertices[vertex])
				
		#End the gl drawing
		glEnd()

@@ -2057,16 +2057,365 @@
 awing%0A%09%09glEnd()%0A
+%09%09%0A%09#Create a function to update the game state%0A%09def update(self):%0A%09%09%0A%09%09#Exit condition%0A%09%09for event in pygame.event.get():%0A%09%09%09if event.type == pygame.QUIT:%0A%09%09%09%09pygame.quit()%0A%09%09%09%09quit()%0A%09%09%09%09%0A%09%09#Clear the buffers%0A%09%09glClear(GL_COLOR_BUFFER_BIT%7CGL_DEPTH_BUFFER_BIT)%0A%09%09%0A%09%09#Draw the shapes%0A%09%09render()%0A%09%09%0A%09%09#Update the display%0A%09%09pygame.display.flip()%0A%09%09%0A%09%0A

Write update function to render the shapes and clear the screen each frame.