I've been having a hard time getting collision to work. I'm new and don't know the in and outs with coding so please can you explain your reasoning.
Here's a simple of some code:
def __init__(self, x, y, width, height, sprite):
self.x = player_x
self.y = player_y
self.width = player.width
self.height = player.height
self.col = pygame.sprite.collide_rect(self, sprite)
pygame.sprite.Sprite.__init__(self)
def velocity_player(self):
player_vertical_velocity = 0
player_horizontal_velocity = 0
player_y = player_y + player_vertical_velocity
player_x = player_x + player_horizontal_velocity
player_fr = 5
def render(self):
player_surface = pygame.image.load("Bunny.png")
player_surface.set_colorkey(TRANSPARENT_GREEN)
player_left = pygame.image.load("Bunny_left.png")
player_left.set_colorkey(TRANSPARENT_GREEN)
player_left = pygame.image.load("Bunny_left.png")
player_left.set_colorkey(TRANSPARENT_GREEN)
player_fall = pygame.image.load("Bunny_Fall.png")
player_fall.set_colorkey(TRANSPARENT_GREEN)
player_jump = pygame.image.load("Bunny_r_Jump.png")
screen.blit(player_surface, [player_x, player_y])