Mercurial > touhou
comparison pytouhou/games/eosd.py @ 300:da53bc29b94a
Add the game interface.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 10 Mar 2012 17:47:03 +0100 |
parents | e7f40bff72fc |
children | 647bde10353d |
comparison
equal
deleted
inserted
replaced
299:e04e402e6380 | 300:da53bc29b94a |
---|---|
18 from pytouhou.game.bullettype import BulletType | 18 from pytouhou.game.bullettype import BulletType |
19 from pytouhou.game.lasertype import LaserType | 19 from pytouhou.game.lasertype import LaserType |
20 from pytouhou.game.itemtype import ItemType | 20 from pytouhou.game.itemtype import ItemType |
21 from pytouhou.game.player import Player | 21 from pytouhou.game.player import Player |
22 from pytouhou.game.orb import Orb | 22 from pytouhou.game.orb import Orb |
23 from pytouhou.game.effect import Effect | |
24 from pytouhou.game.text import Text | |
23 | 25 |
24 from math import pi | 26 from math import pi |
25 | 27 |
26 | 28 |
27 SQ2 = 2. ** 0.5 / 2. | 29 SQ2 = 2. ** 0.5 / 2. |
79 (0, 2, 4, 8, 10, 11, 12)) | 81 (0, 2, 4, 8, 10, 11, 12)) |
80 | 82 |
81 characters = resource_loader.get_eosd_characters() | 83 characters = resource_loader.get_eosd_characters() |
82 players = [EoSDPlayer(state, self, resource_loader, characters[state.character]) for state in player_states] | 84 players = [EoSDPlayer(state, self, resource_loader, characters[state.character]) for state in player_states] |
83 | 85 |
86 interface = EoSDInterface(player_states, resource_loader) | |
87 | |
84 Game.__init__(self, resource_loader, players, stage, rank, difficulty, | 88 Game.__init__(self, resource_loader, players, stage, rank, difficulty, |
85 bullet_types, laser_types, item_types, nb_bullets_max, | 89 bullet_types, laser_types, item_types, nb_bullets_max, |
86 width, height, prng) | 90 width, height, prng, interface) |
91 | |
92 | |
93 | |
94 class EoSDInterface(Game): | |
95 def __init__(self, states, resource_loader): | |
96 self.states = states | |
97 front = resource_loader.get_anm_wrapper(('front.anm',)) | |
98 ascii_wrapper = resource_loader.get_anm_wrapper(('ascii.anm',)) | |
99 | |
100 self.width = 640 | |
101 self.height = 480 | |
102 self.game_pos = (32, 16) | |
103 | |
104 self.items = ([Effect((0, 32 * i), 6, front) for i in range(15)] + | |
105 [Effect((416 + 32 * i, 32 * j), 6, front) for i in range(7) for j in range(15)] + | |
106 [Effect((32 + 32 * i, 0), 7, front) for i in range(12)] + | |
107 [Effect((32 + 32 * i, 464), 8, front) for i in range(12)] + | |
108 [Effect((0, 0), 5, front)] + | |
109 [Effect((0, 0), i, front) for i in range(5) + range(9, 16)]) | |
110 for item in self.items: | |
111 item._sprite.allow_dest_offset = True #XXX | |
112 | |
113 self.labels = { | |
114 'highscore': Text((500, 58), '0', front, ascii_wrapper), | |
115 'score': Text((500, 82), '0', front, ascii_wrapper), | |
116 'player': Text((500, 122), 'star star', front, ascii_wrapper), | |
117 'bombs': Text((500, 146), 'star star', front, ascii_wrapper), | |
118 'power': Text((500, 186), '0', front, ascii_wrapper), | |
119 'graze': Text((500, 206), '0', front, ascii_wrapper), | |
120 'points': Text((500, 226), '0', front, ascii_wrapper), | |
121 'framerate': Text((512, 464), '', front, ascii_wrapper), | |
122 'debug?': Text((0, 464), '', front, ascii_wrapper), | |
123 } | |
124 | |
125 | |
126 def update(self): | |
127 for elem in self.items: | |
128 elem.update() | |
129 | |
130 player_state = self.states[0] | |
131 | |
132 self.labels['score'].set_text('%09d' % player_state.score) | |
133 self.labels['power'].set_text('%d' % player_state.power) | |
134 self.labels['graze'].set_text('%d' % player_state.graze) | |
135 self.labels['points'].set_text('%d' % player_state.points) | |
87 | 136 |
88 | 137 |
89 | 138 |
90 class EoSDPlayer(Player): | 139 class EoSDPlayer(Player): |
91 def __init__(self, state, game, resource_loader, character): | 140 def __init__(self, state, game, resource_loader, character): |