I looked several pages back and haven't found any topic like this, so why not make one? Generally, this could be a place to talk about some stupid bugs that took forever to find, but eventually made us facepalm over how stupid of a mistake they were. Or to talk about some strange code we have seen.

I'll start with a short one from the days I developed Alexland 1: somehow I managed to mistake sin and cos, but since they were calculated basing on Hero Position and Mouse Position, and I was consistent in making the same mistake when calculating bullet movement, this was not a problem. Actually I only realised this when I added a weapon to the game that would calculate bullet sin+cos from angles and not two points. The whole story resulted in the following code:
Code:
With Bullet[BulNum] do begin
   (...)
   Sinx:=Cos( ... );
   Cosx:=Sin( ... );
end;