-
Notifications
You must be signed in to change notification settings - Fork 1
/
other.py
130 lines (99 loc) · 3.44 KB
/
other.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import os
import PIL
from pygame import Surface
from pygame import image
from scene.geometry import Point
builtins = os.listdir("scene/Media")
print(builtins)
class Texture:
def __init__(self, im=None): # todo clean up, it a mess
if isinstance(im, Surface):
self.image = im
elif isinstance(im, str):
for start in builtins:
if im.startswith(start + ":"):
for file in os.listdir("scene/Media" + "/" + start):
if file.startswith(im[len(start) + 1:]):
im = "scene/Media/" + start + "/" + file
self.image = image.load(im)
elif isinstance(im, PIL.Image):
self.image = image.fromstring(image.tostring(), image.size, image.mode)
self.original = self.image
self.filtering_mode = 0 # todo implement and add constants
self.size = 0 # todo add geter
def subtexture(self, rect):
rect2 = self.original.get_rect()
return Texture(self.original.subsurface(
((rect[0]) * rect2[2], (1 - rect[1] - rect[3]) * rect2[3], rect[2] * rect2[2], rect[3] * rect2[3])))
class Action: # TODO make action class and implement it into nodes
def __init__(self, **args):
self._funk = self._call
self._parent = None
def _call(self):
pass
def _done(self):
pass
def _inter(self, p1, p2, t):
return
@classmethod
def call(cls, func, duration=0.5): # todo add
pass
@classmethod
def fade_by(cls, alpha, duration=0.5, timing_mode=None): # todo add # timeing mode
pass
@classmethod
def fade_to(cls, alpha, duration=0.5, timing_mode=None): # todo add
pass
@classmethod
def group(cls, *actions): # todo add
pass
@classmethod
def move_by(cls, dx, dy, duration=0.5, timing_mode=None): # todo add
pass
@classmethod
def move_to(cls, x, y, duration=0.5, timing_mode=None): # todo add
pass
@classmethod
def repeat(cls, action, repeat_count): # todo add
pass
@classmethod
def rotate_by(cls, radians, duration=0.5, timing_mode=None): # todo add
pass
@classmethod
def rotate_to(cls, radians, duration=0.5, timing_mode=None): # todo add
pass
@classmethod
def scale_by(cls, scale, duration=0.5, timing_mode=None): # todo add
pass
@classmethod
def scale_to(cls, scale, duration=0.5, timing_mode=None): # todo add
pass
@classmethod
def scale_x_to(cls, scale, duration=0.5, timing_mode=None): # todo add
pass
@classmethod
def scale_y_to(cls, scale, duration=0.5, timing_mode=None): # todo add
pass
@classmethod
def set_uniform(cls, name, value, duration=0.5, timing_mode=None): # todo add
pass
@classmethod
def sequence(cls, *actions): # todo add
pass
@classmethod
def wait(cls, wait_duration): # todo add
pass
class Touch(object):
def __init__(self, x, y, prev_x, prev_y, touch_id):
self.touch_id = touch_id
self.location = Point(x, y)
self.prev_location = Point(prev_x, prev_y)
self.layer = None
def __eq__(self, other_touch):
if not isinstance(other_touch, Touch):
return False
elif other_touch.touch_id == self.touch_id:
return True
return False
def __hash__(self):
return self.touch_id.__hash__()