TABLE OF CONTENTS
1. 2. i. 3. 4. 5. 6. 7.
Introduction Proposed system Description ii. System requirements Requirement Analysis System Design Source code Testing Future scope of project
INTRODUCTION The following is an example game written in C based on the game called 'snake' which has been around since the earliest days of home computing (I 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. .
Playing the game You can download the executable to try out the game without having to compile it if you wish. Download it by clicking here - it is about 123k in length.Note that on faster PCs, it will be unplayably fast, so you will need to re-compile it with the pause_length pause_length constant set to a higher higher value. My PC is about 350MHz 350MHz and it is OK.To move the snake, use 'a' for up, 'z' for down, 'o' for left and 'p' for right. Again, there are constants you can change if you want to alter these settings. Press 'x' to exit the game at any time. The aim of the game is to collect the dots (food) and avoid the obstacles (crosses, borders, and the snake itself). As you collect food, the snake gets longer, so increasing your likelihood of crashing into yourself. When you have collected enough food, 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 the caps lock on, otherwise the keys will fail to respond
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 fact factor orss whil whilee desig designi ning ng a new syst system em.. It keep keepss into into the the acco account unt the the Econ Econom omic ical al bandwidth available for the new system. The foremost thing that is taken care of is the Need and Requirements of the User. DESCRIPTION Before developing software we keep following things in mind that we can develop powerful and quality software PROBLEM STATEMENT Problem statement was to design a module: o Which is user friendly o Which will restrict the user from accessing other user’s data. o Which will help user in viewing his data and privileges. o o Which will help the administrator to handle all the changes. FUNCTIONS TO BE PROVIDED: The system will be user friendly and completely menu driven so that the users shall have no problem in using all options. o The system will be efficient and fast in response. o The system will be customized according to ne eds. o It is a game which can play by anyone It is easy to use o
SYSTEM REQUIRMENTS Oper Operat atin ing g syst system em:: MS Win Windo dows ws XP XP or Wind Window owss Vist Vistaa Language: C Language Processor: Pentium IV Processor RAM: 512 MB Hard disk: 5 GB
REQUIREMENT ANALYSIS
This process is adopted when management of the system development, Personnel decide that the particular system needs improvement. The system development life cycle is the set of activities, carried out by the analyst, designers and users to develop and implement a system. The systems that are present in the nature follow common life cycle pattern. For example consider the raining system. Initially the rain falls into the river, river flows into sea, the sea water evaporates to form vapors, the vapors form clouds which again bring rain. Similarly consider a man made system initially a system is analyzed, designed and made operational by the efforts of system analysis. After successful operation or a numb number er of user users, s, the the syst system em beco become mess less less and and less less effe effect ctiv ivee by chan change ge in the the environ environmen ment. t. So these these changes changes have to be incorp incorpora orated ted in to the system system by minor minor modifications. So the general activities from the life cycle of the system are given below: Select ion and identification of the system to be studied • Preliminary study • Defining the system • Design and development of the system • Implementation of the system •
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 procedu procedural ral detail detailss necessa necessary ry for the implem implement entati ation. on. Here Here we use Flowch Flowchart art 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 requirements. START
enter the main menu of snake game
Enter your
choice ?
Enter name
Play game
Do you want to continue?
STOP
quit
SOURCE CODE #include
#include #include /* prototypes */ void draw_line(int col, int row); void show_score(); void add_segment(); void setup_level(); /* constants */ const int maxrow=15, maxcol=77; const int snake_start_col=33,snake_start_row=7; const char up_key='a', down_key='z', left_key='o', right_key='p'; const int pause_length=500000; /* global variables */ int score, snake_length, speed, obstacles, level, firstpress, high_score=0; char screen_grid[maxrow][maxcol]; char direction = right_key; struct snake_segment { int row,col; } snake[100]; void main() { /* Variable declarations within main() only */ char keypress; do /* restart game loop */ { obstacles=4; level=1; score=0; speed=14; randomize(); /* Ensure random seed initiated */ setup_level(); /* main loop */ do { for (int i=0;i<(speed*pause_length);i++) int j=1+i; /*pause*/ /* If key has been hit, then check it is a direction key - if so, change direction */ if (kbhit()) { keypress=(char)getch(); if((keypress==right_key)||(keypress==left_key)|| (keypress==up_key)||(keypress==down_key)) direction = keypress; } /* Add a segment to the end of the snake */ add_segment();
/* Blank last segment of snake */ gotoxy(snake[0].col,snake[0].row); cprintf(" "); /* ... and remove it from the array */ for (int i=1;i<=snake_length;i++) snake[i-1]=snake[i]; /* Display snake in yellow */ textcolor(YELLOW); for (int i=0;i<=snake_length;i++) { gotoxy(snake[i].col,snake[i].row); cprintf("O"); } /* keeps cursor flashing in one place instead of following snake */ gotoxy(1,1); /* If first press on each level, pause until a key is pressed */ if (firstpress) { while(!kbhit()); firstpress = 0; } /* Collision detection - walls (bad!) */ if ((snake[snake_length-1].row>maxrow+1)||(snake[snake_length-1].row< ((snake[snake_length-1].row>maxrow+1)||(snake[snake_length-1].row<=1)|| =1)|| (snake[snake_length-1].col>maxcol+1)||(snake[snake_length-1].col<=1)|| /* Collision detection - obstacles (bad!) */ (screen_grid[snake[snake_length-1].row-2][snake[snake_length-1].col-2]=='x')) keypress='x'; /* i.e. exit loop - game over */ /* Collision detection - snake (bad!) */ for (int i=0;i1)) speed--; /* increase speed every 5 levels */ setup_level(); /* display next level */ } } } while (keypress!='x');
/* game over message */ if (score > high_score) high_score = score; show_score(); gotoxy(30,6); textcolor(LIGHTRED); textcolor(LIGHTRED); cprintf("G A M E O V E R"); gotoxy(30,9); textcolor(YELLOW); cprintf("Another Game y/n)? "); do keypress=getch(); while((keypress!='y')&&(keypress!='n')); } while (keypress=='y'); void setup_level() { /* variables local to setup_level() */ int row,col; /* Set up global variables for new level */ snake_length=level+4; direction = right_key; firstpress = 1; /* Fill grid with blanks */ for(row=0;row
cprintf("|"); } draw_line(1,maxrow+2); show_score(); gotoxy(2,maxrow+5); textcolor(LIGHTRED); cprintf("~~ SNAKE GAME~~ Left: %c, Right: %c, Up: %c, Down: %c, Exit: x. Any key to start.", left_key,right_key,up_key,down_key); } void draw_line(int col, int row) { gotoxy(col,row); textcolor(LIGHTBLUE); for (int col=0;col
TESTING
Testin Testing g is the major major contro controll measur measuree used used during during softwa software re develo developme pment. nt. Its basic function function is to detect detect errors errors in the software. During requirement requirement analysis analysis and design, the output is a document that is usually textual and no executable. After the coding phase, computer programs are available that can be executed for testing purpose. This implies that testing not only, has to uncover errors introduced during coding, but also errors introduced during previous phase. Thus the goal of testing is to uncover the requirements, design and coding errors in the programs. So after testing the outputs of my project are as follows: Main menu screen
If snake crosses the line then it terminate
FUTURE SCOPE OF THE PROJECT
Our proje project ct will will be able able to impl implem emen entt in future future afte afterr maki making ng some some chan changes ges and modifications as we make our project at a very low level. So the modifications that can be done in our project are: IT can be made with good graphics. And we can add more options