Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411605 Posts in 69388 Topics- by 58445 Members - Latest Member: gravitygat

May 08, 2024, 06:25:14 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Post if you just laughed at your code.
Pages: 1 2 3 [4] 5 6 ... 27
Print
Author Topic: Post if you just laughed at your code.  (Read 86736 times)
iffi
Guest
« Reply #60 on: April 13, 2011, 06:59:05 PM »

Not my own code, but I laughed when I saw the fast inverse square root implementation as it appears in the Quake 3 source.
Snippet here:
Code:
i  = * ( long * ) &y;                       // evil floating point bit level hacking
i  = 0x5f3759df - ( i >> 1 );               // what the fuck?
Logged
Waffle
Level 0
*


Gotta love em' waffles


View Profile
« Reply #61 on: April 13, 2011, 07:30:34 PM »

was checking my code the other day that i used for a school project..... funny thing is i got full credit on the assignment and the teacher said nothing.
check the title line
Code:
public static void main(String[] args) {
    DisplayClock frame = new DisplayClock();
    frame.setTitle("DisplayCock");
    frame.setLocationRelativeTo(null);
    ......
  }
Logged
mcc
Level 10
*****


glitch


View Profile WWW
« Reply #62 on: April 21, 2011, 04:12:18 AM »

Two interesting things from the last couple days:

- Found myself typing the comment

Code:
 // FIXME: Guarantee this doesn't somehow cause OH FUCK.

...those last two words sort of coming out involuntarily as at that exact moment I realized (1) that yes, the commented block of code did cause heap corruption; and (2) why.

- So I write what I think is a very nice linear interpolate/decimate filter that works without having to allocate any scratch buffers! I use it to play back PCM samples at various speeds. But then I run it, and everything I play back with interpolation has this nasty hissing noise overlaid on it-- like there's a triangle wave of something like 11025 or 22050 hz overlaid on everything, getting louder and softer with the audio data. In other words, it sounds like classic aliasing. But it's loud, really loud-- it more or less overpowers the sample itself. And aliasing shouldn't be that clear or that audible either with the kind of interpolation I'm using or at the ratios I'm using (like, 2x interpolation)-- or so I thought. I check and re-check the code but there is clearly nothing wrong with it. I begin to doubt everything I know about sample interpolation. Is it possible you really just can't resample a sound without doing the low-pass thing?

Then I poke some more. And I discover something weird.

Apparently, when I prepared my sample files in Audacity, I sort of messed up. I'd thought my samples were all 16-bit mono PCM. It turns out, however, that they were all 16-bit stereo PCM-- and the right channel was always just silence! So all along, effectively, all of the samples I'd been playing back were slowed to 1/2 speed. Since they were all drum sounds this wasn't completely noticeable. And they were slowed effectively by inserting silence gaps between each PCM value-- something which normally wouldn't be noticeable. Except then after this accidental, inaudibly-aliased slowdown, I go and perform a second, intentional, inaudibly-aliased slowdown, and my second slowdown faithfully takes the aliasing from the first slowdown and blows it up in to VERY LOUD triangle waves...

I go and fix my source audio files and everything sounds fantastic!!!
Logged

My projects:<br />Games: Jumpman Retro-futuristic platforming iJumpman iPhone version Drumcircle PC+smartphone music toy<br />More: RUN HELLO
Theophilus
Guest
« Reply #63 on: April 21, 2011, 07:38:33 AM »

was checking my code the other day that i used for a school project..... funny thing is i got full credit on the assignment and the teacher said nothing.
check the title line

public static void main(String[] args) {
    DisplayClock frame = new DisplayClock();
    frame.setTitle("DisplayCock");
    frame.setLocationRelativeTo(null);
    ......
  }




 Cheesy

Took me a while to get it.


Logged
frederiksen
Guest
« Reply #64 on: April 21, 2011, 06:04:21 PM »

i don't know what this was or what it was intended to do, but this made me laugh when i found it in some old code, also it looks kinda nice.

Code:
var pr:Array = [1.49, 5.49, 5.99, 2.98, 3.49, 7.30];
var success:int = 0;
var miss:int = 0;
for (var i:int = 0; i < 6; i++)
{
var pr0:Number = pr[i];
for (var j:int = 0; j < 6; j++)
{
var pr1:Number = pr[j];
for (var k:int = 0; k < 6; k++)
{
var pr2:Number = pr[k];
for (var l:int = 0; l < 6; l++)
{
var pr3:Number = pr[l];
for (var m:int = 0; m < 6; m++)
{
var pr4:Number = pr[m];
for (var n:int = 0; n < 6; n++)
{
var pr5:Number = pr[n];
if (pr0 != pr1 && pr0 != pr2 && pr0 != pr3 && pr0 != pr4 && pr0 != pr5 &&
pr1 != pr2 && pr1 != pr3 && pr1 != pr4 && pr1 != pr5 &&
pr2 != pr3 && pr2 != pr4 && pr2 != pr5 &&
pr3 != pr4 && pr3 != pr5 &&
pr4 != pr5)
{
if (pr0 < (pr1 + pr2))
{
if (pr1 + pr2 < pr3 + pr4)
{
if (pr3 + pr4 < pr5)
{
success += 1;
                      trace(pr0+'__'+pr1+'__'+pr2+'__'+pr3+'__'+pr4+'__'+pr5)
}
else { miss += 1;}
}
else { miss += 1;}
}
else { miss += 1;}


}

}

}

}

}


}


edit: i remember what it was, i've seen a segment of the price is right. And there was a game where the contestant was given some articles and had to arrange them like this: the price of the first item must be lower than the second and third combined, the second and third must be lower than the fourth and fifth combined, those two must be lower than the sixth (p1<p2+p3<p4+p5<p6). I found it interesting because you had to actually think about when to use your lowest price, how to get above the price of the second and third while still being under the sixth etc. (Of course she didn't even know the prices).
But i'm just glad i hacked this down without thinking about good implementation.
« Last Edit: April 22, 2011, 06:11:02 AM by frederiksen » Logged
ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #65 on: April 21, 2011, 07:02:11 PM »

it's kind of funny how cluttered gml interface is, here's an example of the code for one of the creatures in my game



it's kind of a hassle to have to constantly keep flipping between the different windows and trying to arrange them in a way that i none hide behind the other
Logged

Triplefox
Level 9
****



View Profile WWW
« Reply #66 on: April 21, 2011, 08:41:52 PM »

Code:
public static function drSeussFindsTheLowestVelocity() : Float
{
var best = 999999.;
for (Ball in idx)
{
var vl = Ball.GetLinearVelocity();

var test = vl.Normalize();

if (test<best)
best = test;
}
return best;
}

Not the actual function name >.>

Edit: it was buggy.
Logged

NFour
Level 0
**


Grow Old or Die Trying


View Profile WWW
« Reply #67 on: April 22, 2011, 05:29:50 PM »

I used to try to use this as often as possible on computer science tests/assignments
Code:
char zard;
Logged
Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW
« Reply #68 on: May 02, 2011, 05:09:59 AM »

Code:
glPushAttrib(GL_CURRENT_BIT or GL_CURRENT_BIT);

Whoops.
Logged



What would John Carmack do?
Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW
« Reply #69 on: May 08, 2011, 09:55:01 PM »

Code:
pragma Import(C, Grab_Mouse, "front_end_grab_mouse");
pragma Import(C, Ungrab_Mouse, "front_end_grab_mouse");

Took me a few minutes to figure out why Ungrab_Mouse was doing the wrong thing.
Logged



What would John Carmack do?
Triplefox
Level 9
****



View Profile WWW
« Reply #70 on: May 20, 2011, 01:46:00 PM »

I decided to introduce the concept of "high" and "low" layers and joints...

Code:
	for (ent in Entity.gettagindex("tilebody"))
{
if (ent.isHigh && joint.startHigh)
{
ent1 = ent;
}
else if (ent.isHigh && joint.endHigh)
{
ent2 = ent;
}
}

I should probably wrap Entity.gettagindex into "bongHit()" to make it complete.
Logged

rivon
Level 10
*****



View Profile
« Reply #71 on: May 21, 2011, 05:50:37 AM »

I don't get it. What's the problem or funny thing about it?
Logged
BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #72 on: May 21, 2011, 05:59:14 AM »

I don't get it. What's the problem or funny thing about it?
Ent n. Slang for somebody who smokes cannabis.

Similarly "joint" and "high".
Logged
st33d
Guest
« Reply #73 on: May 21, 2011, 06:11:46 AM »

Good god, is there no escape from reddit anywhere?
Logged
Evan Balster
Level 10
*****


I live in this head.


View Profile WWW
« Reply #74 on: May 21, 2011, 09:19:11 PM »

Good god, is there no escape from reddit anywhere?

Real life tends to be pretty reliable, depending on your friends.

(Though perhaps the Organization dispatches a token reddit-reader friend to everyone; I have two)
Logged

Creativity births expression.  Curiosity births exploration.
Our work is as soil to these seeds; our art is what grows from them...


Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>
TaintedFork
Level 0
***



View Profile WWW
« Reply #75 on: May 22, 2011, 02:06:34 AM »

I am working on the menu for a game right now, and I had defined each choice as a variable called xxOption, xx being whatever it represented.

This seemed normal, until I did:
Code:
optionsOption

for the options menu. Tongue
Logged
rivon
Level 10
*****



View Profile
« Reply #76 on: May 23, 2011, 11:16:20 AM »

Or you can name it Preferences or Settings Wink
Logged
EliteKill
Level 0
*


View Profile
« Reply #77 on: May 26, 2011, 09:01:19 AM »

I just made a method named getDown.



Logged
dasdsad
Level 0
***


View Profile
« Reply #78 on: June 01, 2011, 04:31:52 PM »

I never thought I'd post in here, but this just happened ..and now that I'm posting it, it doesn't seem that funny anymore.  Waaagh!

WELL, WHATEVER
Code:
#define CREATE_SUCCESS 0 /*Read in Borat Voice*/
Logged
David Pittman
Level 2
**


MAEK GAEM


View Profile WWW
« Reply #79 on: June 08, 2011, 05:11:57 PM »

Learning about Python modules and packages while working on a small prototyping project, I wrote the following:

Code:
AI = ai.ai.AI()
Logged

Pages: 1 2 3 [4] 5 6 ... 27
Print
Jump to:  

Theme orange-lt created by panic