not sure if possible

This is a discussion on not sure if possible within the C++ Programming forums, part of the General Programming Boards category; in the if statement, is there anyway to do it so its like... u type PUNCH and it says, if ...

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    132

    not sure if possible

    in the if statement, is there anyway to do it so its like...

    u type PUNCH and it says, if my health is within 12 above opponents health, 100 % it hits them, 11 above, 90% etc... and if 1 lower, 40%, 10 lower 2% ... etc..

    and depending if strength is 10 above it does + 10 % of the original damage to opponent, 5 above does 5% extra, etc...

    please let me know if its possible cuz its bugging me.

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,807
    Yes it is possible.
    Woop?

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    35
    Quote Originally Posted by prog-bman
    Yes it is possible.

    I concur

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    ^^^I agree.

  5. #5
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,714
    However the if statement is likely to be very complicated by itself. Work out the logic on paper, and then after that, shove it in a function. That way you can make tests like this:

    Code:
     enum HIT { hit_missed, hit_weak, hit_strong, hit_fierce, hit_critical }; 
    // or something. Street Fighter help us
    
    HIT accuracy( void ) {
         // ... This is where you're thinking comes in
         // with your careful logic
    }
    
    switch ( accuracy() ) {
       case hit_critical:
           // detrement the player's health here or K.O?
       break;
       case hit_fierce:
           // detrement health by so much here...
       break;
       case hit_strong:
           // again...
       break;
    };
    and so forth.
    Last edited by whiteflags; 05-25-2006 at 10:26 PM. Reason: anyone else really hate how cases don't break on their own?

  6. #6
    Registered User
    Join Date
    Apr 2006
    Posts
    132
    ok thanks people. just wanted to know if it was possible, ill look into giving it a go soon. thanks.

Popular pages Recent additions subscribe to a feed

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