Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pyglet as pgl
- from pyglet.gl import *
- from pyglet.window import key, mouse
- import math as m
- W = 900
- H = 600
- win = pgl.window.Window(W, H, "Lab 1", resizable=True)
- win.set_minimum_size(300, 200)
- glTranslatef(W/2, H/2, 0)
- @win.event
- def on_draw():
- glClear(GL_COLOR_BUFFER_BIT)
- glColor3f(0, 255, 255)
- glBegin(GL_TRIANGLES)
- glVertex2f(0, H/4)
- glVertex2f(-W/4, -H/4)
- glVertex2f(W/4, -H/4)
- glEnd()
- @win.event
- def on_resize(width, height):
- glViewport(0, 0, width, height)
- @win.event
- def on_key_press(symbol, modifiers):
- if symbol == key.RIGHT:
- glTranslatef(66, 0, 0)
- elif symbol == key.LEFT:
- glTranslatef(-66, 0, 0)
- elif symbol == key.UP:
- glTranslatef(0, 66, 0)
- elif symbol == key.DOWN:
- glTranslatef(0, -66, 0)
- @win.event
- def on_mouse_press(x, y, button, modifiers):
- if button == mouse.LEFT:
- glScalef(1.1, 1.1, 0)
- if button == mouse.RIGHT:
- glScalef(0.9, 0.9, 0)
- def update(dt):
- pass
- pgl.clock.schedule_interval(update, 1/60)
- pgl.app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement