Help needed in a C++ program

Started by
0 comments, last by Brother Bob 12 years, 1 month ago
Hi Everyone,

I am Actually trying to make a simple C++ game in which some random alphabets will fall down and when we press one of those random alphabets keys the aphabet should disappear.

The problem that i am facing in making this code is that when i am using some function to read the key input that causes my program to wait for the user's input and hence my program comes to a stop till i press some key.

I want some logic/function which will stop the execution of my program.

Can you please suggest any such function or some logic that i can use in this program.

Please note my compiler is Microsoft Visual C++ 2010 and i am not that familiar with the functions in windows.h header file.

Thanks in advance.

Any pointers would be greatly appreciated.


My program is somewhat like this

/*Including Header Files*/
#define _CRT_SECURE_NO_DEPRECATE
# include <iostream>
# include <conio.h>
# include <Windows.h>

int i=0,y=1;
char words[5];
int pos[5];
char c;
void gotoxy(int x,int y);
void Movement();
int readkey(void);

void random()
{
int n;
for (int t=0;t<5;++t)
{
n= rand() % 26;
pos[t] = n % 2;
words[t] = (char)(n+65);
}
}

void main()
{
random();
for(y=0;y<10;y++)
{
for(i=0;i<5;++i)
{

gotoxy(3*i,pos);
printf("%c",words);
pos=pos+1;
if(y>0)
{
gotoxy(3*i,pos-2);
printf("%c",' ');
}
}
Sleep(1000);
}
getch();
}


void gotoxy(int x,int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
Advertisement
Cross post, continue here.

This topic is closed to new replies.

Advertisement