Jump to content

  • Log In with Google      Sign In   
  • Create Account

dejaime

Member Since 14 Aug 2011
Offline Last Active Feb 14 2016 07:32 PM

Topics I've Started

Draft Article in the home page.

16 July 2014 - 12:26 PM

Is it just me, or is a draft article appearing in the home page?

"Oh God, Who Wrote This?", "You Did", "Wait? I wrote This?"

23 January 2014 - 12:12 AM

for (totalMatches = 1; // From the last input entry
         (totalMatches <= (pIt)->first->getSize() &&
         ((pIt)->first->compare( (pIt)->first->getSize()-totalMatches, eventLog[eventLog.size()-totalMatches]->getType(),
         translator->translate(eventLog[eventLog.size()-totalMatches]->getKeyCode()), getTimeDiff( (eventLog.size()-totalMatches)))))
         ;++totalMatches) {}

I guess that is the ugliest piece of code I ever wrote.
Notice the {} in the end. All the computing actually happens in the middle section of the for loop... where I use some megamoth functions...

God, this is ugly. I'll have to rewrite the whole function to get rid of this monster I created.

What this does is basically comparing two different vectors to see if they match.
The problem is that one of the vectors need to be translated and interpreted in order to compare with the other one...
There is also some math to calculate a time diff...

and it does it backwards...


Yeah, that's simply horrible, I know it, but I am thinking of it as a placeholder... lol
I do this all the time with sprites!
That's the first time I do that with code though! haha

 

But, of course, I wrote the whole thing while I should be sleeping and it didn't work at first. It took me almost 20 minutes to figure out I was advancing on only one of the vectors and always comparing the second's back. There were also some other less stupid mistakes, I probably wrote this loop in under a minute, but spent over 30 trying to fix it... so ugly... I really need some programming advice! lol

 

@edit:

And yet another bug on this loop. Hey kids, if you are reading this, do not, I repeat: do not, create monsters! They Bite!


PARTNERS