Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » digi-pet loop input question
Closed Thread
Old 02-22-2006, 06:03 PM   #1 (permalink)
 
True Techie

Join Date: Jul 2004

Posts: 235

crazybeans

Default digi-pet loop input question

Ok, my programming skills are only fairly good (I understand loops and most basic c++ code). I am writing a program for a digi-pet that displays text-based images of the pet and uses a loop to determine if the pet is hungry, bored, happy, sad, etc.

My question is in the user input area. I wish to allow the user to input a number 1-4 while the loop for the game is running but wish to set it up so if the user doesn't respond in a certain time (eg, a second) the loop just continues. This would allow the pet to get hungry when you don't feed it after a certain amount of loops and this would allow the pet to become bored if you walk away from the PC. Not feeding it would mean that the program would be able to accept a "keypress" and if one is not established, it will move on, making the pet hungrier.

Is there any way to do this using the standard header files in C++? Remember, I am not using win32 API on this program so am only looking for regular code. I have searched every corner of the web (maybe not well enough) and cannot find anything to answer my question. I would use a "cin" statement but that type of input stops the loop until the user enters information. This is unacceptable because the pet would not function without user input EACH time around the game loop. Any help is much appriciated.
__________________
Come visit a new technology and digital image arena website where you may compete in monthly image contests and chat about technology. t3ch.l33t is currently searching for members to help manage different areas of the site. t3ch.l33t Image Arena Home

http://img.photobucket.com/albums/v3...ch_l33tsig.jpg
crazybeans is offline  
Old 02-24-2006, 07:13 AM   #2 (permalink)
 
Newb Techie

Join Date: Aug 2005

Posts: 22

Cache

Default

It's a shame then that you don't want to use the Win32 API. Using threads would allow the pet to function at the same time as the input operation. There are also events and timers available.
Cache is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On