# HG changeset patch # User Thibaut Girka # Date 1332516427 -3600 # Node ID e935ed8dc5e6caae683ce946d4bbfae2253615c6 # Parent 0f88ae611d37167477d0f31e5fc4addf9f9fd0ce Add out-of-screen item indicators. diff --git a/pytouhou/game/item.py b/pytouhou/game/item.py --- a/pytouhou/game/item.py +++ b/pytouhou/game/item.py @@ -14,21 +14,42 @@ from math import cos, sin, atan2, pi +from copy import copy from pytouhou.utils.interpolator import Interpolator +class Indicator(object): + def __init__(self, item): + self._item = item + + self.sprite = copy(item._item_type.indicator_sprite) + self.removed = False + + self.frame = 0 + self.x = self._item.x + self.y = self.sprite.texcoords[2] / 2. + + + def update(self): + #TODO: alpha + self.x = self._item.x + self.frame += 1 + + + class Item(object): def __init__(self, start_pos, _type, item_type, game, angle=pi/2, player=None, end_pos=None): self._game = game + self._type = _type self._item_type = item_type self.sprite = item_type.sprite self.removed = False - self._type = _type self.frame = 0 self.x, self.y = start_pos self.angle = angle + self.indicator = None if player: self.autocollect(player) @@ -137,5 +158,14 @@ class Item(object): self.x += dx self.y += dy + offscreen = self.y < -(self.sprite.texcoords[2] / 2.) + if offscreen: + self.indicator = self.indicator or Indicator(self) + else: + self.indicator = None + + if self.indicator: + self.indicator.update() + self.frame += 1 diff --git a/pytouhou/ui/gamerenderer.pyx b/pytouhou/ui/gamerenderer.pyx --- a/pytouhou/ui/gamerenderer.pyx +++ b/pytouhou/ui/gamerenderer.pyx @@ -88,7 +88,9 @@ cdef class GameRenderer(Renderer): game.players, game.msg_sprites(), *(player.objects() for player in game.players))) - self.render_elements(chain(game.bullets, game.lasers, game.cancelled_bullets, game.items)) + self.render_elements(chain(game.bullets, game.lasers, + game.cancelled_bullets, game.items, + (item.indicator for item in game.items if item.indicator))) #TODO: display item indicators glEnable(GL_FOG)