mapobj decoratemap(levelobj['mapobj']levelobj['startstate']['player'] gamestateobj copy deepcopy(levelobj['startstate'] mapneedsredraw true set to true to call drawmap( levelsurf basicfont render('level % of % (levelobj['levelnum' totalnumoflevels) textcolor levelrect levelsurf get_rect( levelrect bottomleft ( winheight mapwidth len(mapobjtilewidth mapheight (len(mapobj[ ] (tileheight tilefloorheighttileheight max_cam_x_pan abs(half_winheight int(mapheight )tilewidth max_cam_y_pan abs(half_winwidth int(mapwidth )tileheight leveliscomplete false track how much the camera has moved cameraoffsetx cameraoffsety track if the keys to move the camera are being held down cameraup false cameradown false cameraleft false cameraright false while truemain game loop reset these variables playermoveto none keypressed false for event in pygame event get()event handling loop if event type =quit player clicked the "xat the corner of the window terminate( elif event type =keydown handle key presses keypressed true if event key =k_left playermoveto left elif event key =k_right playermoveto right elif event key =k_up playermoveto up elif event key =k_down playermoveto down email questions to the authoral@inventwithpython com