#🔒 Pygame, floor not big enough

15 messages · Page 1 of 1 (latest)

hazy kindle
#

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 ?

spark brookBOT
#

@hazy kindle

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

hazy kindle
stuck marsh
hazy kindle
#

Yes indeed i just tought about it...

    sol = [Block(i * block_size, HEIGHT - block_size, block_size) for i in range(-WIDTH * 90 // block_size, (WIDTH * 90) // block_size)]

Here's the "solution" if anyone need ahaha

stuck marsh
hazy kindle
#

yeah i'll MAYBE change that xD

stuck marsh
hazy kindle
#

i've tried something like that

But i'm new to this, i started yesterday and i might have some difficulties, but i will try thgo

stuck marsh
hazy kindle
#

less lags, more performence

stuck marsh
hazy kindle
#

ahahah thanks ^^

Its for a school project blob_animated_hypersweat

spark brookBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.