Mercurial > skaapsteker
comparison skaapsteker/sprites/player.py @ 430:25efc74ac19c
Hook up flight and invisibility discharge
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Sat, 09 Apr 2011 18:40:25 +0200 |
parents | 8b047e74dfd1 |
children | b753ea36909e |
comparison
equal
deleted
inserted
replaced
429:8b047e74dfd1 | 430:25efc74ac19c |
---|---|
389 return True | 389 return True |
390 | 390 |
391 def recharge_level(self, attack): | 391 def recharge_level(self, attack): |
392 return min((time.time() - self._last_attacked[attack]) / RECHARGE_TIME, 1) | 392 return min((time.time() - self._last_attacked[attack]) / RECHARGE_TIME, 1) |
393 | 393 |
394 def discharge_level(self, tail): | |
395 if tail == 'invisibility' and hasattr(self, '_invisibility_start_time'): | |
396 start_time = self._invisibility_start_time | |
397 max_time = self._max_invisibility_time | |
398 elif tail == 'flight' and hasattr(self, '_flight_start_time'): | |
399 start_time = self._flight_start_time | |
400 max_time = self._max_flight_time | |
401 else: | |
402 return 0 | |
403 discharge = (time.time() - start_time) / max_time | |
404 if discharge > 1: | |
405 return 0 | |
406 return discharge | |
407 | |
394 def _get_action(self): | 408 def _get_action(self): |
395 if self.attacking: | 409 if self.attacking: |
396 return 'attacking' | 410 return 'attacking' |
397 if (self.sprinting > 0) and self.running: | 411 if (self.sprinting > 0) and self.running: |
398 return 'sprinting' | 412 return 'sprinting' |