Came across this the other day and thought I would share on how not to write game code:
http://hg.icculus.org/icculus/lugaru/file/97b303e79826/Source/GameTick.cpp#l7276
Came across this the other day and thought I would share on how not to write game code:
http://hg.icculus.org/icculus/lugaru/file/97b303e79826/Source/GameTick.cpp#l7276
I hope they're doing much much better with Overgrowth :D
quick skim...
seriously?!...
if(i<numplayers&&i!=k&&player[k].skeleton.free==0&&player[i].skeleton.oldfree==0&&(player[i].targetanimation==jumpupanim||player[k].targetanimation==jumpupanim)&&(player[i].aitype==playercontrolled||player[k].aitype==playercontrolled)&&((player[i].aitype==attacktypecutoff&&player[i].stunned<=0)||(player[k].aitype==attacktypecutoff&&player[k].stunned<=0))){
if(findDistancefast(&player[i].coords,&player[k].coords)<10*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)&&findDistancefastflat(&player[i].coords,&player[k].coords)<2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)){
if(player[i].targetanimation==jumpupanim&&player[k].targetanimation!=getupfrombackanim&&player[k].targetanimation!=getupfromfrontanim&&animation[player[k].targetanimation].height==middleheight&&normaldotproduct(player[i].velocity,player[k].coords-player[i].coords)<0&&((player[k].aitype==playercontrolled&&player[k].attackkeydown)||player[k].aitype!=playercontrolled)){
lolwut?
It's the god method pattern! ![]()
10,000 lines.
A loathing for whitespace.
Globals all over the place.
Only god I'm seeing here is Cthulhu.
nuke it....it's the only way to be sure.
edit: this is so bad, i have to edit this post, because i feel that quote does not do justice to how terrible this code is, and i'm so scared that it would somehow survive a nuke just for the shear fact of how bad it is. I actually feel a bit woozy looking at it.
This is... wow. If that actually compiles without errors, and the resulting binary actually works, then I bow in awe.
My response was this: What is he talking about? It's just a blank file. I see nothing. Granted, it's thousands of lines of nothing, but I can maintain blank lines pretty well.
**scroll around, notice I can scroll to the right, and so I scroll to the right as much as I can**
Oh.. Oh no... No no no no no. That can't be... Yup... it really is... HOLY !@#!
I've just done something incredibly stupid.
I looked at more of the code. OK, I was thinking along the lines of "it can't all be that bad, maybe this one is some kind of freak and the rest of it is normal".
It is all that bad. I need to go lie down in a dark room now.
I really hope overgrowth is doing better, because that code beyond terrible. If in If in If in If IF IF IF! ![]()
For the first few seconds I was still looking for it, and thinking that it was a blank page, nope.
nuke it....it's the only way to be sure.
Nuking it won't be enough I'm afraid, NUKE IT TWICE DAMMIT!
On the other hand, it shipped as part of a pretty damn successful indie title. On that score, not bad?
Holy hell, that list of extern variables...
On the other hand, it shipped as part of a pretty damn successful indie title. On that score, not bad?
It certainly says a lot about the drive of Wolfire to finish their game.
On the other hand, it shipped as part of a pretty damn successful indie title. On that score, not bad?
If that's the actual code the produced the title that shipped (and not some kind of joke), then like I said, I bow in awe. I find that code horrible, but as bad as the code may look... writing such a thing is one story, debugging and making it work it is yet another.
If the author really managed to turn this into a working product (and if it was successful, it must have been kind of functional), that was truly some great work. Now imagine what he could do otherwise...
On the other hand, it shipped as part of a pretty damn successful indie title. On that score, not bad?
If that's the actual code the produced the title that shipped (and not some kind of joke), then like I said, I bow in awe. I find that code horrible, but as bad as the code may look... writing such a thing is one story, debugging and making it work it is yet another.
If the author really managed to turn this into a working product (and if it was successful, it must have been kind of functional), that was truly some great work. Now imagine what he could do otherwise...
The authors are these guys http://www.wolfire.com/
On the other hand, it shipped as part of a pretty damn successful indie title. On that score, not bad?
On that score even worse, I'd say, as it might give out the idea that this is the way to write successful titles. Sure, you can't argue with the success, but the ends don't justify the means.
I note from their blog post announcing it's release: "The coding style is what you might expect from a self-taught high school student, so it could be a challenge to understand" so at least the author(s) acknowledge it's dreadfulness (if in a somewhat understated way), and I've also found that some poor fool has (or had) a fork of the code with the intention of cleaning it up. That's ... brave.
There's probably a moral to this story, something about not letting the endless quest for perfect code get in the way of actually getting stuff done, but this really does lie at one extreme whereas the ideal place to be would be somewhere in the middle.
There's probably a moral to this story, something about not letting the endless quest for perfect code get in the way of actually getting stuff done, but this really does lie at one extreme whereas the ideal place to be would be somewhere in the middle.
QFT.
Until I read that, I assumed that the code was produced by an automated tool, stitching together snippets
I note from their blog post announcing it's release: "The coding style is what you might expect from a self-taught high school student, so it could be a challenge to understand" so at least the author(s) acknowledge it's dreadfulness (if in a somewhat understated way),
On the bright side, their compilation times would be pretty fast!
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more