-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathmain_pygame_simple.py
63 lines (49 loc) · 1.62 KB
/
main_pygame_simple.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
import os
import pygame
# import live2d.v3 as live2d
import live2d.v2 as live2d
import resources
def main():
pygame.init()
live2d.init()
display = (300, 400)
pygame.display.set_mode(display, pygame.DOUBLEBUF | pygame.OPENGL)
pygame.display.set_caption("pygame window")
live2d.glewInit()
model = live2d.LAppModel()
if live2d.LIVE2D_VERSION == 3:
model.LoadModelJson(
os.path.join(resources.RESOURCES_DIRECTORY, "v3/Haru/Haru.model3.json")
)
else:
model.LoadModelJson(
os.path.join(resources.RESOURCES_DIRECTORY,
# "v2/kasumi2/kasumi2.model.json"
# "v2/haru/haru.model.json"
"v2/托尔/model0.json"
# "v2/kana/Kobayaxi.model.json"
# "v2/shizuku/shizuku.model.json"
)
)
model.Resize(*display)
running = True
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
break
elif event.type == pygame.MOUSEMOTION:
model.Drag(*pygame.mouse.get_pos())
elif event.type == pygame.MOUSEBUTTONUP:
model.SetRandomExpression()
model.StartRandomMotion()
if not running:
break
live2d.clearBuffer()
model.Update()
model.Draw()
pygame.display.flip()
live2d.dispose()
pygame.quit()
if __name__ == "__main__":
main()