player_rect = Pfront_n.get_rect()
Here 'Pfront_n' is a sprite, and I am getting a rect for that sprite. This is outside of the main loop. When inside the main loop, print(player_rect)
shows that when my player moves, the rect doesn't follow. My players movement system is a velocity based one, if that makes any difference. How can I have the rect stay around the player?
Following this, I have another similar question...
for layer in room2:
r_x = 0
for tile in layer:
if tile == '2':
bat_create()
if tile == '1':
screen.blit(grass, (r_x*40, r_y*40))
if tile != '0':
tile_rects.append(pygame.Rect)
r_x += 1
r_y += 1
Outside the main loop, I have created a rect for grass
in the same was as I have for my player. The method I am using in the above code has multiple grass
blocks appear in positions pre-determined by an array. How can I get the rects for each individual grass
block?
Fairly Irrelevant Sidenote for Context -The ultimate goal is to use my players rect, and the grass
rect so my player gets stopped when hitting the grass
. Any help on either of these questions would be great. Thanks!