HZNM.COM
welcome to my space
X
Search:  
 HOME   How do I write a loop in c++ that can be interupted by getch?
How do I write a loop in c++ that can be interupted by getch?
Published by: rose 2010-03-16
Welcome to:hznm.com

  • I'm working on a game in which you manage an outpost during a middle ages war. The game is text-based, and it written in C++. However, I have a problem.
    The gameloop runs all the way through, sleeps for half a second, then runs again, etc. I want the gameloop to be allowed to do this until the player hits a key to do an action. The loop will then stop, process the action, and then continue.
    Orton's hum nulling software. Based on the LMS algorithm ::
    y')&&(c!='Y')) { fail=1; continue; } } outfp=fopen(outfn, "wb"); fclose(outfp); remove(outfn); exit(0); } /* Main loop - keep reading buffer-fulls and process nread) { printf("\nData write failed\n"); fclose(infp); fclose(outfp); getch())) { printf("\nUser interrupted processing\n"); fclose(infp);
    http://www.techlib.com/files/Humnul.c
    HOME
    This is important to the game, because I want the game to keep going by itself, and yet allow the player to input something whenever they want. I am using the getCH command, it looks like this:
    AW: IRQ2 interrupt | Analog Devices DSPs | DSPRelated.com::
    If you are, you can now access a powerful tool to discover new web sites. But the processor is not getting interrupted. .. But its not going to the if loop, because NewData is will need to write a C program to do the same. Alok . if (kbhit()){c = getch(); outportb(PORT1, c);} } while (c !=27);
    http://www.dsprelated.com/groups/adsp/show/1266.php
    HOME
    (nKey is a character variable)

    nKey = getch(); //my problem is that the program waits here
    switch ( nKey )
    {
    case 'A':
    //results of action
    break;
    case 'B':
    //results of different action
    break;
    }

    Thanks for the help!


  • If you want to keep doing some sort of game specific processing in the background while waiting for input you'll probably want to make it multi threaded (using pthread libraries for example). Maybe thread out the console input handler?


  • The program waits for getch() because the input buffer is empty. I don't think you realized that, but that's how text-based games are played. You ask for input, you wait for input.





  • Challenging Books For A 14 Year Old?
    First guitar : acoustic or electric?

    You are looking at:hznm.com's How do I write a loop in c++ that can be interupted by getch?, click hznm.com to home
  • two questions about piercings one for guys
  • just wondering
  • here 039 s my most difficult riddle can you get it
  • should he have told me this
  • is it a painful place to get a tattoo on your boob
  • why am i too scared to take a test
  • tattoo on my ribs
  • how fast does your car run
  • a few q 039 s about tattoos
  • i am 16 years old i want a tattoo i want to know where is the best place to get it a where its not painful
  • how serious could this be
  • any tips you can give me about having a girlfriend pls i need help despeately
  • where would you recommend a tat
  •  
  • just a sick joke
  • monthly period and it is very strange
  • where are the most painful and painless places to get tattooed
  • i am planing on getting a tattoo on my foot and i was wondering if that is really a painful place
  • sometimes i poop 3 4 times a day
  • where 039 s the best place to get your first tattoo
  • what can you tell me about tattoos
  • facts about tattoos
  • is this place really painful to get a tattoo
  • silly y names for hen night
  • do u have any answer to leg and arm pins and needles and loss of feeling in legs and arms constant neck pain
  • okay so what 039 s up with the human need to classify others
  • whats up with this girl please tell me whats going on with her
  • some tips on meeting some more decent 16 year old guys
  •  Homepage | Add to favorites | Contact us | Exchange links | LOGIN | Site map | 
    Copyright© 2008 hznm.com        Site made:CFZ