Document Snake Game
Document Snake Game
of
We hereby declare that the details enclosed in the project proposal entitled “SNAKE
GAME” carried out by us in partial fulfilment of the requirements for the award for
degree in computer science & engineering are true and correct to the best of our
knowledge and belief is a record of an original work done by us under the guidance of
MISS SUBREENA AYUB KHAN, faculty of computer science and engineering
department and it is also declare that this report has been prepared for academic
purpose alone and has not been/will not be submitted elsewhere for any other purpose.
Semester-1st
Team Names-AFRAH
ALISHBA
IQRA
MANAHIL
SEHAR
ACKNOWLEDGEMENT
We are highly thankful for your active support, valuable time and advice,
whole-hearted guidance, sincere cooperation and painstaking involvement during the
study and in completing the assignment of preparing the said project within the time
stipulated.
Lastly, we are thankful to all those, particularly the various friends, who
have been instrumental in creating proper, healthy and conductive environment and
including new and fresh innovative ideas for us during the project, their help, it would
have been extremely difficult for us to prepare the project in a time bound framework.
DECLARATION
ACKNOWLEDGEMENT
CONTENTS:
CHAPTER: 1 INTRODUCTION
CHAPTER: 2 MAKING OF THE GAME
CHAPTER: 3 HOW TO RUN THE PROJECT?
CHAPTER: 4 PLAYING THE GAME
CHAPTER: 5 PROPOSED SYSTEM
i) Description
ii) System Requirements
CHAPTER: 6 REQUIREMENT ANALYSIS
CHAPTER: 7 SYSTEM DESIGN
CHAPTER: 8 SOURCE CODE
CHAPTER: 9 EXPLANATION
CHAPTER: 10 BASIC SNAKE GAME CODE FEATURES
CHAPTER: 11 TESTING
CHAPTER: 12 FINAL OUTPUT
CHAPTER: 1
INTRODUCTION
The following is an example game written in C++ based on the game called
'snake game’ which has been around since the earliest days of home
computing (1 can remember writing a version of it for my ZX81), and has re-
emerged in recent years on mobile phones.
It isn't the world's greatest game, but it does give you an idea of what you
can achieve with a relatively simple C++ program, and perhaps the basis by
which to extend the principles and create more interesting games of your own.
The aim of the game is to collect the dots (food) and avoid the obstacles
(crosses, borders, and snake itself). As you collect foods, the snake gets
longer so, increasing your likelihood of crashing into yourself. When you have
collected enough foods, you progress onto the next level, where your snake
gets longer, and the amount of food to collect to progress through the level
gets larger. You get scored according to the length of the snake and the
number of ‘x’ obstacles on the screen. The speed increases every 5 levels.
You get a bonus when you complete the level of 1000, increasing by 1000
each level (e.g. complete level 5, you get a 5000 bonus). There is no concept
of lives. Once you hit an obstacle, that’s it, game over. Make sure you do not
have caps lock on, otherwise the keys will fail to respond. To move the snake,
use ‘w’ for up, ‘s’ for down, ‘a’ for left and ‘d’ for right. Again, there are no
constants you can change if you want to alter these settings. Press zero (0)
key to stop or ‘x’ to end the game.
CHAPTER: 5
PROPOSED SYSTEM
The following documentation is a project the “Name of the term paper
allotted”.it is a detailed summary of all the drawbacks of the old system and
how the new proposed system overcomes these shortcomings. The new
system takes into account the various factors while designing a new system. It
keeps into the account the Economical bandwidth available for the new
system, the foremost thing that is taken care of is the Need & Requirement of
the User.
DESCRIPTION:
Before developing software, we keep following things in mind that we can
develop powerful & quality software.
PROBLEM STATEMENT:
● Which will restrict the user from accessing other user’s data.
FUNCTIONS TO BE PROVIDED:
The system will be user friendly and completely menu driven so that no
problem in using all options.
● It is easy to use.
SYSTEM REQUIREMENTS:
Operating systems: MS Windows XP or Windows Vista
Language: C++ language
RAM: 512 MB
CHAPTER: 6
REQUIREMENT ANALYSIS
● Preliminary study.
CHAPTER: 7
SYSTEM DESIGN
Then we began with the design phase of the system. System design is a
solution, a “HOW TO” approach to the creation of a new system. It translates
system requirements into ways by which they can be made operational. It is a
translational from a user oriented document to a document oriented
programmers. For that, it provides the understanding and procedural details
necessary for the implementation. Here we use flowchart to supplement the
working of the new system. The system thus made should be reliable, durable
and above all should have least possible maintenance costs. It should
overcome all the drawbacks of the Old existing system and most important of
all meet the user’s requirements.
CHAPTER: 8
SOURCE CODE
Let's take the source code of the snake game in C++.
#include<iostream>
#include<conio.h>
#include<windows.h>
// Function prototypes
void setup();
void Draw();
void Input();
void Logic();
void Logic2();
int x, y, fruitX, fruitY, score; // Variables for snake position, fruit position, and
score
int tailx[100], taily[100]; // Arrays to store the tail coordinates
int ntail; // Length of the snake's tail
int main()
{
char ch;
switch (ch)
{
case 'S':
setup();
while (!gameOver)
{
Draw();
Input();
Logic();
_sleep(30);
}
break;
case 'H':
setup();
while (!gameOver)
{
Draw();
Input();
Logic2();
_sleep(30);
}
break;
default:
cout << "Invalid!! Please Select the Given Options.";
break;
}
getch();
return 0;
}
tailx[0] = x;
taily[0] = y;
tailx[0] = x;
taily[0] = y;
CHAPTER: 9
EXPLANATION
About the Application:
CHAPTER: 10
▪ Basic GUI
▪ The project contains basic GUI that display the actual gameplay
of the game.
▪ User-friendly Interface
▪ This project was design with a simple user-friendly interface.
▪ Basic Controls
▪ This project uses a basic control function so that player can easily
be playable.
CHAPTER: 11
TESTING
CHAPTER: 12
FINAL OUTPUT
Following is the output of the above source code: