Advertisement

Funniest line of code ever ?

Started by July 17, 2014 08:27 AM
125 comments, last by Orymus3 9 years, 8 months ago

Personal favorite of mine (from the first version of my 2D engine back in 2009)


	runRight  = new ANIM();
	runLeft   = new ANIM();
	runBack   = new ANIM();
	runFront  = new ANIM();
	idleRight = new ANIM();
	idleLeft  = new ANIM();
	idleBack  = new ANIM();//those of you with OCD will HATE me for these lines...
	idleFront = new ANIM();//if you don't have OCD, you have no idea what I'm talking about.

Fixed for you.

Personal favorite of mine (from the first version of my 2D engine back in 2009)


	runRight  = new ANIM();
	runLeft   = new ANIM();
	runFront  = new ANIM();
	runBack   = new ANIM();
	idleRight = new ANIM();
	idleLeft  = new ANIM();
	idleBack  = new ANIM();//those of you with OCD will HATE me for these lines...
	idleFront = new ANIM();//if you don't have OCD, you have no idea what I'm talking about.

Fixed for you.

You only fixed the formatting... There's more that should drive your OCD insane... Muahahahahaha!

I develop to expand the universe. "Live long and code strong!" - Delta_Echo (dream.in.code)
Advertisement

You only fixed the formatting... There's more that should drive your OCD insane... Muahahahahaha!

Fine, refixificated.

What can i say, the formatting apparently irritated me so much that i had to fix it immediately and could not see the wood for the trees.

Obvious joking aside, there is actually some reasoning in addition to readability to actually keep that kind of stuff lined up. For example, in VS you can edit multiple lines at the same time (alt-select) - useful when you later need to change stuff.

... speaking of which, i take you wrote the "= new ANIM();" stuff per line (copy-paste or otherwise) instead of writing all of them at once? *hint-hint*

tongue.png

You only fixed the formatting... There's more that should drive your OCD insane... Muahahahahaha!

Fine, refixificated.

What can i say, the formatting apparently irritated me so much that i had to fix it immediately and could not see the wood for the trees.

Obvious joking aside, there is actually some reasoning in addition to readability to actually keep that kind of stuff lined up. For example, in VS you can edit multiple lines at the same time (alt-select) - useful when you later need to change stuff.

... speaking of which, i take you wrote the "= new ANIM();" stuff per line (copy-paste or otherwise) instead of writing all of them at once? *hint-hint*

tongue.png

Yup. I am an oldschool programmer set in the ways of Borland and other such IDE's. I use the more modern ones, however, my practices haven't changed.

I develop to expand the universe. "Live long and code strong!" - Delta_Echo (dream.in.code)

Personal favorite of mine (from the first version of my 2D engine back in 2009)


	runRight = new ANIM();
	runLeft = new ANIM();
	runFront = new ANIM();
	runBack = new ANIM();
	idleRight = new ANIM();
	idleLeft = new ANIM();
	idleBack = new ANIM();//those of you with OCD will HATE me for these lines...
	idleFront = new ANIM();//if you don't have OCD, you have no idea what I'm talking about.

Meh, I find the inane repetition far more annoying


for(auto anim : {
		&runRight, &runLeft, &runFront, &runBack,
		&idleRight, &idleLeft, &idleFront, &idleBack
	}
)
	*anim = new ANIM();

Personal favorite of mine (from the first version of my 2D engine back in 2009)


	runRight = new ANIM();
	runLeft = new ANIM();
	runFront = new ANIM();
	runBack = new ANIM();
	idleRight = new ANIM();
	idleLeft = new ANIM();
	idleBack = new ANIM();//those of you with OCD will HATE me for these lines...
	idleFront = new ANIM();//if you don't have OCD, you have no idea what I'm talking about.

Meh, I find the inane repetition far more annoying


for(auto anim : {
		&runRight, &runLeft, &runFront, &runBack,
		&idleRight, &idleLeft, &idleFront, &idleBack
	}
)
	*anim = new ANIM();

except that this was written before C++ 11...

I develop to expand the universe. "Live long and code strong!" - Delta_Echo (dream.in.code)
Advertisement

Meh, I find the inane repetition far more annoying


for(auto anim : {
		&runRight, &runLeft, &runFront, &runBack,
		&idleRight, &idleLeft, &idleFront, &idleBack
	}
)
	*anim = new ANIM();


This very vaguely reminds me of ad-hoc look up tables


typedef int a[];
int someValue = a{5,3,6,4,2}[n];
 
or
 
int someValue = array<int, 5>{{5,3,6,4,2}}[n];
f@dzhttp://festini.device-zero.de



Personal favorite of mine (from the first version of my 2D engine back in 2009)

runRight = new ANIM();	runLeft = new ANIM();	runFront = new ANIM();	runBack = new ANIM();	idleRight = new ANIM();	idleLeft = new ANIM();	idleBack = new ANIM();//those of you with OCD will HATE me for these lines...	idleFront = new ANIM();//if you don't have OCD, you have no idea what I'm talking about.
Meh, I find the inane repetition far more annoying
for(auto anim : {		&runRight, &runLeft, &runFront, &runBack,		&idleRight, &idleLeft, &idleFront, &idleBack	})	*anim = new ANIM();
except that this was written before C++ 11...

So what?

ANIM** anims[] = {		&runRight, &runLeft, &runFront, &runBack,		    &idleRight, &idleLeft, &idleFront, &idleBack	};

for(ANIM*** anim = anims; anim != anims + 8; ++anim)
  **anim = new ANIM();
Would be much easier in both cases if you hadn't made the mistake of naming everything and had made it iterable in the first place.

(Sorry if the formatting is broken, on my phone right now)

Personal favorite of mine (from the first version of my 2D engine back in 2009)

runRight = new ANIM();	runLeft = new ANIM();	runFront = new ANIM();	runBack = new ANIM();	idleRight = new ANIM();	idleLeft = new ANIM();	idleBack = new ANIM();//those of you with OCD will HATE me for these lines...	idleFront = new ANIM();//if you don't have OCD, you have no idea what I'm talking about.

Meh, I find the inane repetition far more annoying
for(auto anim : {		&runRight, &runLeft, &runFront, &runBack,		&idleRight, &idleLeft, &idleFront, &idleBack	})	*anim = new ANIM();

except that this was written before C++ 11...


So what?

personally i think it was a bad excuse why not to use that method, as it's more likely your real code would look something like:

runRight  = new ANIM(2, imgA, imgB);
runLeft   = new ANIM(2, imgC, imgD);
runFront  = new ANIM(2, imgE, imgF);
runBack   = new ANIM(2, imgG, imgH);
idleRight = new ANIM(2, imgI, imgJ);
idleLeft  = new ANIM(2, imgK, imgL);
idleBack  = new ANIM(2, imgM, imgN);
idleFront = new ANIM(2, imgO, imgP);
it's not likely your going to be creating an animation object without feeding them some unique parameters.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

Personal favorite of mine (from the first version of my 2D engine back in 2009)


runRight = new ANIM();	runLeft = new ANIM();	runFront = new ANIM();	runBack = new ANIM();	idleRight = new ANIM();	idleLeft = new ANIM();	idleBack = new ANIM();//those of you with OCD will HATE me for these lines...	idleFront = new ANIM();//if you don't have OCD, you have no idea what I'm talking about.
Meh, I find the inane repetition far more annoying

for(auto anim : {		&runRight, &runLeft, &runFront, &runBack,		&idleRight, &idleLeft, &idleFront, &idleBack	})	*anim = new ANIM();
except that this was written before C++ 11...


So what?

personally i think it was a bad excuse why not to use that method, as it's more likely your real code would look something like:


runRight  = new ANIM(2, imgA, imgB);
runLeft   = new ANIM(2, imgC, imgD);
runFront  = new ANIM(2, imgE, imgF);
runBack   = new ANIM(2, imgG, imgH);
idleRight = new ANIM(2, imgI, imgJ);
idleLeft  = new ANIM(2, imgK, imgL);
idleBack  = new ANIM(2, imgM, imgN);
idleFront = new ANIM(2, imgO, imgP);
it's not likely your going to be creating an animation object without feeding them some unique parameters.

And again, if those images and anims weren't named and instead in an array, this could be done easily with a loop.

I'm just extremely annoyed by useless repetition. I have just seen too many people writing vector classes with named elements x, y, and z and having repeated code for each of the three dimensions just about everywhere.

This topic is closed to new replies.

Advertisement