-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
86 lines (80 loc) · 3.88 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
75
76
77
78
79
80
81
82
83
84
85
86
import spritekit as sk
from typing import override
@sk.main_scene
class TestScene(sk.Scene):
config = {
"width": 800,
"height": 600,
"title": "Test",
"exit_key": sk.Keys.escape,
"flags": sk.Flags.window_resizable,
"fps": 60
}
def add_stuff(self):
self.add_child(sk.RectangleNode(name="test",
width=100,
height=100,
color=sk.Color(1., 0, 0)))
self.add_child(sk.CircleNode(name="test",
position=sk.Vector2([100, 100]),
radius=100,
color=sk.Color(0, 1., 0)))
self.add_child(sk.TriangleNode(name="test",
position2=sk.Vector2([100, 200]),
position3=sk.Vector2([200, 100]),
color=sk.Color(0, 0, 1.)))
self.add_child(sk.SpriteNode(name="test",
texture=sk.Texture(f"assets/textures/LA.png"),
origin=sk.Vector2([1., 1.]),
scale=sk.Vector2([0.5, 0.5])))
def add_circle(self):
return sk.CircleNode(name="test",
radius=50,
color=sk.Color(1., 0, 1.))
@override
def enter(self):
self.add_child(sk.LabelNode(name="tset",
text="Hello, World!",
font_size=24,
color=sk.Color(1., 0., 1.)))
self.add_child(sk.MusicNode(name="bg",
music=sk.Music(f"assets/audio/country.mp3"),
auto_start=True))
self.add_child(sk.EmitterNode(emit=self.add_circle,
duration=1.))
self.add_child(sk.RectangleNode(name="poo",
width=50,
height=50,
color=sk.Color(.5, .5, 0)))
self.add_child(sk.ActionSequence([sk.WaitAction(duration=1.),
sk.ActionNode(target=250.,
easing_fn=sk.ease_bounce_in_out,
field="position.y",
actor=self.find_child("poo")),
sk.WaitAction(duration=1.),
sk.ActionNode(target=0.,
easing_fn=sk.ease_bounce_in_out,
field="position.y",
actor=self.find_child("poo"))],
repeat=True))
self.add_child(sk.EmitterNode(emit=(sk.CircleNode,
{'name': 'test',
'radius': 25,
'color': sk.Color(1., 1., 0.)}),
duration=.5))
self.add_stuff()
@override
def step(self, delta):
if sk.Keyboard.key_pressed("r"):
if self.find_children("test"):
self.remove_children("test")
else:
self.add_stuff()
if sk.Keyboard.key_pressed("space"):
for child in self.find_children("bg"):
child.toggle()
for child in self.children("test"):
child.position.x += 100 * delta
for child in self.children("tset"):
child.rotation += 100 * delta
super().step(delta)