Recently hacked a simple Julia fractal generator together over the space of about three days. The resulting source code is probably a litany of How Not To Do It examples, written in C++. For example, here are some of the screwier bits:
Code:
const int set_xsize=600;
const int set_ysize=800; // for some reason I'm too lazy to work out
const float rangex=6; // x and y have been swapped and mixed up
const float rangey=8; // all over the damn place.
const float offsetx=0; // meh, whatever.
const float offsety=0;
Laziness is a virtue, right? RIGHT?
Code:
outbmp.open("out.bmp", ios::out | ios::binary | ios::trunc);
if (! outbmp.is_open())
{ cout << "BALLS!\n"; return (1); }
Note the sucky indentation style and the extra insightful error message.
Code:
// DOT dotmap [set_xsize][set_ysize];
// *ahem* STACK OVERFLOOOOWWWW!
// I *really* ought to be using a dynamic variable here
// But the voodoo chicken gods don't like that for some reason
// Okay, I do actually know how to do it properly
// But I'm too lazy and hey, it's only a 200 to 1600 kilobyte array.
// That's WELL within the acceptable limits for a global variable, right?
// bwahaahahahahah!
You may note that, aside from the blatant use of the wrong damn tool for the job, I also abuse C++ style comments horribly.
Code:
intensity=0;
COMPLEX zee(xcoord,ycoord);
COMPLEX ecs(xcoord,ycoord);
while ( ((float)zee <= 10000.0f) && (intensity < 25) )
{
intensity++;
zee = zee * zee;
zee = zee + ecs;
/* additional frobberisation commands go here */
}
This is probably the cleanest bit of the entire codebase. Except, of course, if one notes the style of comment used...
Code:
/* outbmp.write((char*)&heada,14);
THIS ^^ is what the code is supposed to be.
BELOW is an ugly hack that I've had to implement
because for some FUCKING REASON this GOD DAMN MOTHERFUCKING
PIECE OF HORSE SHIT IS FUCKING PUTTING THE FUCKING STRUCTS
TOGETHER IN THE WRONG *FUCKING ORDER* AARWBGUIQEA FUCKING USELESS
FUCKING PIECE OF FUCKING SHIT DIE YOU GNU SLUTS DIE DIE DIE DIEDIE
IT'S SUPPOSED TO FUCKING WELL DO WHAT IT SAYS IN THE
FUCKING SOURCE CODE YOU BASTARD WANKERS NOT WHAT THE FUCKIING COMPLIER FEELS LIKE FUCKI DOING TO DAY arwt ej */
outbmp.write((char*)&heada,2);
outbmp.write(((char*)&heada+4),10);
outbmp.write(((char*)&heada+2),2);
outbmp.write((char*)&headb,40);
Good news is, I'm actually using the right type of comment for the job this time around. Bad news is, I'm using a screwy hack because I can't figure out why GCC keeps putting my structs together in a completely different order to that specified in the header file.
Code:
float getx(void); // buggered if I can think of
float gety(void); // any good reason to use these ^_^
I'm also horribly cheeky.
Discuss. (Also, does anyone know why GCC might be putting a struct together in some completely different order to that specified in my header files? This is bordering on a hair-rippy-out magnitude annoyance.)