-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiao.py
More file actions
68 lines (61 loc) · 1.98 KB
/
diao.py
File metadata and controls
68 lines (61 loc) · 1.98 KB
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
# -*- coding: utf-8 -*-
from main import *
c = Chang(jie)
if __name__ == '__main__':
class number(Role):
@try_except()
def __init__(self, chang: Chang) -> None:
super().__init__(chang)
Render(self)
self.__render: Render = self.get_component("render")[0]
self.__font = pygame.font.SysFont("Arial", 20)
self.__text = self.__font.render("0", True, (0, 0, 0))
self.__render.set_image(self.__text)
self.__i = 0
@try_except()
def update(self):
super().update()
self.__i += 1
self.__text = self.__font.render(str(self.__i), True, (0, 0, 255))
self.__render.set_image(self.__text)
class a(Role):
@try_except()
def update(self) -> None:
super().update()
# self.chang.ray_detection(tuple(self.cos), (0, 1), 100, 'a')
# print(self.get_component("collision")[0].collision_thing)
print(self.chang.ray_detection(tuple(self.cos), (0, 1), 100, 'a'))
if self.chang.get_mouse_down(1):
self.cos = self.chang.get_mouse_pos()
# c.add_collision_rule('a','normal',False)
# c.add_collision_rule('normal','normal',False)
red = Surface((1000, 100))
red.fill(Color(255, 0, 0))
ro = Role(c)
re = Render(ro)
co = Collision(ro)
co.size = Ve2(1000, 100)
# co.friction = 1
co.elasticity = 2
co.elasticity = 0.9
ro.cos = Ve2(0, 300)
# co.rotation = True
re.set_image(red)
c.camera.change_father(ro)
ro2 = number(c)
ro2.cos = Ve2(0, 0)
blue = Surface((100, 100))
blue.fill(Color(0, 0, 255))
ro2 = a(c)
ro2.cos = Ve2(200, -400)
re2 = Render(ro2)
co2 = Collision(ro2)
co2.elasticity = 1
# co2.friction = 1
co2.size = Ve2(100, 100)
co.body_type = pymunk.Body.STATIC
co.apply_impulse((0, -1000))
print(co.velocity)
re2.set_image(blue)
jie.change_chang(c)
start()