Mercurial > touhou
annotate data/ST/make_stage.py @ 119:fad7b44cebf2
Switch from pygame + PyOpenGL to pyglet
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Wed, 07 Sep 2011 18:12:24 +0200 |
parents | 1ec8be40880f |
children | 4300a832f033 |
rev | line source |
---|---|
115 | 1 from pytouhou.formats.std import Stage, Model |
2 from pytouhou.formats.anm0 import Animations | |
3 from pytouhou.vm.anmrunner import ANMRunner | |
4 from pytouhou.game.sprite import Sprite | |
5 from pytouhou.resource.anmwrapper import AnmWrapper | |
6 from pytouhou.opengl.sprite import get_sprite_rendering_data | |
7 | |
8 ground = Model(quads=[(14, -100.0, -46*3, 0.5, (192+100)*2, 46*3), | |
9 (0, 192.0 - 40, -46.0, 0.0, 0, 0), | |
10 (0, 192.0 - 40, -46.0*2, 0.0, 0, 0), | |
11 (0, 192.0 - 40, -46.0*3, 0.0, 0, 0), | |
12 (11, -100.0, -46*3, 0.0, 220, 46*3), | |
13 (11, 192*2+100.0-220, -46*3, 0.0, 220, 46*3), | |
14 (12, 120.0, -46*3, -0.1, 0, 46*3), | |
15 (13, 192*2-120-14, -46*3, -0.1, 0, 46*3)]) | |
16 | |
17 tree = Model(quads=[(9, 0.0, 0.0, 0.0, 0, 0)]) | |
18 tree2 = Model(quads=[(10, 0.0, 0.0, 0.0, 0, 0)]) | |
19 | |
20 models = [ground, tree, tree2] | |
21 | |
22 | |
23 instances = [(0, 0.0, -46*3*-1, 0.0), | |
24 (0, 0.0, -46*3*0, 0.0), | |
25 (0, 0.0, -46*3*1, 0.0), | |
26 (0, 0.0, -46*3*2, 0.0), | |
27 (0, 0.0, -46*3*3, 0.0), | |
28 (0, 0.0, -46*3*4, 0.0), | |
29 (0, 0.0, -46*3*5, 0.0), | |
30 (0, 0.0, -46*3*6, 0.0), | |
31 (0, 0.0, -46*3*7, 0.0), | |
32 (0, 0.0, -46*3*8, 0.0), | |
33 #Trees | |
34 (1, 40.0, -46*3*1, -50.0), | |
35 (1, 40.0, -46*3*2, -50.0), | |
36 (1, 40.0, -46*3*3, -50.0), | |
37 (1, 40.0, -46*3*4, -50.0), | |
38 (1, 40.0, -46*3*5, -50.0), | |
39 (1, 40.0, -46*3*6, -50.0), | |
40 | |
41 (1, 40.0+40, -46*3*1-20, -50.0), | |
42 (1, 40.0+40, -46*3*2-20, -50.0), | |
43 (1, 40.0+40, -46*3*3-20, -50.0), | |
44 (1, 40.0+40, -46*3*4-20, -50.0), | |
45 (1, 40.0+40, -46*3*5-20, -50.0), | |
46 (1, 40.0+40, -46*3*6-20, -50.0), | |
47 | |
48 (2, 192*2-30-40.0, -46*3*1, -50.0), | |
49 (2, 192*2-30-40.0, -46*3*2, -50.0), | |
50 (2, 192*2-30-40.0, -46*3*3, -50.0), | |
51 (2, 192*2-30-40.0, -46*3*4, -50.0), | |
52 (2, 192*2-30-40.0, -46*3*5, -50.0), | |
53 (2, 192*2-30-40.0, -46*3*6, -50.0), | |
54 | |
55 (2, 192*2-30-40.0-50.0, -46*3*1-20, -50.0), | |
56 (2, 192*2-30-40.0-50.0, -46*3*2-20, -50.0), | |
57 (2, 192*2-30-40.0-50.0, -46*3*3-20, -50.0), | |
58 (2, 192*2-30-40.0-50.0, -46*3*4-20, -50.0), | |
59 (2, 192*2-30-40.0-50.0, -46*3*5-20, -50.0), | |
60 (2, 192*2-30-40.0-50.0, -46*3*6-20, -50.0)] | |
61 | |
62 | |
63 # Bounding boxes | |
64 anm_wrapper = AnmWrapper([Animations.read(open('stg1bg.anm', 'rb'))]) | |
65 for model in models: | |
66 vertices = [] | |
67 for script_index, ox2, oy2, oz2, width_override, height_override in model.quads: | |
68 sprite = Sprite() | |
69 anmrunner = ANMRunner(anm_wrapper, script_index, sprite) | |
70 anmrunner.run_frame() | |
71 sprite.update() | |
72 key, (vertices2, uvs2, colors2) = get_sprite_rendering_data(sprite) | |
73 vertices.extend((x + ox2, y + oy2, z + oz2) for x, y, z in vertices2) | |
74 xmin, ymin, zmin = min(x for x, y, z in vertices), min(y for x, y, z in vertices), min(z for x, y, z in vertices) | |
75 xmax, ymax, zmax = max(x for x, y, z in vertices), max(y for x, y, z in vertices), max(z for x, y, z in vertices) | |
76 model.bounding_box = (xmin, ymin, zmin, xmax - xmin, ymax - ymin, zmax - zmin) | |
77 | |
78 | |
79 stage = Stage() | |
80 stage.name = 'Test by ThibG' | |
117
1ec8be40880f
[Data] Fix a crash with 102h.exe (missing music), and fix bullet sizes
Thibaut Girka <thib@sitedethib.com>
parents:
115
diff
changeset
|
81 stage.bgms = ('', 'bgm/th06_15.mid'), ('', ''), ('', ''), ('', '') |
115 | 82 stage.models = models |
83 stage.object_instances = instances | |
84 stage.script = [(0, 1, (50, 0, 50, 300.0, 800.0)), | |
85 (0, 2, (0.0, 400.0, 0.3)), | |
86 (0, 0, (0.0, 0.0, 0.0)), | |
87 (1600, 0, (0.0, -600.0, 0.0)), | |
88 (6500, 0, (0.0, -600.0, 0.0))] | |
89 | |
90 with open('stage1.std', 'wb') as file: | |
91 stage.write(file) | |
92 |