Skip to content

Modheus/SnakeGame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snake Game Overview

A screenshot of the snake game

The snake game operates by rendering a canvas, the snake segments, and the apple with each new frame.


The Snake

  • Segment Size: The snake has a size variable that defines the pixel dimensions of each side of its segments. This determines how large each block of the snake appears on the canvas.

  • Movement Logic:

    • The snake's movement is controlled by an object containing functions for each direction (up, down, left, right).
    • These functions modify a movement variable, which serves as an offset to calculate the snake's next position on the canvas.
    • With every frame, the snake’s position is updated based on this offset.

The Apple

  • Random Placement:

    • The apple is placed at a random location on the canvas when the game begins and every time it collides with the snake's head.
  • Static Behavior:

    • Once placed, the apple remains stationary until the snake collects it by overlapping its head with the apple's position.

The Score

  • Increment:

    • Each time the snake collects an apple, the score increases by 1. showing the player’s progress in the game.
  • Reset on Death:

    • If the snake dies, the score resets to 0, prompting the player to reset.

About

Um pequeno projeto pessoal de recriar o jogo Snake

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published