   newbie question
  Hi,I''m a complete C++ programming newbie although I have quite a bit of experience in programming in general, so this will more than likely sound incredibly rudimentary.Basically I''m writing a little DOS game in CS where there is a person onscreen that can move left and right and shoot. The code for determining his movement looks something like this:void main_game() {  int key = getch();  while (key != ESC) {if (key == leftarrow) {   erase_person(x, y);   x-=1;   drawperson(x, y);} else if (key == rightarrow) {   erase_person(x, y);   x+=1;   drawperson(x, y);} else if (key == spacebar) {   shootgun(x, y);}  }}A problem that I''ve come across is that when I press shoot that one action is the only thing being processed by the computer until it is finished. So, for instance, if I wanted to both shoot and move left at the same time, I couldn''t.Is there a way to make it possible for both these processes to be computed at the same time? And does anyone know of a link to a good "basics" game programming tutorial where I could pick up information like this for programming DOS games?Thanks,Intaglio  
  Get rid of the else statement, cause with that you cant be shooting and moving. I suggest you really just buy some books. Good luck. Maybe stick the movement in a switch(int var) or someting.   ;  Maybe your shotgun function is making the bullet and then moving it?  If thats the case, you shouldn't do this, because your input loop will not continue to run until the shotgun () function finishes.  A typical game loop (in pseudo code) for the game you described should look like this:   do {  getinput ();  process input ();  updateplayer ();  updatebullets ();  update enemies ();  drawGame ();} while (playerIsNotDead && inputIsNotEscape)  All that should happen in the process input section is that you update variables that tell you what the velocity of the player is (if you keep adding one to velocity as long as the button is held down or until you reach max velocity, you can get smoother motion, because the player will appear to accelerate, instead of meandering along at the same speed).  If the player hits the firing button, you need to make a new bullet object, setting its position and its velocity to the appropriate values.  If you want to allow more than one bullet, use a linked list of bullets, or an array for a fixed number of bullets.Now in updateplayer () you add the player's current velocity, check for collisions with enemies or solid areas of the map, and move the player.For update bullets, for each bullet, add the bullet velocity to the bullet, check for collisions with enemies (kill them as necessary) and update the bullet position.You basically do the same thing for the enemies, although they probably have much more sophisticated movement ai than the bullets.Finally once you are all done, you draw the map, the player, the bullets, and the enemies (and any other objects you might have created, like explosions or power ups).The idea is basically that you have all objects, whether they are players, enemies, bullets, explosions, or whatever store information about their states (like what direction am i going, am i jumping, am i dying, doing a super move etc.)  and then you update the properties of all objects in the game based on their current states.  Collisions with other objects, user input, or the passage of time can change objects from one state to another (such as the player pushing right making him move right) or destroy objects (like when a bullet hits an enemy) or spawn new objects (such as leaving a power up behind when an enemy dies).Anyways, I hope that made sense, and I hope it helps!Edited by - invective on May 2, 2001 10:28:46 PM  ;  Your problem is that getch() will only return one keypress at a time, so if you''re holding 2 keys down, only one of them will be registered.Better to use some other key detection function which will give you the state of all keys. Not sure how to do this in DOS, but under windows you could use GetAsyncKeyState, egif (GetAsyncKeyState(VK_LEFT)){ ----;}if (GetAsyncKeyState(VK_RIGHT)){ ---;}if (GetAsyncKeyState(VK_SPACE)){---;}etc. This will allow you to process multiple keys at once. However getch() will not allow to do this. Don''t know the equivalent function in DOS.;  Yeah, Intaglio, Mikey is right. getch() only processes one key at a time. What you will have to do is create a keyboard handler that detects multiple key presses. The general step for this is1. Get and store normal keyboard handler2. Replace it with your own3. Use it in your game4. Restore ordinary one before your exit the gameYou will have to search the net for how to do this. There is no exact DOS function that does this. You have two options. 1. Write your own2. Use a lib.Sorry I can''t give more details, but I am still a DOS coder and it took me years to discover how to write one and where to find decent information on this.  But the only way to write a DOS game with proper keyboard handling is through the use of a handler. C/C++ functions can''t do it unless maybe u work in Windows, or DirectXDark Star ;  What compiler are you using? Thats the main question here.It it''s some old borland than the function you want is get/setvect  ;  if you are talking to me I use DJGPP and it has some wierd long dpmi function but it is not as simple has borland''s ways, that''s for sure. I can''t remember the code off the top of my headDark Star    ;  Does Allegro allow dos programs to register more than one keypress?  ;  Check out the book Tricks of the Game Programming Gurus.  It''s a book with a variety of info on how to do dos games in c.  http://www.amazon.com/exec/obidos/ASIN/0672305070/jaylagare/102-0403273-3042535