Пример #1
0
def main(argv=sys.argv):
    import py2exeeggs
    py2exeeggs.loadEggs()

    pygame.init()
    pygame.display.set_mode((SCREEN_WIDTH,SCREEN_HEIGHT),OPENGL|DOUBLEBUF)
    gl_init((SCREEN_WIDTH,SCREEN_HEIGHT))
    pygame.display.set_caption('pyogl-test prototype')
    
    letter_texture, letter_map = map_letters()
    letter_texture_id = makeTexture(pygame.image.tostring(letter_texture,"RGBA",1), letter_texture.get_width(), letter_texture.get_height())

    keys_down = {}
    move_speed = 5
    ticks = 0
    curtex = 0
    object_pos = [0,0]
    
    start_time = time.time()
    frames = 0
    CameraPos = [0,0,0]
    
    while True: # The Full Game Loop
        for event in (pygame.event.get()):
            if event.type == QUIT:
                sys.exit()
            if event.type == KEYDOWN:
                if event.key == K_ESCAPE:
                    sys.exit()
                else:
                    keys_down[event.key] = 1
            if event.type == KEYUP:
                del keys_down[event.key]
        if K_UP in keys_down:
            CameraPos[1] -= move_speed
        if K_DOWN in keys_down:
            CameraPos[1] += move_speed
        if K_LEFT in keys_down:
            CameraPos[0] -= move_speed
        if K_RIGHT in keys_down:
            CameraPos[0] += move_speed
        # 2d
        #pygame.display.update()
        # 3d

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        glLoadIdentity()
        
        # Camera Position/Orient
        #glRotatef(-CameraRotate[1],1,0,0)
        #glRotatef( CameraRotate[0],0,1,0)
        glTranslatef(CameraPos[0],-CameraPos[1],0)
        
        text=   ['This string is the best string ever.',
                 'But this string is also alright.',
                 'Don\'t discount this string in your evaluation.',
                 'This string should not be considered.',
                 'This string is the best string ever as well.',
                 'This string is cool sometimes but not right now.',
                 'This screen has a lot of words on it.',
                 'This string is filling up space.',
                 'This string is well within your polygon budget',
                 'Only a fool would enjoy coding this project.']
        i = 0
        for word in text:
            gl_drawword(letter_map, letter_texture_id, word, i)
            i += 30

        pygame.display.flip()
        
        # ticks += 1
        # if (ticks % 10) == 0:
            # curtex += 1
            # curtex %= len(quads)
            
        frames += 1
        if (frames % 100) == 0:
            print "fps: " + str(frames/(time.time() - start_time))
Пример #2
0
#!/usr/bin/python
import sys, os

#py2exe openglfix
if sys.platform[:3] == 'win':
    sys.path.insert(
        0,
        os.path.join(
            os.path.dirname( sys.executable ),
            'PyOpenGL-3.0.0a6-py2.4.egg'
        )
    )
    sys.path.append("scripts/py2exe/");
    import py2exeeggs
    py2exeeggs.loadEggs()


from engine3d import Engine3d
from engine3d.games import Tetris3d

e = Engine3d()
game = Tetris3d()
e.run( game )
Пример #3
0
def main(argv=sys.argv):
    import py2exeeggs
    py2exeeggs.loadEggs()

    pygame.init()
    pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT), OPENGL | DOUBLEBUF)
    gl_init((SCREEN_WIDTH, SCREEN_HEIGHT))
    pygame.display.set_caption('pyogl-test prototype')

    letter_texture, letter_map = map_letters()
    letter_texture_id = makeTexture(
        pygame.image.tostring(letter_texture, "RGBA", 1),
        letter_texture.get_width(), letter_texture.get_height())

    keys_down = {}
    move_speed = 5
    ticks = 0
    curtex = 0
    object_pos = [0, 0]

    start_time = time.time()
    frames = 0
    CameraPos = [0, 0, 0]

    while True:  # The Full Game Loop
        for event in (pygame.event.get()):
            if event.type == QUIT:
                sys.exit()
            if event.type == KEYDOWN:
                if event.key == K_ESCAPE:
                    sys.exit()
                else:
                    keys_down[event.key] = 1
            if event.type == KEYUP:
                del keys_down[event.key]
        if K_UP in keys_down:
            CameraPos[1] -= move_speed
        if K_DOWN in keys_down:
            CameraPos[1] += move_speed
        if K_LEFT in keys_down:
            CameraPos[0] -= move_speed
        if K_RIGHT in keys_down:
            CameraPos[0] += move_speed
        # 2d
        #pygame.display.update()
        # 3d

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        glLoadIdentity()

        # Camera Position/Orient
        #glRotatef(-CameraRotate[1],1,0,0)
        #glRotatef( CameraRotate[0],0,1,0)
        glTranslatef(CameraPos[0], -CameraPos[1], 0)

        text = [
            'This string is the best string ever.',
            'But this string is also alright.',
            'Don\'t discount this string in your evaluation.',
            'This string should not be considered.',
            'This string is the best string ever as well.',
            'This string is cool sometimes but not right now.',
            'This screen has a lot of words on it.',
            'This string is filling up space.',
            'This string is well within your polygon budget',
            'Only a fool would enjoy coding this project.'
        ]
        i = 0
        for word in text:
            gl_drawword(letter_map, letter_texture_id, word, i)
            i += 30

        pygame.display.flip()

        # ticks += 1
        # if (ticks % 10) == 0:
        # curtex += 1
        # curtex %= len(quads)

        frames += 1
        if (frames % 100) == 0:
            print "fps: " + str(frames / (time.time() - start_time))