Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

878552 Posts in 32926 Topics- by 24337 Members - Latest Member: kellerx25

May 22, 2013, 06:46:41 AM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Post if you just laughed at your code.
Pages: 1 ... 11 12 [13] 14 15 ... 29
Print
Author Topic: Post if you just laughed at your code.  (Read 36295 times)
zacaj
Level 3
***


void main()


View Profile WWW Email
« Reply #180 on: May 01, 2012, 03:48:59 AM »

Code:
if(newLine)
   newLine = !newLine

Could somebody explain this to me pls?
If it's not zero, set it to NOT itself. NOT itself if it's any number besides 0 makes it equals zero. It's the equivalent of newLine=0

Right, that's what I thought. So it's just a really bizarre thing to write... I wonder what the thought process was.
Most likely they wrote the second line first, possibly without any condition or with a different condition, and then later changed the condition without actually reading the code below it, only thinking that they knew that code needed to be run then. Or something along those lines.
Code:
if(newLine)
   newLine = !newLine

even better I forgot to tell you newLine is a boolean varible Cheesy
Well it would work with any integer, right? Does it work with negatives? I've never actually checked...
Logged

My twitter: @zacaj_

Quote from: mcc
Well let's just take a look at this "getting started" page and see--
Quote
Download and install cmake
Noooooooo
Claw
Level 4
****



View Profile WWW Email
« Reply #181 on: May 01, 2012, 04:16:00 AM »

Well it would work with any integer, right? Does it work with negatives? I've never actually checked...

Doing a boolean check on anything just checks if it is 0 (false) or non-zero (true), so yeah it should work on negatives too.

I had to think for a second looking at that code snippet but then I laughed Tongue
Logged

Sakar
Level 9
****


Je suis le chat


View Profile WWW Email
« Reply #182 on: May 05, 2012, 12:14:13 PM »

Code:
frame = (n == 0) ? 0 : (n <= 0.25) ? 1 : (n <= 0.5) ? 2 : (n <= 0.75) ? 3 : (n <= 1) ? 4 : 4;

Found this funny
Logged

Site | Twitter
rivon
Level 10
*****



View Profile
« Reply #183 on: May 05, 2012, 12:21:25 PM »

Oh god why... Why would anyone write such an ugly and totally unreadable piece of code?
Logged
Sakar
Level 9
****


Je suis le chat


View Profile WWW Email
« Reply #184 on: May 05, 2012, 01:46:16 PM »

I'm still asking myself the same thing. Not sure what I was thinking when I wrote that
Logged

Site | Twitter
Geti
Level 10
*****



View Profile WWW
« Reply #185 on: May 05, 2012, 07:13:05 PM »

.. we use ternaries like that pretty often. helps to use more brackets. Hand Thumbs Up Left
Logged

Fallsburg
Level 10
*****


Fear the CircleCat


View Profile WWW
« Reply #186 on: May 06, 2012, 09:41:14 AM »

You use ternaries to do something like this?

Code:
frame =  min(ceil(n*4),4);

Because I think you are doing it wrong.


Also, even in that horribly convoluted way the bit
Code:
(n <= 1) ? 4 : 4
is completely unnecessary.  I mean, the rest of it is bad, but that's just horrible.
Logged

Xienen
Level 2
**


Greater Good Games


View Profile WWW Email
« Reply #187 on: May 07, 2012, 11:23:14 PM »

Oh god why... Why would anyone write such an ugly and totally unreadable piece of code?

Is it sad that this line was immediately readable to me?  Obviously the whole thing was pointless and is not any sort of well written, but I've obviously dealt with ternaries a little too much =D
Logged

Owner/Programmer at Greater Good Games makers of Break Blocks
Currently developing It Hungers(Unity) and Swipe Attack(UDK)
Klaim
Level 10
*****



View Profile WWW
« Reply #188 on: May 08, 2012, 02:48:21 AM »

This is the typical result when you first write the first condition, simple to read, then try it and find that there are special cases, so you just add some more conditions, but on test you see that you forgot those other different edge cases that depends on if you are or not in the right state, so you add some more conditions and continue like that until you get happy and move on without thinking about your future self.


Classic.
Logged

http://www.klaimsden.net | Game : NetRush | Digital Story-Telling Technologies : Art Of Sequence
Geti
Level 10
*****



View Profile WWW
« Reply #189 on: May 08, 2012, 04:57:53 AM »

"You use ternaries to do something like this?"
No, we use ternaries that look similar to that to accomplish more useful things. The one pictured is hilarious but strings of ternaries aren't so bad compared to the equivalent pile of conditionals, though going above 3 or so in close proximity (or especially nested without parens) hurts readability to no end for sure.

"I mean, the rest of it is bad, but that's just horrible."
Good for a laugh though, no?

Laughed at my code this morning for a coding lab at uni. Have had a bunch of other stuff on so hadn't looked over the lab. Basic graph theory stuff about a social network.

Ended up that the two german guys were on their own "friend island", disconnected from everyone else in the graph. Not sure if it was the lecturer being a (funny) dickhead or what, but it certainly helped make frantically coding everything a little more bearable.  Coffee
Logged

cliffski
Level 0
***



View Profile WWW
« Reply #190 on: May 13, 2012, 11:54:43 AM »

I was working on collision detection, and wanted to save the penetration depth (overlap) of the collision.

Code:
double penetration

Well I LOLed...
Logged

www.positech.co.uk Maker of Democracy Kudos and Gratuitous Space Battles for the PC. owner of showmethegames.com.
garlandobloom
Level 0
***



View Profile WWW Email
« Reply #191 on: May 16, 2012, 01:56:30 PM »

Just fixed an if( x = y ) bug yesterday. It had been in the code for years. Surprised it hadn't caused more problems. Those are the peskiest kind of bugs. Just one equals sign difference. I only noticed because I updated MingW and now GCC warns about them.

So...good on the GCC devs for adding that warning! Smiley
Logged

Geti
Level 10
*****



View Profile WWW
« Reply #192 on: May 16, 2012, 05:54:03 PM »

I just had a laugh about the
Code:
double penetration;
thing again, but only by proxy.
Code:
Vec2f penetration;
.
Logged

pixhead
Level 4
****


fish_master57@hotmail.com
View Profile Email
« Reply #193 on: May 22, 2012, 09:34:28 PM »

Code:

/**
 * the container class contains things that need containing
 */
Class Container
{
   //the prisoner is container within the continaer. For life.
   Object prisoner;
}


Note to self, code when drunk more often  Cheesy
Logged

"Games are made by artists, so to not consider them art is an insult to the artists who work on them." - Some guy on IGN.
Evan Balster
Level 10
*****


dreaming close to metal


View Profile WWW Email
« Reply #194 on: May 29, 2012, 12:55:58 PM »

I scrolled past some old templated code in my reflection system.

Code:
static const Parents NOPARENTS; //aww

awwwwww
Logged

Infinite Blank, SoundSelf, Cave Story+, Wreath
voice, accordion, mandolin, (oboe, soon)
Game audio programming consultant.
<plaid/audio>: opensource audio framework
Pages: 1 ... 11 12 [13] 14 15 ... 29
Print
Jump to:  

Theme orange-lt created by panic