Skip to content

🛡️ Feature Request: Add Power-Up – “Shield” (Immunity to Self-Collision for 2 Seconds) #3

Description

@AjaysDevWorkspace

Introduce a new power-up called “Shield” that makes the snake immune to self-collision for 2 seconds after being picked up.
This will allow players to survive if they accidentally run into their own tail — but only for a short time.

🎯 Requirements:

  • Add a new shield item (e.g., a glowing orb or different-colored fruit).
  • When the player collects this item:
    • Enable a shield mode for 2 seconds.
    • During shield mode, ignore self-collision checks.
    • After 2 seconds, return collision behavior to normal.
  • Prevent shield stacking if a second one is collected while the first is still active.
  • Optional: Add a visual indicator (e.g., glowing snake, border around the screen, shield icon on screen).

đź’ˇ Implementation Hints:

  • Add a flag like isShieldActive to control self-collision logic.
  • Use setTimeout to automatically disable the shield after 2000ms.
  • Modify the part of the code that checks for self-collision to something like:
    if (!isShieldActive && checkSelfCollision()) {
      gameOver();
    }
  • Consider adding sound or visual feedback when the shield activates or deactivates.

đź§© Files Likely Involved:

  • script.js (main game loop, collision detection)
  • Any file that handles power-up spawning or game state

âś… Acceptance Criteria:

  • Player collects the Shield item successfully
  • Self-collision is ignored for exactly 2 seconds
  • Collision works normally again after 2 seconds
  • No shield stacking bugs or unexpected behaviors
  • UI feedback shows shield status clearly (optional)

đź§Ş Optional Bonus:

  • Show a countdown timer or visual effect while the shield is active.
  • Add a cool-down before another shield can be used.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions