Changeset 355:5bdb4677510a


Ignore:
Timestamp:
04/09/11 12:02:13 (12 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Phase:
public
Rebase:
33303233626430663033346439393631383831633262343465383164343563386561353632393866
Message:

Have fireballs appear in the right place.

Location:
skaapsteker/sprites
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/sprites/base.py

    r352 r355  
    9090
    9191        self.collide_rect = Rect((0, 0), (2, 2))
    92         self.collide_rect.midbottom = (pos[0]*TILE_SIZE[0]+TILE_SIZE[0]/2, (pos[1]+1)*TILE_SIZE[1])
     92        if isinstance(pos, pygame.Rect):
     93            self.collide_rect.midbottom = pos.midbottom
     94        else:
     95            self.collide_rect.midbottom = (pos[0]*TILE_SIZE[0]+TILE_SIZE[0]/2, (pos[1]+1)*TILE_SIZE[1])
    9396        self._update_image()
    9497        self.setup(**opts)
  • skaapsteker/sprites/player.py

    r353 r355  
    274274        self.attacking = 2
    275275        self._last_time = time.time() # Reset the animation clock
    276         fireball = Fireball(self.get_tile_pos())
    277         fireball.facing = self.facing
     276        if self.facing == 'left':
     277            pos = pygame.Rect(self.rect.midleft, (0, 0))
     278        else:
     279            pos = pygame.Rect(self.rect.midright, (0, 0))
     280        fireball = Fireball(pos, direction=self.facing)
    278281        AddSpriteEvent.post(fireball)
    279282
     
    370373        return [a/b for a, b in zip(self.rect.center, TILE_SIZE)]
    371374
     375    def get_tile_for_pos(self, pos):
     376        return [a/b for a, b in zip(pos, TILE_SIZE)]
     377
    372378    def get_sprite(self, set_level):
    373379        my_item = self._me.item
  • skaapsteker/sprites/projectiles.py

    r346 r355  
    2020    }
    2121
     22    FIREBALL_WIDTH = 60 # pixels
     23
     24    def setup(self, direction):
     25        self.facing = direction
     26        if self.facing == "left":
     27            shift = (-self.FIREBALL_WIDTH / 2, 0)
     28        else:
     29            shift = (self.FIREBALL_WIDTH / 2, 0)
     30        self.rect.move_ip(shift)
     31        self.collide_rect.move_ip(shift)
     32
    2233    def collided_player(self, player):
    2334        print "%s went boom with player" % self
Note: See TracChangeset for help on using the changeset viewer.