Created
September 12, 2013 03:07
-
-
Save davepape/6532661 to your computer and use it in GitHub Desktop.
a triangle with one animated vertex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# animtriangle.py | |
# by Dave Pape, for DMS 423 | |
# | |
# draws a triangle with one moving vertex | |
from pyglet.gl import * | |
window = pyglet.window.Window() | |
vlist = pyglet.graphics.vertex_list(3, ('v2f', [0,0, 400,50, 200,300])) | |
@window.event | |
def on_draw(): | |
glClear(pyglet.gl.GL_COLOR_BUFFER_BIT) | |
glColor3f(1,0,0) | |
vlist.draw(GL_TRIANGLES) | |
direction = -1 | |
def update(dt): | |
global direction | |
vlist.vertices[4] += direction | |
if vlist.vertices[4] < 0: | |
direction = 1 | |
elif vlist.vertices[4] > 300: | |
direction = -1 | |
pyglet.clock.schedule_interval(update,1/60.0) | |
pyglet.app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment