What I want to do is have a predefined battle function, I can code the function, all I need to know how to do is have the function sitting there, so when I call it, all it takes is one or two variables to set up and go. So every time I don't have to input damage calculators, defense algorithms etc.
Help would be greatly appreciated, thanks.
valestrom
17
Junior Poster in Training
Recommended Answers
Jump to PostWhat I want to do is have a predefined battle function, I can code the function, all I need to know how to do is have the function sitting there, so when I call it, all it takes is one or two variables to set up and go. So every …
Jump to PostYou're essentially describing the purpose of a function.
Here's an example attack function.
bool attack(int atk, int def) { return (atk > def); }
Here, the algorithm is simple: return true if the attack value is more than the defense value; otherwise, return false.
Now you …
All 5 Replies
pseudorandom21
166
Practically a Posting Shark
Mouche
valestrom
17
Junior Poster in Training
Mouche
valestrom
17
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.