# HG changeset patch # User Emmanuel Gil Peyrot # Date 1376134602 -7200 # Node ID 4ccc47828002faeebe466bc7aadfb17adf1e92da # Parent cae1ae9de4309638e19df97db834af0443c0256f Display the name of a spellcard and the face of its invoker. diff --git a/pytouhou/game/game.pyx b/pytouhou/game/game.pyx --- a/pytouhou/game/game.pyx +++ b/pytouhou/game/game.pyx @@ -46,7 +46,7 @@ cdef class Game: self.items = [] self.labels = [] self.faces = [None, None] - self.texts = [None, None, None, None] + self.texts = [None, None, None, None, None, None] self.interface = interface self.hints = hints @@ -100,13 +100,33 @@ cdef class Game: def enable_spellcard_effect(self): - self.spellcard_effect = Effect((-32., -16.), 0, - self.spellcard_effect_anm) #TODO: find why this offset is necessary. - self.spellcard_effect.sprite.allow_dest_offset = True #TODO: should be the role of anm’s 25th instruction. Investigate! + pos = (-32, -16) + self.spellcard_effect = Effect(pos, 0, + self.spellcard_effect_anm) + self.spellcard_effect.sprite.allow_dest_offset = True + + face = Effect(pos, 3, self.msg_anm[0][0][0]) + face.sprite.allow_dest_offset = True + face.sprite.anm, face.sprite.texcoords = self.msg_anm[1][self.spellcard[2]] + self.effects.append(face) + + self.texts[5] = self.new_native_text((384-24, 24), self.spellcard[1], align='right') def disable_spellcard_effect(self): self.spellcard_effect = None + self.texts[5] = None + + + def set_player_bomb(self): + face = Effect((-32, -16), 1, self.msg_anm[0][0][0]) + face.sprite.allow_dest_offset = True + self.effects.append(face) + self.texts[4] = self.new_native_text((24, 24), u'Player Spellcard') + + + def unset_player_bomb(self): + self.texts[4] = None cpdef drop_bonus(self, double x, double y, long _type, end_pos=None): diff --git a/pytouhou/game/player.pxd b/pytouhou/game/player.pxd --- a/pytouhou/game/player.pxd +++ b/pytouhou/game/player.pxd @@ -14,7 +14,7 @@ cdef class Player(Element): cdef object anm cdef tuple speeds - cdef long fire_time, direction + cdef long fire_time, bomb_time, direction cdef void set_anim(self, index) cpdef play_sound(self, str name) diff --git a/pytouhou/game/player.pyx b/pytouhou/game/player.pyx --- a/pytouhou/game/player.pyx +++ b/pytouhou/game/player.pyx @@ -230,6 +230,14 @@ cdef class Player(Element): self.fire() self.fire_time -= 1 + if keystate & 2 and self.bomb_time == 0: + self._game.set_player_bomb() + self.bomb_time = 240 + if self.bomb_time > 0: + self.bomb_time -= 1 + if self.bomb_time == 0: + self._game.unset_player_bomb() + if self.death_time: time = self._game.frame - self.death_time if time == 6: # too late, you are dead :( diff --git a/pytouhou/vm/eclrunner.py b/pytouhou/vm/eclrunner.py --- a/pytouhou/vm/eclrunner.py +++ b/pytouhou/vm/eclrunner.py @@ -746,7 +746,7 @@ class ECLRunner(object): #TODO: display it on the game. self._enemy.difficulty_coeffs = (-.5, .5, 0, 0, 0, 0) self._game.change_bullets_into_star_items() - self._game.spellcard = (number, name) + self._game.spellcard = (number, name, face) self._game.enable_spellcard_effect()