Skip to content

NinjaBuilderPro/Snake-Game

 
 

Repository files navigation

This is a sample project used to help teach some quick programming concepts and helps students create a project that will auto-deploy and be ready for them to share with others.

Tasks for Students

Track your progress with the project by updating the checkmarks down below

Set up

  • Read this readme <<<<<<< HEAD
  • Fork this project into your own Github project
  • Confirm that your website is auto-deployed to https://Ninjabuilderpro.github.io/Snake-Game/game
    • Make sure to update the {username} texts on the line above to your github username
  • Make sure the following are installed (Two of these will already be installed on computer sets up for robotics)
  • Install node packages npm install in a command line window
  • Start the server locally: npm run dev
  • Browser to the local server: http://localhost:3000/ =======
  • Fork this project into your own Github project
  • Confirm that your website is auto-deployed to GitHub Pages
    • Make sure to update the {username} text on the line above to your github username
  • Make sure the following are installed (Two of these will already be installed on computer sets up for robotics)
  • Install node packages npm install in a command line window
  • Start the server locally: npm run dev
  • Browser to the local server: http://localhost:3000/

060ece02456937ad2b22c1420c7f73e23884365b

Grid Helper

All these changes can be made in ./game/studentCode.ts

  • getGridSize - you can change it from 10 to something, to see how it changes, but return to 10 after
  • getBoardSpeedMs - we can explain it, but we will need to go back to it after the snake is moving
  • createApple - change from going to the first cell to a random cell
  • getDirection - we can explain how switch statements work and enums (for the Direction enum)

Snake

All these changes can be made in ./game/studentCode.ts

  • Handle moving the snake head from the direction passed in
  • Detect collision with a wall
  • Detect collision with an apple
  • Handle consuming an apple
  • Add default body parts
  • Handle updating the snake body when the head moves
  • Detect collisions with the body
  • Update background for the apple to ./game-assets/apple.png
  • Update image parts for the snake

Next.js Documentation

This is a Next.js project bootstrapped with create-next-app.

Getting Started

First, run the development server:

npm run dev

Open http://localhost:3000 with your browser to see the result.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

About

Snaforke

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 84.4%
  • CSS 14.7%
  • JavaScript 0.9%