-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__main__.py
206 lines (143 loc) · 5.36 KB
/
__main__.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
import wrap_py.ru as wru
from wrap_py import world, event, sprite, text_sprite
from wrap_py.ru import programma
# app.set_fps(100)
programma.ustanovit_fps(100)
world.create_world(1000, 1000)
world.set_world_background_color([10, 20, 30])
# sp1_id = sprite.add_sprite("type2", 600, 600, True, n"1")
sp1_id = sprite.add_text(600, 600, "Ха Ха Ха", text_color=[255, 255, 255])
sp2_id = sprite.add_sprite("type2", 600, 600, False, "man1")
sp_mark_id = sprite.add_sprite("type3", 500, 500, True)
def on_right_clicked(key, unicode):
sprite.set_bottom_to(sp1_id, 100)
def on_left_clicked(keys):
sprite.set_top_to(sp1_id, 100)
width = 100
def _show_sprite_size(id):
x, y = sprite.get_sprite_size(id)
xpr, ypr = sprite.get_sprite_size_proc(id)
# print('width: ' + str(x) + " pix / " + str(xpr) + "%")
# print('height: ' + str(y) + " pix / " + str(ypr) + "%")
def _check_collision(id1, id2):
res = sprite.sprites_collide(id1, id2)
if res:
sprite.move_sprite_to(sp_mark_id, res[0], res[1])
sprite.show_sprite(sp_mark_id)
else:
sprite.hide_sprite(sp_mark_id)
def _check_collision_any(id1, id_list):
res = sprite.sprites_collide_any(id1, id_list)
# print(res)
def _check_collision_all(id1, id_list):
if sprite.sprite_exists(id1):
res = sprite.sprites_collide_all(id1, id_list)
# print(res)
def on_up_clicked(control_keys):
global width
width += 5
if wru.KMOD_SHIFT in control_keys:
sprite.change_sprite_height_proc(sp1_id, width)
else:
from_modified = wru.KMOD_ALT in control_keys
if from_modified:
sprite.change_sprite_size_by_proc(sp1_id, 105)
else:
sprite.change_sprite_size_proc(sp1_id, width, width)
_show_sprite_size(sp1_id)
def on_down_clicked(control_keys):
global width
width -= 5
if wru.KMOD_SHIFT in control_keys:
sprite.change_sprite_height_proc(sp1_id, width)
else:
from_modified = wru.KMOD_ALT in control_keys
if from_modified:
sprite.change_sprite_size_by_proc(sp1_id, 95)
else:
sprite.change_sprite_size_proc(sp1_id, width, width)
_show_sprite_size(sp1_id)
def on_zero_clicked():
sprite.set_sprite_original_size(sp1_id)
def on_space_clicked(key, unicode, dasfg):
global sp1_id, sp2_id
t = sp1_id
sp1_id = sp2_id
sp2_id = t
size_diff = 1
def on_one_clicked(control_keys):
global size_diff
apply_proc_size = wru.KMOD_SHIFT not in control_keys
sprite.set_previous_costume(sp1_id, True, apply_proc_size)
if text_sprite.is_sprite_text(sp1_id):
s = text_sprite.get_angle(sp1_id)
if s==None:
s=45
elif s==45:
s =215
else:
s = None
text_sprite.set_angle(sp1_id, s)
# print(text_sprite.get_angle(sp1_id))
_show_sprite_size(sp1_id)
def on_two_clicked():
flipx = sprite.get_sprite_flipx_reverse(sp1_id)
sprite.set_sprite_flipx_reverse(sp1_id, not flipx)
def on_three_clicked():
flipy = sprite.get_sprite_flipy_reverse(sp1_id)
sprite.set_sprite_flipy_reverse(sp1_id, not flipy)
def on_four_clicked():
if not sprite.is_sprite_visible(sp1_id):
sprite.show_sprite(sp1_id)
else:
sprite.hide_sprite(sp1_id)
def on_five_clicked():
pass
def on_six_clicked():
pass
def on_w_clicked():
a = sprite.get_sprite_angle(sp1_id)
sprite.set_sprite_angle(sp1_id, a + 5)
def on_s_clicked():
a = sprite.get_sprite_angle(sp1_id)
sprite.set_sprite_angle(sp1_id, a - 5)
def on_d_clicked():
sprite.move_sprite_to_angle(sp1_id, 10)
def on_a_clicked():
sprite.move_sprite_to_angle(sp1_id, -10)
def on_del_clicked():
sprite.remove_sprite(sp1_id)
def on_sec1():
# print(sprite.get_sprite_final_angle(sp1_id))
_check_collision_all(sp1_id, [sp2_id, sp_mark_id])
def on_sec2():
sprite.move_sprite_by(-20, 0)
def on_mouse_pressed(pos):
# sprite.move_sprite_to_point(sp1_id, pos[0], pos[1], 3)
sprite.rotate_to_point(sp1_id, pos[0], pos[1])
sprite.move_sprite_to_angle(sp1_id, 30)
# left_id = event.on_key_down(wru.K_LEFT, on_left_clicked)
# left_id = event.on_key_pressed([wru.K_LEFT, wru.K_RIGHT], on_left_clicked, 100, [wru.KMOD_LALT, wru.KMOD_RSHIFT])
right_id = event.on_key_down(wru.K_RIGHT, on_right_clicked)
left_id = event.on_key_down(wru.K_LEFT, on_left_clicked)
up_id = event.on_key_down(wru.K_UP, on_up_clicked)
down_id = event.on_key_down(wru.K_DOWN, on_down_clicked)
space_id = event.on_key_down(wru.K_SPACE, on_space_clicked)
zero_id = event.on_key_down(wru.K_0, on_zero_clicked)
one_id = event.on_key_down(wru.K_1, on_one_clicked)
two_id = event.on_key_down(wru.K_2, on_two_clicked)
three_id = event.on_key_down(wru.K_3, on_three_clicked)
four_id = event.on_key_down(wru.K_4, on_four_clicked)
five_id = event.on_key_down(wru.K_5, on_five_clicked)
six_id = event.on_key_down(wru.K_6, on_six_clicked)
w_id = event.on_key_down(wru.K_w, on_w_clicked)
s_id = event.on_key_down(wru.K_s, on_s_clicked)
d_id = event.on_key_down(wru.K_d, on_d_clicked)
a_id = event.on_key_down(wru.K_a, on_a_clicked)
del_id = event.on_key_down(wru.K_DELETE, on_del_clicked)
# close_id = event.on_close(on_close)
sec_id1 = event.on_timeout(50, 0, on_sec1)
# sec_id2 = event.on_timeout(1000, 5, on_sec2)
mouse_pressed_id = event.on_mouse_pressed([0], on_mouse_pressed, 100)
# app.start()
programma.zapusk()