-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.py
More file actions
84 lines (75 loc) · 1.64 KB
/
demo.py
File metadata and controls
84 lines (75 loc) · 1.64 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import spritePro as s
import pygame
# Initialize the library
s.init()
# Create a window
s.get_screen((800, 600), "My Game")
circle = pygame.Surface((100, 100), pygame.SRCALPHA)
pygame.draw.circle(
circle,
(130, 255, 70),
(50, 50),
radius=45,
)
had = s.Sprite(
circle,
size=(100, 100),
pos=s.WH_C,
speed=3,
)
had.set_scale(5)
had.rect.centery -= 50
had.update()
circle = pygame.Surface((100, 100), pygame.SRCALPHA)
pygame.draw.circle(circle, (255, 255, 255), (50, 50), radius=45)
eye = s.Sprite(
circle,
size=(70, 70),
pos=(300, 150),
)
eye.set_parent(had)
circle = pygame.Surface((100, 100), pygame.SRCALPHA)
pygame.draw.circle(circle, (255, 255, 255), (50, 50), radius=45)
eye = s.Sprite(
circle,
size=(70, 70),
pos=(500, 150),
)
eye.set_parent(had)
circle = pygame.Surface((100, 100), pygame.SRCALPHA)
pygame.draw.circle(circle, (255, 255, 255), (50, 50), radius=45, width=10)
smile = s.Sprite(
circle,
size=(100, 100),
pos=s.WH_C,
)
smile.set_parent(had)
# tweenColor
tm_player = s.TweenManager()
tm_player.add_tween(
name="color",
start_value=0,
end_value=255,
duration=0.7,
easing=s.EasingType.EASE_OUT,
loop=True,
yoyo=True,
delay=0,
on_update=lambda x, sprite=smile: sprite.set_color((100, int(x), 100)),
)
tm_player.add_tween(
name="scale",
start_value=1,
end_value=2.5,
duration=0.7,
easing=s.EasingType.EASE_OUT,
loop=True,
yoyo=True,
delay=0,
on_update=lambda x, sprite=smile: sprite.set_scale(x),
)
# Main game loop
while True:
s.update(fill_color=(0, 0, 100))
tm_player.update()
had.handle_keyboard_input()