computer project (3)
computer project (3)
A FINAL REPORT
FINAL REPORT
ON
"SNAKE GAME USING HTML"
A Report Submitted for the partial fulfilment of requirement for the degree of NEB
in computer science
…………………………….
1|Page
DEPARTMENT OF COMPUTER SCIENCE
KHWOPA SECONDARY SCHOOL
DEKOCHA-06, BHAKTAPUR
CERITFICATE
This is to certify that the project entitled “Programming with
HTML” submitted by Mr. Samir Dulal, Mr. Rojan Koju, Mr.
Nayan Thapa & Mr. John Prajapati in a partial fulfillment of the
requirements for the internal marks of Computer science in NEB
(National Examination Board) Class 11 (XI), is a bonafide work
to the best of my/our knowledge and may be placed before the
examination board for their consideration.
Panel of Examiners:
Name Signature Date
External Examiner
……………………
Project Supervisors
2|Page
ACKNOWLEDGEMENT
We are thankful to all those who have helped us directly or
indirectly with this project. Foremost, we would like to thank
the Department of Computer Science of Khwopa Secondary
School for the giving an opportunity to carry out project entitled
"PC based Snake Game".
We would like to thank our computer teachers Er. Pujan
Changubhari for their guidance while developing project and
also for organizing the project schedules. Also we would like to
acknowledge their effort that encouraged us to take this
challenging project. We would also like to thanks our brother
Amit Achara to helping for developing the project. We would
also like to offer our gratitude towards some of our friends who
helped throughout our project development phase by providing
several references regarding different links for code and making
project report.
3|Page
ABSTRACT
This is our project related with one of the famous "snake game".
Nowadays most of the people in this world love to play video
games. To provide a video game for them we create our new
HTML project “Snake Game”. In this game you will enjoy. You
will get task eat apple there from you can enjoy. If you touch the
border of given certain area and the body of the snake by its
head you will be out from this game you have to click start play
game again. The main objective of this project is to provide the
enjoyment in which we can get by playing video game.
Content
4|Page
s
INTRODUCTION..................................................................................6
BACKGROUND............................................................................................................................ 6
OBJECTIVES................................................................................................................................ 6
APPLICATIONS............................................................................................................................ 7
SCOPE AND LIMITATIONS........................................................................................................... 7
METHODOLOGY.................................................................................8
DISCUSSION..............................................................................................................................14
CONCLUSION............................................................................................................................14
APPENDIX.........................................................................................15
APPENDIX -2............................................................................................................................. 16
APPENDIX- 3............................................................................................................................. 17
APPENDIX -4............................................................................................................................. 19
REFERENCE.......................................................................................21
5|Page
INTRODUCTION
BACKGROUND
Technology is rapidly increasing in today’s world. Internet is one of the
rapidly increasing technologies. The use and user are increasing day by
day. Nowadays, people are using internet for communication,
collaboration, and many others things that done online. With the
development of internet, computer programming is also developed
rapidly in the modern era. Computer Programming is the fundamental
skills for so many different applications, not just software development
or cutting-edge research into artificial intelligence. Through the help of
computer programming we can do research and development,
government operations, web development and designs, marketing and
business operations, data science and artificial intelligence, cyber
security etc.
OBJECTIVES
To familiar with the use of HTML programming in realistic manner
To learn how to use canvas, script, function in the program
To be able to design a simple application by use of HTML codes
6|Page
APPLICATIONS
To show how the code really works
To provide general knowledge about HTML programming
To demonstrate that how coding is important in modern era
7|Page
METHODOLOGY
8|Page
JavaScript:
- Immediately Invoked Function Expression (IIFE): Wraps the entire
JavaScript code within a function that is immediately invoked. This is a
common pattern to avoid polluting the global namespace.
Constants and Variables:
¤ `CELLS_COUNT`: Defines the number of cells in
each row/column of the game grid.
¤ `CELL_SIZE`: Calculates the size of each cell based
on the canvas width and the number of cells.
¤ `snake`: An array to store the positions of the snake's
segments.
¤ `food`: An object representing the position of the food
on the canvas.
¤ `dir`: Keeps track of the current direction the snake is
moving.
¤ `score`: Tracks the player's score.
¤ `speedCoeff`: A coefficient affecting the speed of the
snake.
Colors:
¤ `FIELD_COLOR`, `FOOD_COLOR`,
`GRID_COLOR`, `SNAKE_COLOR`: Constants
representing colors used in the game.
9|Page
Event Listener:
¤ Listens for key down events to change the direction of
the snake based on arrow key presses.
Drawing Functions:
¤ `draw_field()`: Draws the game field, including the
background and grid.
¤ `draw_food()`: Draws the food on the canvas.
¤ `draw_snake()`: Draws the snake on the canvas.
10 | P a g e
Initialization and Game Start:
¤ `init()` is called to set up the initial game state.
¤ `step()` is called to start the game loop
11 | P a g e
BLOCK DIAGRAM
Main screen Game will automatically start when you
g open program
If you press down If you press up arrow If you press left arrow If you press right
arrow the snake will the snake will goes the snake will goes arrow the snake will
goes downward upward toward left goes toward right
If you lose the game you will see there a box having
your total score of this game and an option "ok" if
you click on ok the game will restart
12 | P a g e
TOOLS AND PLATFORM
13 | P a g e
DISCUSSION & CONCLUSION
DISCUSSION
By doing the project of html we are able to create simple game and
design it. In this project we able to provide the information related on
how we can use canvas and how we can specify JavaScript in HTML .
CONCLUSION
In conclusion, the basic snake game project in HTML provides a simple
yet functional platform for users to entertainment. The game which
designed is PC based so, it can't be lay on mobile phone or in tablet. But
it is must interesting game.
14 | P a g e
APPENDIX
This is the main screen that appears at the first after compiling and
running the program.
Figure 0-1
15 | P a g e
APPENDIX -2
This is the next screen when we lose the game or we are out from
game.
Figure 0-2
16 | P a g e
APPENDIX- 3
Figure 0-3
Figure 0-4
17 | P a g e
Figure 0-5
Figure 0-6
18 | P a g e
APPENDIX -4
Figure 0-7
Figure 0-8
19 | P a g e
Figure 9
REFERENCE
2) https://www.codingnepalweb.com
3) https://chat.openai.com
20 | P a g e
21 | P a g e