Have you ever looked at a piece of code you wrote a week ago and seen this:
Code:double x = sum();
if (contains_factor())
x += 0;
else
x += coefficient();
Printable View
Have you ever looked at a piece of code you wrote a week ago and seen this:
Code:double x = sum();
if (contains_factor())
x += 0;
else
x += coefficient();
Well its not quite the same but for some reason when i wrote my newbie txt RPG i incremented x and y positions like this:
Now i look through code from even a few months ago and im like wtf was i thinking here?? Im getting better at debugging and finding better routes though.Code:user_x = user_x++;
I wrote some code really quickly the other day with STL lists. When I tried to compile it, I realized that I had for some reason tried incrementing the list in a for loop instead of the iterator.
Anything I write quickly usually has a few mistakes on the order of, "WTF was I thinking."
I started to learn C#, then a few days later I thought:
"WTF was I thinking".
It has been a while since I wrote this code and I finally dare posting it:
My game crashed after five minutes constantly and when I added debug info to the screen it only crashed faster.Code://DrawText v2.0
DxEngine* DxEngine::DrawText(int x, int y,const Color& c,TCHAR *szFormat, ...)
{
TCHAR *szBuffer=new char[strlen(szFormat)+512];// Large buffer for very long text
va_list pArgs;
va_start(pArgs, szFormat);
vsprintf(szBuffer, szFormat, pArgs);
va_end(pArgs);
HDC hdc;
if(lpddsback->GetDC(&hdc)==DD_OK)
{
SelectObject(hdc,hFont);
SetTextColor(hdc, RGB(c.r,c.g,c.b));
SetBkMode(hdc, TRANSPARENT);
TextOut(hdc, x, y, szBuffer, strlen(szBuffer));
lpddsback->ReleaseDC(hdc);
}
return this;
delete[] szBuffer;
}
I was puzzled. :)
Aha! Here's the code. Yes... I must've been rather tired.
Code:std::list<QString> cont;
// ... Populate cont ...
std::list<QString>::const_iterator it;
for(it = cont.begin(); cont != cont.end(); ++cont) :rolleyes:
{
// Do stuff...
}
Hey Brian ... how's the C# learning coming along?