couple questions for newb

This is a discussion on couple questions for newb within the C++ Programming forums, part of the General Programming Boards category; The questions are in the following: 1.)Is there a timer function?what is it and it's prototype<the #include> 2.)How do you ...

  1. #1
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269

    couple questions for newb

    The questions are in the following:
    1.)Is there a timer function?what is it and it's prototype<the #include>
    2.)How do you let 2 buttons able to be pressed at once<for two player games>
    3.)since when you type a code, it gets real long. Is there a function to open up another script to make your game code easier?


    Please answer a.s.a.p. !!!!!!!!

  2. #2
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753

    hehe

    "Program real or go", eh?

  3. #3
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    yeah, I need help with that second question. How to do two getch()'s at once? But I don't really need help with that...I'm doing directX anyways. for you, bluehead, use why don't you use header files? and for your timer, you can use the Delay() function in dos.h.
    Last edited by Xterria; 11-20-2001 at 08:23 PM.

  4. #4
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    FINE!!
    1.)Is there a timer function?what is it and it's prototype<the #include>
    1.)Is there a timer function?If yes, what is it and it's header file?
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  5. #5
    wierd guy bart's Avatar
    Join Date
    Aug 2001
    Posts
    87
    Is there a function to open up another script to make your game code easier?
    what do you mean?

  6. #6
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    your typing up a code, right?
    well, when you type it up, it gets all confusing and messy. Is there a way to make to diferant 'texts' and make one to load to the other

    for example:
    Your making a two player game.
    you wrote the one player version.
    you open up a new file and do the two player version.
    then you let the user choose which way he wants in the one player version. Is there a way to open the two player version or do you have to do it all in one file?

    THERE. happy now?
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  7. #7
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    1) windows has all sorts of timers. there is also <time.h> or <ctime> that contains functions you might find helpful.look it up in your help files or fav. text book.
    2) said this a million times.... this is the last time as this info is on the faq board.... GetAsyncKeyState() from <windows.h>. look it up at msdn
    3) look into oop and/or splitting your code into separate modules.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  8. #8
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753

    yeah

    for your 'two player' example, it shouldn't be too messy if you did good coding. You should have all or most of the actions being done in functions. For example, the player's move, the computer's move, etc. You can put all of those functions into some header files. Then, of course, you include that header file in your main program. Then you should just ask to play 1 player, 2 player, computer, whatever. Then have have a switch/case statement and depending on what they enter, call the certain function. You can call all of the functions like player moving and stuff one after another, or you could put them all into one function called something like void StartOnePlayer();. void StartComputer();. void StartTwoPlayer();. So you have all of the functions like playermove, computermove, etc. in a header file. You can also make a function called StartOnePlayer or something and put that into the header file also. Then your main program could look something like this:

    #include <Game.h> //Header file you made
    #include blah blah
    blah blah

    int main()
    {
    cout<<"1) 1 player 2) 2 player"<<endl;
    int choice;
    cin>>choice;
    switch (choice)
    {
    case 1:
    StartPlayerOne();
    break;
    case 2:
    StartPlayerTwo();
    break;
    default:
    cout<<"You idiot, either 1 or 2";
    break;
    }
    return 0;
    }

  9. #9
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    [start]
    Ok.....got that covered. now is there a 'goto' command
    <like in QBasic, you make it 'goto 1' and it goes to the 1 spot>
    if you need more info just ask
    [/start]
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  10. #10
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753

    hmm...

    Actually I have never used a 'goto' before. I have read a little about it though. From what I've heard, you can achieve the same thing without it, and its better practice. Overall, I read you shouldn't use them. That came from deitel & deitel's 3rd edition c++ book. And here's just some advice: get "Beginning Visual C++ 6" by: Ivor Horton....that is if you're using vc++ 6. It's awsome, it teaches windows programming in it as well as all the c++ stuff. Its real nice, im using it now.

  11. #11

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Couple of Questions About Classes
    By bengreenwood in forum C++ Programming
    Replies: 3
    Last Post: 05-20-2009, 02:50 PM
  2. Couple of questions about XOR linked lists...
    By klawson88 in forum C Programming
    Replies: 5
    Last Post: 04-19-2009, 04:55 PM
  3. Couple of simple directdraw questions.
    By Deo in forum Game Programming
    Replies: 3
    Last Post: 05-25-2005, 07:55 AM
  4. Studying for Final, Couple Questions...
    By stewade in forum C Programming
    Replies: 4
    Last Post: 05-10-2004, 05:02 PM
  5. A couple of Questions
    By johnnabn in forum C++ Programming
    Replies: 4
    Last Post: 02-24-2003, 09:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21