0

I am trying to do this code to print "YOU HIT THE RED BLOCK!!" but not working

player_hitbox = pygame.draw.rect(win, (255,255,45), player,2)
for tile_object in map.tmxdata.objects:
    if tile_object.name == 'player':
        x = tile_object.x
        y = tile_object.y
    if tile_object.name == 'wall':
        hit_rect = pygame.Rect(tile_object.x, tile_object.y, tile_object.width, tile_object.height)
        # rect = pygame.Rect(tile_object.x, tile_object.y, tile_object.width, tile_object.height)
        if player_hitbox.colliderect(hit_rect) == True:
            print("YOU HIT THE RED BLOCK!!")
Ted Klein Bergman
  • 8,342
  • 4
  • 24
  • 45
abycoder
  • 11
  • 1
  • 2
    I am voting to close this question as there is no [**Minimal**, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example). – Rabbid76 Dec 28 '20 at 10:50
  • Well, use debug (or some print statements) and you will see that you are not entering the nested `if` statements. – skibee Dec 28 '20 at 11:57

0 Answers0