Solved

Doing stuffs in the background

Posted on 2000-05-13
8
185 Views
Last Modified: 2010-04-02
I am building a game, and I would like to run a function in the background.  While the user is playing the game, the user could type the [TAB] key to access a menu list where the user could save, load, quit, etc.  Also, while the user is playing the game, I would like to play a midi file in the background (Different function).  Simply put, when the user presses the [TAB] key on his/her keyboard, the program should run a certain function.  How would I accomplish this?
0
Comment
Question by:junkyboy
  • 4
  • 3
8 Comments
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2806631
What OS, compiler ar you using?
0
 

Author Comment

by:junkyboy
ID: 2806656
I'm using MS VisC++ 6.0 on a Win2k machine.
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 2806690
Natural way is: using threads.
About threads you can read in you Windows doc or see
 http://sourceware.cygnus.com/pthreads-win32/ for "pthreads"
If you want, i can send you simple example of using threads (write you EMail).
 
0
 

Author Comment

by:junkyboy
ID: 2806716
I'm creating a console program...  Would it still work???  Also, I wanted to try to make this simple and easy to follow...
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 2807044
Why not? You (psevdo)code may be as :
#include <process.h>
void Thread1 (PVOID pvoid)
{
     while (!EndOfThread())
        {
          .....
        }
     _endthread () ;
}
void Thread2 (PVOID pvoid)
{
     while (!EndOfThread())
        {
          .....
        }
     _endthread () ;
}
void Thread3 (PVOID pvoid)
{
     while (!EndOfThread())
        {
          .....
        }
     _endthread () ;
}
void main()
{
   static PARAMS params1 ;
   static PARAMS params2 ;
   static PARAMS params3 ;
   _beginthread (Thread1, 0, &params1) ;
   _beginthread (Thread2, 0, &params2) ;
   _beginthread (Thread3, 0, &params3) ;
}
0
 

Author Comment

by:junkyboy
ID: 2807079
Can you send me a sample code, and if I could work it out, I'll give you the points: korngerd@yahoo.com

Thanks
0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 50 total points
ID: 2807334
I 've sent you simple example.
If you want something more serious, see
http://www.codeguru.com/misc/thread_manager.shtml
If not example, not class from codeguru don't fit you, simple reject my reply.
Alex

0
 

Author Comment

by:junkyboy
ID: 2807888
I think I could work it out somehow.  Thanks for the sample!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now