Thread: all-endurant command

  1. #1
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942

    all-endurant command

    is there a way to make a command usable throughout the whole program(ie. During the whole program, if the user types in save, it will save their game)

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Can you be a little more vague
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942
    for example a game. say the user is walking and has to quit their game. how could they save whenever they want, anytime during the whole proggy.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Still too vague - what exactly are you trying to do? Or are you asking how games save and load?

    gg

  5. #5
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942
    I want the person to be able to save at any time in the game that they want at all. Would I have to have an if command for every time the computer asks for input?

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >(ie. During the whole program, if the user types in save, it will save their game)
    You could do this any number of ways. An easy solution would be to save the current game any time the quit option is selected (be sure to confirm that the user wants to save). Another option is to maintain a second thread that handles "any time" input and acts accordingly. I could make better suggestions if I knew the design of your game, if it is based on text commands like a MUD then all you need to do is create a save command. If it is an action game then you should probably offer an option to save at regular intervals or have a menu option or a hotkey like Ctrl+S that can be accessed quickly without pausing the game or that sets the game to a pause state.

    >Would I have to have an if command for every time the computer asks for input?
    A command table of function pointers would be better. That way you can simply say something like:
    Code:
    command[get_index ( cmd )]();
    Instead of a long string of conditionals. Then all you have to do is add a save command to the table and you're done.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 10:43 AM
  2. problem with "touch" command in c program
    By Moony in forum C Programming
    Replies: 10
    Last Post: 08-01-2006, 09:56 AM
  3. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  4. Ping problem
    By bladerunner627 in forum C++ Programming
    Replies: 12
    Last Post: 02-02-2005, 12:54 PM
  5. exe files in -c- language
    By enjoy in forum C Programming
    Replies: 6
    Last Post: 05-18-2004, 04:36 PM