Skip to content
Md. Reyanus Salehin edited this page May 24, 2024 · 6 revisions

Intro

This repository contains an implementation of a snake game. Different features have been implemented in different branches. For the workshop, the student will be given the "first-step" project on which they will implement different features. Students will implement the "Initial Mode" and "Challenges" throughout their workshop session. Branch name, in which a specific feature has been implemented, is given by ":branch_name" inside the first bracket with them at their right side. In "Challenges" each challenge's index is its difficulty level. Every feature is developed on the "initial-mode" branch except for "snake-life" and "increase-life-food".

Required Tools

  • Visual Studio code (vs code)
  • Live Server extension (in vs code)

First Step (:first-step)

  • Head color is the same as body
  • Apple's position is static
  • Snake cannot eat the apple
  • Snake doesn't increase in length (as it can't eat the apple)
  • Score doesn't increase (as snake can't eat the apple)
  • Snake can move backwards
  • Snake's position changes every time a game is started
  • Snake dies if it hits the edges of the board

Initial Mode (:initial-mode)

The change of features and new features in initial-mode compared to first-step

  • Head color is different to the body
  • Snake can eat the apple
  • Apple's position is dynamic and random and stays until the snake eats it
  • Score increases as a snake eats the apple
  • Snake's body doesn't increase in length even if it eats the apple
  • Snake can't move backwards
  • Snake position doesn't change every time the game started
  • Snake doesn't get killed by hitting itself

Challenges

  1. Snake increases in length by one unit every time it eats one apple. (:snake-size-increase)

  2. Snake appears in a random position every time the game starts. (:random-snake-position)

  3. Snake moves through the edges to their opposite edge in a circular way. (:circular-way)

  4. Snake gets killed by hitting itself. (:killed-by-hitting-itself)

  5. If the snake hits its body, then the remaining part of the body disappears from the hitting spot but the snake doesn't die. (:snake-body-disappear)

  6. A reset button above the top-right corner of the canvas resets the game. (:reset)

  7. The speed of the snake increases with the score. (:increase-speed)

  8. Another apple called 'booster apple' is added to the game. Booster apple appears in random places after eating every 5 apples and stays for 5 seconds. If the snake can eat the booster apple, then the score is increased by 3 points. (:booster-apple)

  9. Another feature called "life" is added. Initially, 3 lifes have been given. A flower appears initially after eating 13 apples and after that, eating a random number of apples between 1 to 15 (inclusive). It appears in random places on the canvas and stays for 2.5 seconds. And when the snake eats the flower, its life is increased by 1. (:increase-life-food)

  10. 4 walls are created on the canvas of the game. If the snake hits any of the walls it dies. There are 4 levels. At each level the arrangement of the walls changes. After eating 15, 27 and 39 apples (respectively) in the 0th, 1st and 2nd levels the doors for the next level 1st, 2nd and 3rd levels appear. The door is indicated by 2 walls and a space between them near the edges of the canvas. If the snake hits the walls of the door, it dies. The door appears in different places on different levels.


Compare to (:janbodnar/JavaScript-Snake-Game)

Features present in (:JavaScript-Snake-Game)

  • Head color is different to the body
  • Snake can eat the apple
  • Apple's position is dynamic and random and stays until the snake eats it
  • Score increases as a snake eats the apple
  • Snake's body increases in length as it eats the apple
  • Snake can't move backwards
  • Snake position changes every time the game starts
  • Snake gets killed by hitting itself
  • Snake dies if it hits the edges of the board

Modification in Initial Mode

  • The snake doesn't increase in length
  • Snake does not get killed by hitting itself

Modification in First Step

  • Head color is the same as body
  • Apple's position is static
  • Snake cannot eat the apple
  • Snake doesn't increase in length
  • Score doesn't increase
  • Snake can move backwards
  • Snake's position changes every time a game is started