Mercurial > touhou
comparison pytouhou/games/sample/enemies.py @ 599:d471b07ce4fd
Add a sample Python ECL.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 25 Oct 2014 18:52:21 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
598:a7286a0facf9 | 599:d471b07ce4fd |
---|---|
1 # -*- encoding: utf-8 -*- | |
2 ## | |
3 ## Copyright (C) 2014 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | |
4 ## | |
5 ## This program is free software; you can redistribute it and/or modify | |
6 ## it under the terms of the GNU General Public License as published | |
7 ## by the Free Software Foundation; version 3 only. | |
8 ## | |
9 ## This program is distributed in the hope that it will be useful, | |
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 ## GNU General Public License for more details. | |
13 ## | |
14 | |
15 from math import radians | |
16 from pytouhou.vm import spawn_enemy | |
17 from pytouhou.game import NextStage | |
18 | |
19 | |
20 def disk(enemy, game): | |
21 if enemy.frame == 0: | |
22 enemy.set_anim(0) | |
23 | |
24 enemy.set_hitbox(32, 32) | |
25 | |
26 enemy.death_anim = 1 | |
27 | |
28 enemy.update_mode = 0 | |
29 enemy.angle, enemy.speed = radians(90), 1.5 | |
30 | |
31 elif enemy.frame == 10000: | |
32 enemy.removed = True | |
33 | |
34 | |
35 def boss(enemy, game): | |
36 if enemy.frame == 0: | |
37 enemy.set_anim(3) | |
38 enemy.set_hitbox(8, 32) | |
39 enemy.death_flags = 1 | |
40 enemy.set_boss(True) | |
41 | |
42 enemy.timeout = 20 * 60 | |
43 enemy.timeout_callback.enable(some_spellcard, (enemy, game)) | |
44 | |
45 enemy.low_life_trigger = 0x40 | |
46 enemy.low_life_callback.enable(some_spellcard, (enemy, game)) | |
47 | |
48 elif enemy.frame == 10000: | |
49 enemy.removed = True | |
50 | |
51 if enemy.frame % 10 == 0: | |
52 enemy.set_bullet_attributes(67, 0, 0, 3 if game.spellcard is not None else 1, 1, 6., 6., 0., radians(3), 0) | |
53 | |
54 | |
55 def some_spellcard(enemy, game): | |
56 enemy.life = 0x40 | |
57 enemy.difficulty_coeffs = (-.5, .5, 0, 0, 0, 0) | |
58 game.change_bullets_into_star_items() | |
59 game.spellcard = (42, 'Some Spellcard', 0) | |
60 game.enable_spellcard_effect() | |
61 | |
62 enemy.timeout = 10 * 60 | |
63 enemy.timeout_callback.enable(on_boss_death, (enemy, game)) | |
64 enemy.death_callback.enable(on_boss_death, (enemy, game)) | |
65 enemy.low_life_callback.disable() | |
66 | |
67 | |
68 def on_boss_death(enemy, game): | |
69 enemy.timeout_callback.disable() | |
70 enemy.death_callback.disable() | |
71 game.disable_spellcard_effect() | |
72 enemy.removed = True | |
73 | |
74 raise NextStage | |
75 | |
76 | |
77 def stage1(game): | |
78 if game.frame == 0x10: | |
79 spawn_enemy(game, disk, x=50., y=-32., life=20, score=300) | |
80 elif game.frame == 0x20: | |
81 spawn_enemy(game, disk, x=60., y=-32., life=20, score=300) | |
82 elif game.frame == 0x30: | |
83 spawn_enemy(game, disk, x=70., y=-32., life=20, score=300) | |
84 elif game.frame == 0x40: | |
85 spawn_enemy(game, disk, x=80., y=-32., life=20, score=300) | |
86 elif game.frame == 0x50: | |
87 spawn_enemy(game, disk, x=90., y=-32., life=20, score=300) | |
88 elif game.frame == 0x60: | |
89 spawn_enemy(game, disk, x=100., y=-32., life=20, score=300) | |
90 elif game.frame == 0x100: | |
91 spawn_enemy(game, boss, x=192., y=64., life=1000, item=-2, score=10000) |