Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. import random
  2. from random import *
  3.  
  4. import pygame
  5. from OpenGL.GL import *
  6. from OpenGL.GLU import *
  7. from pygame.locals import *
  8.  
  9. going_left = False
  10. x_pos = 100
  11.  
  12. def init_game():
  13. pygame.display.init()
  14. pygame.display.set_mode((800, 600), DOUBLEBUF | OPENGL)
  15. glClearColor(0.0, 1.0, 0.1, 0.0)
  16.  
  17.  
  18. def update():
  19. pass
  20.  
  21.  
  22. def display():
  23. glMatrixMode(GL_PROJECTION)
  24. glLoadIdentity()
  25. glMatrixMode(GL_MODELVIEW)
  26. glLoadIdentity()
  27. glViewport(0, 0, 800, 600)
  28. gluOrtho2D(0, 800, 0, 600)
  29. glColor3f(0.5, 1.0, 1.0)
  30. glBegin(GL_TRIANGLES)
  31. glVertex2f(100, 100)
  32. glVertex2f(100, 200)
  33. glVertex2f(200, 100)
  34. glEnd()
  35. pygame.display.flip()
  36.  
  37.  
  38. def game_loop():
  39. for event in pygame.event.get():
  40. if event.type == pygame.QUIT:
  41. pygame.quit()
  42. quit()
  43. elif event.type == pygame.KEYDOWN:
  44. if event.key == K_ESCAPE:
  45. pygame.quit()
  46. quit()
  47. elif event.key == K_q:
  48. glClearColor(random(), random(), random(), 1.0)
  49.  
  50. update()
  51. display()
  52.  
  53.  
  54. if __name__ == "__main__":
  55. init_game()
  56. while True:
  57. game_loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement