@paul_craven/

Pyglet example

Pygame

No description

fork
loading
Files
  • main.py
  • nohup.out

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.09258264392719595","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"U0NSRUVOX1dJRFRIID0gNjQwClNDUkVFTl9IRUlHSFQgPSA0ODAKCmltcG9ydCBweWdsZXQKZnJvbSBweWdsZXQuZ2wgaW1wb3J0ICoKZnJvbSBweWdsZXQgaW1wb3J0IGNsb2NrCmltcG9ydCB0aW1lCgpjbGFzcyBNeUdhbWUocHlnbGV0LndpbmRvdy5XaW5kb3cpOgoKICAgIGRlZiBfX2luaXRfXyhzZWxmLCB3aWR0aCwgaGVpZ2h0KToKICAgICAgICBjb25maWcgPSBDb25maWcoc2FtcGxlX2J1ZmZlcnM9MSwKICAgICAgICAgICAgICAgICAgICAgICAgc2FtcGxlcz0xNiwKICAgICAgICAgICAgICAgICAgICAgICAgZG91YmxlX2J1ZmZlcj1UcnVlKQoKICAgICAgICBzdXBlcigpLl9faW5pdF9fKHdpZHRoLCBoZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWc9Y29uZmlnKQogICAgICAgIGdsRW5hYmxlKEdMX01VTFRJU0FNUExFX0FSQikKCiAgICBkZWYgb25fZHJhdyhzZWxmKToKICAgICAgICBwcmludCgiT2siKQogICAgICAgICMgYXJjYWRlLnN0YXJ0X3JlbmRlcigpCgogICAgICAgIHNpemUgPSBzZWxmLmhlaWdodCAvIDQKICAgICAgICAjIGdsQ2xlYXIoR0xfQ09MT1JfQlVGRkVSX0JJVCkKICAgICAgICAjIGdsRW5hYmxlKEdMX0JMRU5EKQogICAgICAgICMgZ2xCbGVuZEZ1bmMoR0xfU1JDX0FMUEhBLCBHTF9PTkVfTUlOVVNfU1JDX0FMUEhBKQoKICAgICAgICBnbExvYWRJZGVudGl0eSgpCiAgICAgICAgZ2xUcmFuc2xhdGVmKHNlbGYud2lkdGgvMiwgc2VsZi5oZWlnaHQvMiwgMCkKICAgICAgICBnbFJvdGF0ZWYoNSwgMCwgMCwgMSkKCiAgICAgICAgZ2xDb2xvcjNmKDEsIDAsIDApCiAgICAgICAgZ2xCZWdpbihHTF9RVUFEUykKICAgICAgICBnbFZlcnRleDJmKC1zaXplLCAtc2l6ZSkKICAgICAgICBnbFZlcnRleDJmKHNpemUsIC1zaXplKQogICAgICAgIGdsVmVydGV4MmYoc2l6ZSwgc2l6ZSkKICAgICAgICBnbFZlcnRleDJmKC1zaXplLCBzaXplKQogICAgICAgIGdsRW5kKCkKCgoKZGVmIG1haW4oKToKICAgICIiIiBNYWluIG1ldGhvZCAiIiIKICAgIHdpbmRvdyA9IE15R2FtZShTQ1JFRU5fV0lEVEgsIFNDUkVFTl9IRUlHSFQpCgogICAgIyB3aGlsZSBUcnVlOgogICAgIyAgICAgd2luZG93Lm9uX2RyYXcoKQogICAgIyAgICAgd2luZG93LmZsaXAoKQogICAgIyAgICAgd2luZG93LmRpc3BhdGNoX2V2ZW50cygpCiAgICBweWdsZXQuYXBwLnJ1bigpCgoKaWYgX19uYW1lX18gPT0gIl9fbWFpbl9fIjoKICAgIG1haW4oKQo="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
SCREEN_WIDTH = 640
SCREEN_HEIGHT = 480

import pyglet
from pyglet.gl import *
from pyglet import clock
import time

class MyGame(pyglet.window.Window):

    def __init__(self, width, height):
        config = Config(sample_buffers=1,
                        samples=16,
                        double_buffer=True)

        super().__init__(width, height,
                         config=config)
        glEnable(GL_MULTISAMPLE_ARB)

    def on_draw(self):
        print("Ok")
        # arcade.start_render()

        size = self.height / 4
        # glClear(GL_COLOR_BUFFER_BIT)
        # glEnable(GL_BLEND)
        # glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

        glLoadIdentity()
        glTranslatef(self.width/2, self.height/2, 0)
        glRotatef(5, 0, 0, 1)

        glColor3f(1, 0, 0)
        glBegin(GL_QUADS)
        glVertex2f(-size, -size)
        glVertex2f(size, -size)
        glVertex2f(size, size)
        glVertex2f(-size, size)
        glEnd()



def main():
    """ Main method """
    window = MyGame(SCREEN_WIDTH, SCREEN_HEIGHT)

    # while True:
    #     window.on_draw()
    #     window.flip()
    #     window.dispatch_events()
    pyglet.app.run()


if __name__ == "__main__":
    main()