Skip to content

piece variable initialization and usage #7

@Imran-imtiaz48

Description

@Imran-imtiaz48

In your setup() function, you are incrementing piece by 1 (piece++) at the start of the game. This means the snake already has one tail segment before it eats any fruit, which is not the expected behavior. The snake should usually start with zero tail pieces (only head visible), and grow only when it eats fruit. This off-by-one initialization also causes rendering confusion because your draw() loop tries to print a body segment that should not exist yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions