comparison pytouhou/game/item.py @ 327:13201d90bb22

Display the text when collecting an item.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 21 Jun 2012 15:01:25 +0200
parents e935ed8dc5e6
children 94fdb6c782c1
comparison
equal deleted inserted replaced
326:efcdf2ce747c 327:13201d90bb22
76 76
77 def on_collect(self, player): 77 def on_collect(self, player):
78 player_state = player.state 78 player_state = player.state
79 old_power = player_state.power 79 old_power = player_state.power
80 score = 0 80 score = 0
81 label = None
82 color = 'white'
81 83
82 if self._type == 0 or self._type == 2: # power or big power 84 if self._type == 0 or self._type == 2: # power or big power
83 if old_power < 128: 85 if old_power < 128:
84 player_state.power_bonus = 0 86 player_state.power_bonus = 0
85 score = 10 87 score = 10
86 player_state.power += (1 if self._type == 0 else 8) 88 player_state.power += (1 if self._type == 0 else 8)
87 if player_state.power > 128: 89 if player_state.power > 128:
88 player_state.power = 128 90 player_state.power = 128
91 for level in (8, 16, 32, 48, 64, 96):
92 if old_power < level and player_state.power >= level:
93 label = self._game.new_label((self.x, self.y), ':') # Actually a “PowerUp” character.
94 color = 'blue'
95 label.set_color(color)
96 labeled = True
89 else: 97 else:
90 bonus = player_state.power_bonus + (1 if self._type == 0 else 8) 98 bonus = player_state.power_bonus + (1 if self._type == 0 else 8)
91 if bonus > 30: 99 if bonus > 30:
92 bonus = 30 100 bonus = 30
93 if bonus < 9: 101 if bonus < 9:
96 score = (bonus - 8) * 100 104 score = (bonus - 8) * 100
97 elif bonus < 30: 105 elif bonus < 30:
98 score = (bonus - 17) * 1000 106 score = (bonus - 17) * 1000
99 elif bonus == 30: 107 elif bonus == 30:
100 score = 51200 108 score = 51200
109 color = 'yellow'
101 player_state.power_bonus = bonus 110 player_state.power_bonus = bonus
102 self._game.modify_difficulty(+1) 111 self._game.modify_difficulty(+1)
103 112
104 elif self._type == 1: # point 113 elif self._type == 1: # point
105 player_state.points += 1 114 player_state.points += 1
106 poc = player.sht.point_of_collection 115 poc = player.sht.point_of_collection
107 if player_state.y < poc: 116 if player_state.y < poc:
108 score = 100000 117 score = 100000
109 self._game.modify_difficulty(+30) 118 self._game.modify_difficulty(+30)
119 color = 'yellow'
110 else: 120 else:
111 #score = #TODO: find the formula. 121 #score = #TODO: find the formula.
112 self._game.modify_difficulty(+3) 122 self._game.modify_difficulty(+3)
113 123
114 elif self._type == 3: # bomb 124 elif self._type == 3: # bomb
131 if old_power < 128 and player_state.power == 128: 141 if old_power < 128 and player_state.power == 128:
132 #TODO: display “full power”. 142 #TODO: display “full power”.
133 self._game.change_bullets_into_star_items() 143 self._game.change_bullets_into_star_items()
134 144
135 if score > 0: 145 if score > 0:
136 #TODO: display the score.
137 player_state.score += score 146 player_state.score += score
147 if not label:
148 label = self._game.new_label((self.x, self.y), str(score))
149 if color != 'white':
150 label.set_color(color)
138 151
139 self.removed = True 152 self.removed = True
140 153
141 154
142 def update(self): 155 def update(self):