News:

11 March 2016 - Forum Rules

Main Menu

Funny story that happen in Computer programming 1

Started by InfamousKnight, December 09, 2012, 05:48:19 PM

Previous topic - Next topic

InfamousKnight

So me and my friend were trying to figure out critical hits for our game we were making and I knew what to do and he didn't believe me.

He had code that said:

enemyhp -= rand() % 3
if enemyhp == 1 || enemyhp == 2 {
    enemyhp -= 50
}

That's not exactly what it was but the same idea.
He was a n00b and I had much more experience then he did and he didn't believe me that you needed another variable called like crit.

Something that makes more sense would be:

if crit == 1 || crit == 2 {
     enemyhp -= 50
} else {
    enemyhp -= rand() % 3
}

So, his code was like funny because it was saying in the English language: "If the enemies hp is either 1 or 2 really kill that enemy with a sledge hammer!"
As you can see, he thought he only needed that enemy variable.

Isn't that some funny code?

Yeah, he didn't believe me that he needed another variable to have critical hits. The teacher had to agree with me and tell him some.. sense if you know what I mean :P

snarfblam

Yeah, it's pretty hilarious when people have trouble figuring out how to program.

Ahem...