News: 11 March 2016 - Forum Rules

Author Topic: Funny story that happen in Computer programming 1  (Read 1967 times)

InfamousKnight

  • Sr. Member
  • ****
  • Posts: 321
    • View Profile
Funny story that happen in Computer programming 1
« on: December 09, 2012, 05:48:19 pm »
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:
Code: [Select]
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:
Code: [Select]
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

  • Submission Reviewer
  • Hero Member
  • *****
  • Posts: 595
  • CANT HACK METROID
    • View Profile
    • snarfblam
Re: Funny story that happen in Computer programming 1
« Reply #1 on: December 09, 2012, 07:48:26 pm »
Yeah, it's pretty hilarious when people have trouble figuring out how to program.

Ahem...