-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
74 lines (59 loc) · 2.5 KB
/
test.py
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#from pgui import *
from pyglet.gl import *
from pyglet_gui import *
from random import randint
class circle(genericShape):
def __init__(self, *args, **kwargs):
## TODO: Add batch
super(circle, self).__init__('GL_TRIANGLES', *args, **kwargs)
self.set_color(gfx.hex_to_colorpair(gfx.colors['tea_green'])*int(len(self.vertices)/2))
def update(self):
self.move(randint(-1, 1), randint(-1, 1))
class smilyface(genericSprite):
def __init__(self, *args, **kwargs):
super(smilyface, self).__init__(*args, **kwargs)
self.pixel(5, 15, b'\xff\x00\x00\xff')
self.pixel(10, 15, b'\xff\x00\x00\xff')
self.pixel(2, 8, b'\xff\x00\x00\xff')
self.pixel(2, 7, b'\xff\x00\x00\xff')
self.pixel(3, 6, b'\xff\x00\x00\xff')
self.pixel(4, 5, b'\xff\x00\x00\xff')
self.pixel(5, 5, b'\xff\x00\x00\xff')
self.pixel(6, 5, b'\xff\x00\x00\xff')
self.pixel(7, 5, b'\xff\x00\x00\xff')
self.pixel(8, 5, b'\xff\x00\x00\xff')
self.pixel(9, 5, b'\xff\x00\x00\xff')
self.pixel(10, 5, b'\xff\x00\x00\xff')
self.pixel(11, 5, b'\xff\x00\x00\xff')
self.pixel(12, 5, b'\xff\x00\x00\xff')
self.pixel(13, 6, b'\xff\x00\x00\xff')
self.pixel(14, 7, b'\xff\x00\x00\xff')
self.pixel(14, 8, b'\xff\x00\x00\xff')
class testButton(genericInteractive):
def __init__(self, *args, **kwargs):
if not 'theme' in kwargs: kwargs['theme'] = 'default'
if not 'debug' in kwargs: kwargs['debug'] = False
genericInteractive.__init__(self, *args, **kwargs)
def click(self, *args, **kwargs):
print('I am a test button!')
class window(windowWrapper):
def __init__(self):
super(window, self).__init__(vsync=False, debug=True, log=True, fps=True)
self.add_sprite('circle', circle(x=int(self.width/2), y=int(self.height/2), alpha=0))
self.add_sprite('smilyface', smilyface(x=100, y=200, width=20, height=20, alpha=0))
self.add_sprite('webimage', resources.image_from_url('https://hvornum.se/favicon.ico', x=self.width-64, y=self.height-64))
self.add_sprite('button', testButton(label='щракни ми', x=64, y=self.height-64))
def key_E(self, *args, **kwargs):
self.sprites['webimage'].rotate(0.5)
def key_Q(self, *args, **kwargs):
self.sprites['webimage'].rotate(-0.5)
def key_W(self, symbol, event, modifiers, *args, **kwargs):
self.camera.move(0, 1)
def key_S(self, symbol, event, modifiers, *args, **kwargs):
self.camera.move(0, -1)
def key_D(self, symbol, event, modifiers, *args, **kwargs):
self.camera.move(1, 0)
def key_A(self, symbol, event, modifiers, *args, **kwargs):
self.camera.move(-1, 0)
W = window()
W.run()