Skip to content

Task 2 Snake Game

AravindReddy5076 edited this page Mar 12, 2020 · 4 revisions

INTRODUCTION:

This is an angular code used to develop a basic snake game. There will be different game modes in this game namely classic, no_walls and obstacles. Score of each game will be stored and best score will be displayed.

OBJECTIVE:

The main objective of this web application is to develop a basic snake game using angular.

1.User can play this game using the arrow keys for the movement of the snake. 2.There are three modes of game namely classic, no_walls and obstacles. 3.No_walls is the easiest level of all modes where there will be no walls or obstacles present in the maze. The game will be ended only when the snake hits itself. 4.Classic is the moderate game mode where there will be walls on 4 sides. The game will be ended when snake hit the walls or snake hit itself. 5.Obstacles is the hardest level of all modes where different obstacles will be present in random positions all over the maze. Game will be ended when snake hits obstacle or when it hits itself.

APPROACHES/METHODS:

1.This is the html code for snake game.It consists of different div elements and Boolean values which are used for displaying div elements. 1

2.When we open local host 4200 we can view web application of the game.On this page start button and best score of the previous games will be present.

3.When we click on the start button on the next page different game modes will be displayed based on the Boolean value where user can select any mode. 2

4.Whenever the user contact with the fruit the score will be incremented and stored.

3 5.The position of the fruit will be determined by random number function. 4

6.this is the game over code for the snake game whenever if hits the wall or obstacle or itself.

5

7.The best score of all games will be stored and compared with other scores if the score is higher than the best score then it will be automatically updated.

5

WORKFLOW:

1.This is the UI of the game.

6 2.Different game modes:

3.This is the web page after game has started with fruit and snake. 7

4.This is the page for obstacle mode.

7 5.Score will be incremented each time when snake collects fruit.

6.This is the game over page:

7.Current score will be compared with previous best score. If current score is higher than the best score then the best score will be updated. 8 CONCLUSION:

By doing this task I gained knowledge about angular and how to develop a snake game.

LINKS: Source code:https://github.com/AravindReddy5076/WEBSPRING_2020/tree/master/LAB-1/Task-2%20Snake%20Game/Source%20code youtube :https://youtu.be/T0-ITWS10Ck

Clone this wiki locally