Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- from random import *
- import pygame
- from OpenGL.GL import *
- from OpenGL.GLU import *
- from pygame.locals import *
- going_left = False
- x_pos = 100
- def init_game():
- pygame.display.init()
- pygame.display.set_mode((800, 600), DOUBLEBUF | OPENGL)
- glClearColor(0.0, 1.0, 0.1, 0.0)
- def update():
- pass
- def display():
- glMatrixMode(GL_PROJECTION)
- glLoadIdentity()
- glMatrixMode(GL_MODELVIEW)
- glLoadIdentity()
- glViewport(0, 0, 800, 600)
- gluOrtho2D(0, 800, 0, 600)
- glColor3f(0.5, 1.0, 1.0)
- glBegin(GL_TRIANGLES)
- glVertex2f(100, 100)
- glVertex2f(100, 200)
- glVertex2f(200, 100)
- glEnd()
- pygame.display.flip()
- def game_loop():
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- quit()
- elif event.type == pygame.KEYDOWN:
- if event.key == K_ESCAPE:
- pygame.quit()
- quit()
- elif event.key == K_q:
- glClearColor(random(), random(), random(), 1.0)
- update()
- display()
- if __name__ == "__main__":
- init_game()
- while True:
- game_loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement