May-25-2020, 09:06 AM
(This post was last modified: May-25-2020, 09:06 AM by lolloiltizio.)
well you can also use pygame Rect and the finction colliderect() like
If you want to put a not defined number of platforms, than you should do something like this:
for further informations about this visit the "getting projectiles in pygame" in this forum ;P
character = pygame.Rect(x, y, width, height) platform = pygame.Rect(x, y, width, height) speed = 5and in the while loop:
if character.colliderect(platform): jump() #a function that I haven't defined wich makes the character jump else: character.y += speedImplementing this should solve your problems.
If you want to put a not defined number of platforms, than you should do something like this:
#where platforms is a list filled with platforms rects variables for platform in platforms: if character.colliderect(platform): jump() #a function that I haven't defined wich makes the character jump else: character.y += speedWith this thing you can avoid messing up with classes for such a simple project...
for further informations about this visit the "getting projectiles in pygame" in this forum ;P