Advertisement
Guest User

Untitled

a guest
May 26th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. def main():
  2. pygame.init()
  3.  
  4. window_width = 1920
  5. window_height = 1080
  6. aspect_ratio = window_width/window_height
  7. fps = 60
  8. clock = pygame.time.Clock()
  9. running = True
  10.  
  11. pygame.display.set_mode([window_width, window_height], DOUBLEBUF | OPENGL | FULLSCREEN)
  12. pygame.display.set_caption("Minecraft Clone")
  13. window_width, window_height = pygame.display.get_surface().get_size()
  14. pygame.event.set_grab(True)
  15. pygame.mouse.set_visible(False)
  16.  
  17. # OPEN_GL STUFF
  18. #
  19. #
  20. # OPEN_GL STUFF
  21.  
  22. while running:
  23. current_frame = pygame.time.get_ticks()
  24. delta_time = current_frame - last_frame
  25. last_frame = current_frame
  26. last_cam_pos = 0
  27.  
  28. camera_speed = .01 * delta_time
  29.  
  30. keys_pressed = pygame.key.get_pressed()
  31.  
  32. # Keyboard
  33. if keys_pressed[K_w]:
  34. camera_position += camera_speed * camera_front
  35. camera_position[1] = last_cam_pos
  36. if keys_pressed[K_s]:
  37. camera_position -= camera_speed * camera_front
  38. camera_position[1] = last_cam_pos
  39. if keys_pressed[K_a]:
  40. camera_position -= vector.normalise(vector3.cross(np.array(camera_front, dtype=np.float32), np.array([0., 1., 0.], dtype=np.float32))) * camera_speed
  41. if keys_pressed[K_d]:
  42. camera_position += vector.normalise(vector3.cross(np.array(camera_front, dtype=np.float32), np.array([0., 1., 0.], dtype=np.float32))) * camera_speed
  43. if keys_pressed[K_SPACE]:
  44. camera_position[1] += camera_speed
  45. last_cam_pos = camera_position[1]
  46. if keys_pressed[K_LSHIFT]:
  47. camera_position[1] -= camera_speed
  48. last_cam_pos = camera_position[1]
  49.  
  50. # Mouse
  51. mouse_x, mouse_y = pygame.mouse.get_pos()
  52. x_offset = mouse_x - last_x
  53. y_offset = last_y - mouse_y
  54.  
  55. last_x = mouse_x
  56. last_y = mouse_y
  57.  
  58. x_offset *= mouse_sensitivity
  59. y_offset *= mouse_sensitivity
  60.  
  61. for event in pygame.event.get():
  62. if event.type == QUIT:
  63. running = False
  64. elif event.type == KEYDOWN:
  65. if event.key == K_ESCAPE:
  66. running = False
  67.  
  68. # MORE OPEN_GL STUFF
  69. #
  70. #
  71. #
  72. #
  73.  
  74. pygame.display.flip()
  75. clock.tick(fps)
  76.  
  77. pygame.quit()
  78. sys.exit()
  79.  
  80. if __name__ == "__main__":
  81. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement