| 88 | self.lookback_cooldown = 0 |
| 89 | |
| 90 | def update(self): |
| 91 | # Update head animation based on volume |
| 92 | if self.crow.volume > 0: |
| 93 | target_index = int(len(self.crow.head) * self.crow.volume) |
| 94 | self.head_index = min(target_index, len(self.crow.head) - 1) |
| 95 | else: |
| 96 | self.head_index = 0 |
| 97 | |
| 98 | # Update idle animation |
| 99 | if not self.crow.flying: |
| 100 | self.idle_timer += 1 |
| 101 | if self.idle_timer >= (60 / self.idle_animation_speed): |
| 102 | self.idle_index = (self.idle_index + 1) % len(self.crow.idle) |
| 103 | self.idle_timer = 0 |
| 104 | |
| 105 | # Update fly animation |
| 106 | if self.crow.flying: |
| 107 | self.fly_timer += 1 |
| 108 | if self.fly_timer >= (60 / self.fly_animation_speed): |
| 109 | self.fly_index = (self.fly_index + 1) % len(self.crow.fly) |
| 110 | self.fly_timer = 0 |
| 111 | |
| 112 | # Update blink timer |
| 113 | if self.crow.volume == 0: |
| 114 | self.blink_cooldown -= 1 |
| 115 | if self.blink_cooldown <= 0: |
| 116 | self.blink_timer = self.blink_interval |
| 117 | self.blink_cooldown = random.randint(self.blink_interval, self.blink_interval * 20) |
| 118 | if random.random() < 0.1: # 10% chance to look back instead of blink |
| 119 | self.lookback_timer = 120 |
| 120 | else: |
| 121 | self.lookback_timer = 0 |
| 122 | |
| 123 | # Decrement blink timer |
| 124 | if self.blink_timer > 0: |
| 125 | self.blink_timer -= 1 |
| 126 | |
| 127 | # Update lookback timer |
| 128 | if self.lookback_timer > 0: |
| 129 | self.lookback_timer -= 1 |
| 130 | self.lookback_cooldown = self.lookback_interval |
| 131 | |
| 132 | # Update lookback cooldown |
| 133 | if self.lookback_cooldown > 0: |
| 134 | self.lookback_cooldown -= 1 |
| 135 | |
| 136 | def render(self, screen): |
| 137 | # Render body |