Hi everyone
So im working on a project, here is the code :
def main(window):
clock = pygame.time.Clock()
arriereplan, ap_image = get_background("bleu.png")
block_size = 96
joueur = Player(450, 600, 64, 64)
# Générer des blocs sur une plage plus large
sol = [Block(i * block_size, HEIGHT - block_size, block_size) for i in range(-WIDTH // block_size, (WIDTH * 2) // block_size)]
offset_x = 0
scroll_area_width = 200
run = True
while run:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
break
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP and joueur.jump_count < 2:
joueur.jump()
joueur.loop(FPS)
handle_move(joueur, sol)
draw(window, arriereplan, ap_image, joueur, sol, offset_x)
if ((joueur.rect.right - offset_x >= WIDTH - scroll_area_width) and joueur.x_vel > 0) or ((joueur.rect.left - offset_x <= scroll_area_width) and joueur.x_vel < 0):
offset_x += joueur.x_vel
pygame.quit()
quit()
At first, the ground seems big, but when i start walking to the left or right, at some point there isn't any more blocks in the ground, any idea how to resolve it ?
