annotate pytouhou/games/eosd.py @ 234:3cbfa2c11dec

Fix instructions 69 and 71.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 31 Dec 2011 03:08:01 +0100
parents 067f6d9c562b
children e59bd7979ddc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 # -*- encoding: utf-8 -*-
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2 ##
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 ## Copyright (C) 2011 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
4 ##
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5 ## This program is free software; you can redistribute it and/or modify
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6 ## it under the terms of the GNU General Public License as published
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7 ## by the Free Software Foundation; version 3 only.
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 ##
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9 ## This program is distributed in the hope that it will be useful,
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12 ## GNU General Public License for more details.
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 ##
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14
206
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
15 from pytouhou.utils.interpolator import Interpolator
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17 from pytouhou.game.game import Game
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
18 from pytouhou.game.bullettype import BulletType
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
19 from pytouhou.game.itemtype import ItemType
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
20 from pytouhou.game.player import Player
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
21 from pytouhou.game.bullet import Bullet
199
8ec34c56fed0 Implement orbs.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 197
diff changeset
22 from pytouhou.game.orb import Orb
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
23
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
24 from math import pi
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
25
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
26
220
0595315d3880 Fix SHT handling; change a few things to be closer to ZUN’s mind; and first stub of PCB support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 216
diff changeset
27 SQ2 = 2. ** 0.5 / 2.
0595315d3880 Fix SHT handling; change a few things to be closer to ZUN’s mind; and first stub of PCB support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 216
diff changeset
28
0595315d3880 Fix SHT handling; change a few things to be closer to ZUN’s mind; and first stub of PCB support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 216
diff changeset
29
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30 class EoSDGame(Game):
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
31 def __init__(self, resource_loader, player_states, stage, rank, difficulty, **kwargs):
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
32 etama3 = resource_loader.get_anm_wrapper(('etama3.anm',))
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
33 etama4 = resource_loader.get_anm_wrapper(('etama4.anm',))
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
34 bullet_types = [BulletType(etama3, 0, 11, 14, 15, 16, hitbox_size=4),
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
35 BulletType(etama3, 1, 12, 17, 18, 19, hitbox_size=6),
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36 BulletType(etama3, 2, 12, 17, 18, 19, hitbox_size=4),
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 BulletType(etama3, 3, 12, 17, 18, 19, hitbox_size=6),
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38 BulletType(etama3, 4, 12, 17, 18, 19, hitbox_size=5),
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39 BulletType(etama3, 5, 12, 17, 18, 19, hitbox_size=4),
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
40 BulletType(etama3, 6, 13, 20, 20, 20, hitbox_size=16),
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
41 BulletType(etama3, 7, 13, 20, 20, 20, hitbox_size=11),
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
42 BulletType(etama3, 8, 13, 20, 20, 20, hitbox_size=9),
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
43 BulletType(etama4, 0, 1, 2, 2, 2, hitbox_size=32)]
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
44 #TODO: hitbox
197
e1bc8c4cbb1a Do the right action when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 196
diff changeset
45 item_types = [ItemType(etama3, 0, 7), #Power
e1bc8c4cbb1a Do the right action when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 196
diff changeset
46 ItemType(etama3, 1, 8), #Point
e1bc8c4cbb1a Do the right action when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 196
diff changeset
47 ItemType(etama3, 2, 9), #Big power
e1bc8c4cbb1a Do the right action when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 196
diff changeset
48 ItemType(etama3, 3, 10), #Bomb
e1bc8c4cbb1a Do the right action when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 196
diff changeset
49 ItemType(etama3, 4, 11), #Full power
e1bc8c4cbb1a Do the right action when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 196
diff changeset
50 ItemType(etama3, 5, 12), #1up
e1bc8c4cbb1a Do the right action when collecting an item.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 196
diff changeset
51 ItemType(etama3, 6, 13)] #Star
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
52
229
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
53 characters = resource_loader.get_eosd_characters('102h.exe')
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
54
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
55 players = []
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
56 for player in player_states:
229
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
57 players.append(EoSDPlayer(player, self, resource_loader, sht=characters[player.character]))
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
58
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
59 Game.__init__(self, resource_loader, players, stage, rank, difficulty,
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
60 bullet_types, item_types, nb_bullets_max=640, **kwargs)
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
61
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
62
206
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
63
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
64 class EoSDPlayer(Player):
229
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
65 def __init__(self, state, game, resource_loader, speeds=None, hitbox_size=2.5, graze_hitbox_size=42., sht=None):
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
66 self.sht = sht
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
67 anm_wrapper = resource_loader.get_anm_wrapper(('player0%d.anm' % (state.character // 2),))
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
68 self.anm_wrapper = anm_wrapper
206
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
69
229
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
70 Player.__init__(self, state, game, anm_wrapper,
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
71 speeds=(self.sht.horizontal_vertical_speed,
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
72 self.sht.diagonal_speed,
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
73 self.sht.horizontal_vertical_focused_speed,
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
74 self.sht.diagonal_focused_speed))
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
75
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
76 self.orbs = [Orb(self.anm_wrapper, 128, self.state, None),
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
77 Orb(self.anm_wrapper, 129, self.state, None)]
206
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
78
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
79 self.orbs[0].offset_x = -24
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
80 self.orbs[1].offset_x = 24
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
81
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
82 self.orb_dx_interpolator = None
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
83 self.orb_dy_interpolator = None
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
84
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
85
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
86 def start_focusing(self):
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
87 self.orb_dx_interpolator = Interpolator((24,), self._game.frame,
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
88 (8,), self._game.frame + 8,
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
89 lambda x: x ** 2)
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
90 self.orb_dy_interpolator = Interpolator((0,), self._game.frame,
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
91 (-32,), self._game.frame + 8)
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
92 self.state.focused = True
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
93
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
94
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
95 def stop_focusing(self):
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
96 self.orb_dx_interpolator = Interpolator((8,), self._game.frame,
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
97 (24,), self._game.frame + 8,
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
98 lambda x: x ** 2)
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
99 self.orb_dy_interpolator = Interpolator((-32,), self._game.frame,
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
100 (0,), self._game.frame + 8)
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
101 self.state.focused = False
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
102
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
103
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
104 def objects(self):
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
105 return self.orbs if self.state.power >= 8 else []
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
106
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
107
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
108 def update(self, keystate):
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
109 Player.update(self, keystate)
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
110
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
111 if self.death_time == 0 or self._game.frame - self.death_time > 60:
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
112 if self.orb_dx_interpolator:
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
113 self.orb_dx_interpolator.update(self._game.frame)
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
114 dx, = self.orb_dx_interpolator.values
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
115 self.orbs[0].offset_x = -dx
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
116 self.orbs[1].offset_x = dx
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
117 if self.orb_dy_interpolator:
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
118 self.orb_dy_interpolator.update(self._game.frame)
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
119 dy, = self.orb_dy_interpolator.values
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
120 self.orbs[0].offset_y = dy
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
121 self.orbs[1].offset_y = dy
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
122
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
123 for orb in self.orbs:
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
124 orb.update()
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
125
eca53abdfeab Fix ReimuA, and refactor Player a bit.
Thibaut Girka <thib@sitedethib.com>
parents: 200
diff changeset
126
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
127 def fire(self):
229
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
128 sht = self.sht
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
129 power = min(power for power in sht.shots if self.state.power < power)
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
130
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
131 bullets = self._game.players_bullets
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
132 nb_bullets_max = self._game.nb_bullets_max
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
133
229
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
134 for shot in sht.shots[power]:
232
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
135 if shot.type == 3: # TODO: Lasers aren't implemented yet
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
136 continue
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
137
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
138 if self.fire_time % shot.interval != shot.delay:
230
1c24a6d93c1b Improve find_character_defs, clean up a bit, and disable attack types 2 and 3 for now
Thibaut Girka <thib@sitedethib.com>
parents: 229
diff changeset
139 continue
1c24a6d93c1b Improve find_character_defs, clean up a bit, and disable attack types 2 and 3 for now
Thibaut Girka <thib@sitedethib.com>
parents: 229
diff changeset
140
232
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
141 if nb_bullets_max is not None and len(bullets) == nb_bullets_max:
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
142 break
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
143
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
144 origin = self.orbs[shot.orb - 1] if shot.orb else self
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
145 x = origin.x + shot.pos[0]
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
146 y = origin.y + shot.pos[1]
196
1e501e3b6645 Add a subclass for each character, and implement player attacks.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
147
232
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
148 #TODO: find a better way to do that.
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
149 bullet_type = BulletType(self.anm_wrapper, shot.sprite % 256,
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
150 shot.sprite % 256 + 32, #TODO: find the real cancel anim
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
151 0, 0, 0, 0.)
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
152 if shot.type == 2:
233
067f6d9c562b Fix replay handling a bit
Thibaut Girka <thib@sitedethib.com>
parents: 232
diff changeset
153 #TODO: triple-check acceleration!
232
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
154 bullets.append(Bullet((x, y), bullet_type, 0,
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
155 shot.angle, shot.speed,
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
156 (-1, 0, 0, 0, 0.15, -pi/2., 0., 0.),
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
157 16, self, self._game, player_bullet=True,
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
158 damage=shot.damage, hitbox=shot.hitbox))
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
159 #TODO: types 1 and 4
8843e26f80c3 Hopefully implement “accelerating” bullets
Thibaut Girka <thib@sitedethib.com>
parents: 231
diff changeset
160 else:
229
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
161 bullets.append(Bullet((x, y), bullet_type, 0,
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
162 shot.angle, shot.speed,
5afc75f71fed Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 220
diff changeset
163 (0, 0, 0, 0, 0., 0., 0., 0.),
230
1c24a6d93c1b Improve find_character_defs, clean up a bit, and disable attack types 2 and 3 for now
Thibaut Girka <thib@sitedethib.com>
parents: 229
diff changeset
164 0, self, self._game, player_bullet=True,
1c24a6d93c1b Improve find_character_defs, clean up a bit, and disable attack types 2 and 3 for now
Thibaut Girka <thib@sitedethib.com>
parents: 229
diff changeset
165 damage=shot.damage, hitbox=shot.hitbox))
1c24a6d93c1b Improve find_character_defs, clean up a bit, and disable attack types 2 and 3 for now
Thibaut Girka <thib@sitedethib.com>
parents: 229
diff changeset
166