0

I am having two problems with my code:

  1. I don't know how to make my character check that it's colliding with the blocks

  2. How do I blit to a new screen every time she completes a level? So when the character reaches the stair then a new screen should appear showing the new level

Here is all my code :

http://pastebin.com/u/bluesplay106

I am pretty new to pygame so my style may not be good and I kind of hard coded this game. If you could tell me how to fix my problem that would be really great!!

stema
  • 90,351
  • 20
  • 107
  • 135
  • Your questions are going to need to be much more specific if you hope to get an applicable answer. – hspain Dec 06 '11 at 21:00

1 Answers1

0

for the collision detection you need to make your character and your blocks into sprites and do a collision detection that way.

As for the new screen when you get to the stairs, you can use a statement like this:

if heroSprite_x >= 200 and heroSprite_x <= 300:
    if heroSprite_y >= 300 and heroSprite_y <= 400:

        #go to new screen using either a new level from a list or a new class or whatever method you want.

Your question was a bit vague but I hope that's what you were looking for :)

I just realized I didnt answer your first question, here's a snippet from one of my games:

unit_enemy = pygame.sprite.groupcollide(unitgroup, enemygroup, True, pygame.sprite.collide_mask) 

for hit in unit_enemy:
    #do something

This checks if any enemies hit my unit. So in you case it would be your hero, and the enemies would be blocks.

Here's the documentation on collision detection.

http://pygame.org/docs/ref/sprite.html

Jere
  • 116
  • 7