Thursday, July 30, 2009

Im working on a c++ battle system and i need the attack power to be random-ish?

i want it to hit like 5 to 20 attack power somethin like that





somethin with srand right?





an example code would be nice if possible

Im working on a c++ battle system and i need the attack power to be random-ish?
Does not look easy, may be you can contact a C++ expert live at website like http://askexpert.info/
Reply:Well that is not enough info. Also I personally don't know C++ but if you want help you would want to describe it more and post it on a C++ Forum.
Reply:Generally, random number generators give you a result from 0 to 1 (but never actually equal to 1). So you need to scale it....





To get an integer between 1 and 15, you need the equivalent of...





myrand = int(random() * 15) + 1





you need to look up the C++ runtime random number generation function and replace "random()" with that.


No comments:

Post a Comment