Reply to post:

You've seen things people wouldn't believe – so tell us your programming horrors

Anonymous Coward
Anonymous Coward

My most ridiculous bug. While at uni I was working on a 2d side scrolling game, I got it all finished, and the night before it was due to be handed in my PC crashed. On reboot, the project was corrupted, and I had, in true student fashion, not done a single backup.

I worked through the night and got the entire game working again except one problem. the player character wouldn't die. Or rather, they wouldn't lose a life. All the code was there, but in my sleep deprived state I couldn't identify the bug.

onDeath()

{

if ( --life =< 0);

{

gameOver();

}

}

I do not know why, but the compiler we were using decided that, if you have a ; on the end of an if statement, it would decide the if statement was completed, and skip the block below. So my gameOver code was never triggered. And because the compiler thought this was valid code, it was never flagged as an error. I spent over an hour trying to debug a semi-colon of stupidity.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon