Remember the facebook game typing maniac? i'm trying to make that game using dev c++.. but i don't know how to put a line where a user will type the falling word before it hits the line.. i've only made the platform and the falling word..
You really need to have a game programming library to make this in so that you have use of threads and timers. Otherwise, this is going to be very difficult/impossible to make.
Will the user have to press enter? Otherwise, you will have to use non-line buffered input, which as Mats said, is easiest done with a game lib, or at least a graphics lib like SFML. I will be happy to help if you need it!
Ok, sure, in order for this to work, it will not have to press 0;
So, some psuedocode:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int main()
{
//instructions
//ready? Go!!
//choose word to fall from a list
//game loop:
//print the screen, walls, word, etc
//if keyboard hit, then use getch or some other way.
//add the key to the input string
//if input string -equals the word,
//Winner
//else
// update the board
//wait for a amount of time, probably a var
}
Note: THis is simple, doesn't work with more than one word.
The point of using the game programming library is you want to do this:
Print the screen
Test keyboards hits
Add key to the input string
Check winning conditions
Check losing conditions.
But you want to do ALL of this at the same time! A game programming library would let you do it like this (pseudocode):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
timer eventupdate == 0.02s
{
UpdateEvents(); //Update the falling word and anything else like
//charactors remaining or current typing speed
reset timer eventupdate;
}
timer print == 0.025s //40 frames per second
{
UpdateScreen();
CollisionCheck(); //Check if the falling word is in collision with the line.
LoseCheck(); //Check if the losing condition was met.
reset timer print;
}
timerkeytest == 0.05s //Allows for a typing speed above the current world record.
{
CheckKeyPress(); //Check for a new keypress
WinCheck(); //Check for a win
reset timer keytest;
}
So we don't exactly do everything at the same time, but update the events very quickly and in a sensible order so that it appears to the user that everything is seamless. I'm not sure how you would do this in standard C++ (without doing some advanced coding), although I'm sure you could achieve it with boost. It would be way easier using a library such as SFML or Allegro though, which has all the things that you need already done!