Skip to content

Instantly share code, notes, and snippets.

@tmngtk
Created September 11, 2009 14:53

Revisions

  1. tomonaga revised this gist Sep 11, 2009. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion pyglet and psyco.py
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    import pyglet
    from pyglet.gl import *
    import psyco
    import time

    FRAME_RATE = 60
    USE_FULL_SCREEN = False
    @@ -19,8 +20,9 @@ def on_resize(width, height):
    glLoadIdentity()
    gluOrtho2D(0, 1, 0, 1)

    INITIAL_TIME = time.time()
    def update(dt):
    frame = int((time.time() - initial_time) * FRAME_RATE)
    frame = int((time.time() - INITIAL_TIME) * FRAME_RATE)
    # do something
    pyglet.clock.schedule_interval(update, FRAME_RATE)

  2. tomonaga revised this gist Sep 11, 2009. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions pyglet and psyco.py
    Original file line number Diff line number Diff line change
    @@ -24,10 +24,13 @@ def update(dt):
    # do something
    pyglet.clock.schedule_interval(update, FRAME_RATE)

    fps_display = pyglet.clock.ClockDisplay()

    @window.event
    def on_draw():
    window.clear()
    # do something
    fps_display.draw()

    psyco.cannotcompile(on_resize)
    psyco.cannotcompile(on_draw)
  3. tomonaga revised this gist Sep 11, 2009. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions pyglet and psyco.py
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,9 @@
    import psyco

    FRAME_RATE = 60
    USE_FULL_SCREEN = False

    window = pyglet.window.Window(fullscreen=USE_FULL_SCREEN)

    @window.event
    def on_resize(width, height):
  4. tomonaga revised this gist Sep 11, 2009. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions pyglet and psyco.py
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,8 @@
    from pyglet.gl import *
    import psyco

    FRAME_RATE = 60

    @window.event
    def on_resize(width, height):
    global SCREEN_WIDTH, SCREEN_HEIGHT
    @@ -14,9 +16,15 @@ def on_resize(width, height):
    glLoadIdentity()
    gluOrtho2D(0, 1, 0, 1)

    def update(dt):
    frame = int((time.time() - initial_time) * FRAME_RATE)
    # do something
    pyglet.clock.schedule_interval(update, FRAME_RATE)

    @window.event
    def on_draw():
    window.clear()
    # do something

    psyco.cannotcompile(on_resize)
    psyco.cannotcompile(on_draw)
  5. tomonaga created this gist Sep 11, 2009.
    23 changes: 23 additions & 0 deletions pyglet and psyco.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    import pyglet
    from pyglet.gl import *
    import psyco

    @window.event
    def on_resize(width, height):
    global SCREEN_WIDTH, SCREEN_HEIGHT
    SCREEN_WIDTH = width
    SCREEN_HEIGHT = height
    glViewport(0, 0, width, height)
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    gluOrtho2D(0, 1, 0, 1)

    @window.event
    def on_draw():
    window.clear()

    psyco.cannotcompile(on_resize)
    psyco.cannotcompile(on_draw)
    psyco.full()