Changeset 50:7d411ed02eac


Ignore:
Timestamp:
Apr 3, 2011, 7:18:31 PM (9 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Message:

Initial stab at detecting collisions.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • data/levels/level1.json

    r28 r50  
    1919    ],
    2020    "enemies": [
    21         {"type": "Dummy", "pos": [2, 2], "direction": "left" }
     21        {"type": "Dummy", "pos": [4, 2], "direction": "left" }
    2222    ],
    2323    "sprites": [
  • scripts/level-editor

    r46 r50  
    5353        level_surface.set_clip(clip_rect)
    5454        level.draw(level_surface)
     55        level.draw_tiles(level_surface)
    5556        screen_surface.blit(level_surface, (0, 0), clip_rect)
    5657
  • skaapsteker/level.py

    r47 r50  
    102102    def draw(self, surface):
    103103        self.draw_background(surface)
    104         self.draw_tiles(surface)
    105 
    106 
  • skaapsteker/levelscene.py

    r43 r50  
    1717        for sprite in self._level.enemies:
    1818            self._world.add(sprite)
     19        for sprite in self._level.tiles:
     20            self._world.add(sprite)
    1921
    2022    def draw(self, screen_surface):
  • skaapsteker/physics.py

    r43 r50  
    7474            sprite.deltap(dt)
    7575
     76        # check for collisions
     77        print "-------"
     78        for sprite1, sprites in pygame.sprite.groupcollide(self._mobiles, self._all, False, False).iteritems():
     79            for sprite2 in sprites:
     80                if sprite1 is sprite2:
     81                    continue
     82                print "Collision! %r (%s), %r (%s)" % (sprite1, id(sprite1), sprite2, id(sprite2))
     83                print "    ", sprite1.rect, sprite2.rect
     84
    7685    def draw(self, surface):
    7786        self._all.draw(surface)
Note: See TracChangeset for help on using the changeset viewer.