Skip to content

Instantly share code, notes, and snippets.

@davepape
Created September 12, 2013 03:07
Show Gist options
  • Save davepape/6532661 to your computer and use it in GitHub Desktop.
Save davepape/6532661 to your computer and use it in GitHub Desktop.
a triangle with one animated vertex
# 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