any small game in c++

Status
Not open for further replies.

ehsanelahimirza

Full Member level 6
Joined
Feb 24, 2006
Messages
334
Helped
28
Reputation
56
Reaction score
7
Trophy points
1,298
Activity points
3,570
snake game in turbo c++

hi all

plz give any small game in c++ code

which is based on classes, linklist and structures

plz help me to give the code or ideas
 

small game version c++

you can simply devolop a snake game in C++. If u r devoloping in Turbo C u have to include graphics library. There will be sample programs to show how to use graphics in C.

There is no need to use linked list for this. But if u want u can use.

Shape of the snake can be created using rectangles. There are functions to create rectangle. U can have 7 or 8 rectangles on the screen one after the other.

Let the postion of the 1st rectangle is (x,y). U can create the rectangles like rect(x-5, y-5,x+5,y+5). The other rectangles can also be created like this. Thus we got a snake that is not moving.

We have to store all these coordintes in an array or linked list.
if it is a linked list node can be like this

struct node
{
int x; //x-coordinate
int y; //y coordinate
struct node * next; //pointer to the next node
}

Create a linked list of fixed number of nodes that corresponsds to the length of snake.

Now we have to move the snake. There is one functin clrscr(), it will clear the screen. We have to move the snake a step ahead and draw the snake again.

Now control the direction according to the keyboard input.

This is the idea. rest is upto u.
 

check the following code in c++...i can send u the code for any other knid of game if yr interested........sidra_maheen84@yahoo.com
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…