Which "damage" variable anyway? There seem to be a lot of them.
And boy oh boy, it might be possible to write an entire book about good programming principles using this as a field case.
In particular, try to move functionality (such as recurring calculations (or even non-recurring)) inside their own functions. Functions should generally be short and only do one particular task (and do it well).
Some more white space would also help readability. Give the curly braces their own line, at least.
I hope this helps someone... After looking through this, I feel like you really need to rethink your design thelateryears (embrace OOP!) This is going to be a bitch to debug in like three days. Also, please format your code with code tags <>
Ok. thelateryears, you need to learn to use the code tags. they're on the right-hand side of the text box that you type into when you leave a comment. Also, you need to format your code better; give curly braces their own line, and if you aren't going to do that, atleast space things out, so that certain things line up, like the following:
1 2 3 4 5 6 7
int x = 0, y = 9;
if ( x == 0 && y == 8) { cout << "HELLO!" << endl; }
if ( x == 9 && y == 9) { cout << "GOODBYE!" << endl; }
if ( x == 0 && y == 9) { cout << "GOOD MORNING!"<< endl; }
if ( x == 9 && y == 0) { cout << "GOOD NIGHT!" << endl; }
//notice all of the variables match up, if statements match up, the "<< endl;"'s match up, etc.
just please, for the love of god, make your code easier to read :)
extra note: Don't use classes where they aren't really needed; classes can sometimes make things confusing... just make stand-alone functions. I don't mean to be mean, but I just HATE it when people make their code hard to read and understand. But... You're coding for Pokemon, so I want you to keep going :)
Don't use classes where they aren't really needed; classes can sometimes make things confusing...
I completely disagree! For any program that requires this much code to do something relatively small, classes can make things a whole lot easier to explain, code, debug, and modify. I mean in my opinion (although there is a saying about those) a Pokemon is practically begging to be represented with a class having all these stats and what not.
The damage still is 0 r is not geting subtracted from the hp
Without looking to hard*, in Pokemon::dmgcalc() you have *(stat[3]/d.stat[4]), stat looks to be an int[] so the likely result of the afore mentioned code would be to multiply by zero, thus making the overall result zero.
* your coding style is appalling, I can see why you are having problems. Use whitespaces, format your code, use better names, post your code with code tags [code][/code] etc.
Grey Wolf was a bit harsh with that phrase... but he has a point. You really need to practice code structure. Basically, make it look nice, line things up, WHITE-SPACE.
grey wolf is not that harsh at all- but too much whitespace makes it hard to follow along the program for me.
Put it this way- would you like it if i put all my code on one line?
I write my c0ode like that already- the edit box erases all initial spaces.
i have a problem with the variable "damage" in here.
thelateryears wrote:
All of you are obsessed about whitespace
Are you beginning to see the correlation here? You came to us asking for help, we told you how to avoid problems in the future. We aren't obsessing, we are trying to help you. I could care less how you write your code, just don't ask me to debug it!