annotate pytouhou/games/sample/enemies.py @ 611:a6a191e371c7

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