MCPcopy Create free account
hub / github.com/Blakkis/PyGLMaze / mainloop

Method mainloop

pymaze/main.py:117–163  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

115
116
117 def mainloop(self):
118 while 1:
119 delta = self.clock.tick(self.d_max_fps) / 1000.0
120 seconds = pygame.time.get_ticks() / 1000.0
121
122 glClearColor(0.0, 0.0, 0.0, 1.0)
123 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
124
125 for event in pygame.event.get():
126 if (event.type == QUIT) or (event.type == KEYUP and event.key == K_ESCAPE):
127 pygame.quit()
128 sys.exit()
129
130 if (event.type == KEYUP) and (event.key == K_LEFT):
131 PPostTypes.changeShader(-1)
132
133 if (event.type == KEYUP) and (event.key == K_RIGHT):
134 PPostTypes.changeShader(1)
135
136 # --------
137
138 self.player.update(delta, self.camera, self.maze.aabb_walls)
139 self.camera.updateCamera(delta, self.player.getPosition())
140
141 # --------
142
143 # All draw commands should go between the begin/end clause for them to appear on the framebuffer textures
144
145 self.post.begin()
146
147 self.maze.renderMaze(self.camera, False, self.skybox.skybox_shadow)
148 self.skybox.renderSkybox(self.camera)
149
150 # Draw all debug lines last
151 PWDebug.drawDebug(self.camera)
152
153 self.post.end(seconds, self.camera)
154
155 found_portal = self.portal.render(self.camera, seconds, self.post.getColorAttachment(), self.post.getDepthAttachment())
156
157 if found_portal and not self.final_time:
158 self.final_time = pygame.time.get_ticks() - self.time_start
159 seconds = int(self.final_time / 1000.0)
160 print("Solved in: ({0})!".format(str(datetime.timedelta(seconds=seconds))))
161
162 pygame.display.set_caption("FPS: {0:.2f}".format(self.clock.get_fps()))
163 pygame.display.flip()
164
165
166if __name__ == "__main__":

Callers 1

main.pyFile · 0.80

Calls 12

changeShaderMethod · 0.80
updateMethod · 0.80
updateCameraMethod · 0.80
renderMazeMethod · 0.80
renderSkyboxMethod · 0.80
drawDebugMethod · 0.80
getColorAttachmentMethod · 0.80
getDepthAttachmentMethod · 0.80
getPositionMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
renderMethod · 0.45

Tested by

no test coverage detected