-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Description
When a Food object is created, a random generation function is used to create it's position, excluding the snake's position from the possible generated positions:
self.rect = random_pos_rect(
Game.DEFAULT_RECT, [sprite.rect for sprite in snake_group.sprites()]
)
- Change the way the second argument is passed to this function, passing the group and checking for collisions with it instead, to improve performance.
- Keep the full list of points on screen in memory for the function and only limit the width and height within the generator.
- If the excluded_rects is empty, return a random item of the list without creating the rects_without_collision list.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed