Worst Coding Ever

Discussion about everything. New games, 3d math, development tips...
Post Reply
Nick_Japan
Posts: 98
Joined: Mon Dec 13, 2004 11:47 am
Location: Japan

Worst Coding Ever

Post by Nick_Japan »

I was just looking over code I wrote for my final year project at Uni, when I was just about getting the hang of programming but still hadn't quite mastered the art of making it easy on myself.

Code: Select all

// need to decrement y, as coordinate system increases from top to bottom
void PlayerMoveUp(PlayerData *player)
{
	player->y -= 1;
}
And I wonder why it gave me headaches...

What are some absolute screamers you've managed?
Image Image
Guest

Post by Guest »

when i was just starting 2d game programming, i labelled all the squares on my maps and coded my movement functions like this:

Code: Select all

a1toa2()
{
this->x = 2;
}

a2toa3()
{
this->x = 3;
}
I kid you not. :oops: I estimate my tile-based game would be 1 million lines. :shock:
SuperAssGas
Posts: 2
Joined: Thu Apr 06, 2006 9:05 pm

Post by SuperAssGas »

I made a frogger clone once without the use of any arrays. I used a huge list of if statements like such:

Code: Select all

if (car1.active) {
   car1.move();
}

if (car2.active) {
   car2.move();
}

if (car3.active) {
   car3.move();
}
If you think that's not bad, imagine what I had to do to draw the tile based level.
Peter
Posts: 4
Joined: Tue Apr 04, 2006 5:43 pm
Location: Witness Protection Program

Post by Peter »

hehe, in QBasic, before i knew about for-next loops i coded the code for 20 individual blob enemy dudes seperatley...

like so (except way different because i don't remember what i did)

Code: Select all

if enemy1x > playerx then dec enemy1x
if enemy2x > playerx then dec enemy2x
...
...
and of course i had a whole bunch of things they did (they didn't just follow after the player)

it was like those classic text book examples where i did what could be done in 20 lines in 400 lines... :oops:
There are 10 kinds of people in this world...
Those who understand binary...
And those who don't.
TheWorstCoderEver
Posts: 47
Joined: Wed Feb 01, 2006 8:09 pm
Location: Wroclaw
Contact:

Post by TheWorstCoderEver »

At last, a thread to which I will be able to contribute on regular basis. :lol:

This one's probably not the worst piece code I ever written, but nonetheless I find it hilarious. I created it during my fiddlings with Crystal Space:

lookat=GetCurrentCharacter()->GetMesh()->GetMovable()->GetFullPosition();
:lol:
Guest

Post by Guest »

That is some nice error checking sir :)
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

I got you all beat!

originally Guice had a grid made from draw rectangle and every single quad coordinate to make a straight line from a rectangle... took me all day to arrange it and 10mins for someone to get me started learning for-loops.
TheWorstCoderEver
Posts: 47
Joined: Wed Feb 01, 2006 8:09 pm
Location: Wroclaw
Contact:

Post by TheWorstCoderEver »

If you thought you've seen it all, watch out for this overly bloated class declaration.

Take a deep breath...


Ready?...

GO!!!

Code: Select all


class MiniApp: public csApplicationFramework, public csBaseEventHandler
{
    private:
    csRef<iEngine> silnik;
    csRef<iVirtualClock> zegar;
    csRef<iGraphics3D> g3d;
    csRef<iKeyboardDriver> kbd;
    csRef<iLoader> loader;
    csRef<iCollideSystem> collsys;
    csRef<iView> pwidz;
    csRef<iVFS> FileSystem;
    csColliderActor collider;
    iSector* pokoj;
    Character* current_character;
    const char *mapa;
    const char *folder;
    int CameraType;


    //prywatne metody

    void ProcessFrame();
    void FinishFrame();
    bool LoadMap();
    void CameraControl();

    public:

    iCameraPosition* kamera;

    MiniApp();
    ~MiniApp();

    void OnExit();
    bool OnInitialize(int argc, char* argv[]);

    bool Application();

    bool OnKeyboard(iEvent& ev);

    CS_EVENTHANDLER_NAMES("application.MiniApp")


    //ponizsze funkcje NIE ZOSTALY ODZIEDZICZONE PO ZADNEJ KLASIE!


    Character* BuildCharacterMesh(const char* factory_path,csVector3 pozycja, bool IsCurrent);
    void SetFolder(const char *dir);
    void SetMap(const char *map);
    const char* GetMap()
    {
        return mapa;
    }

    void SetCameraType(int type)
    {
        CameraType=type;
    }

    int GetCameraType()
    {
        return CameraType;
    }

    csRef<Character> GetCurrentCharacter()
    {
        return current_character;
    }

    void SetCurrentCharacter(Character* character)
    {
        current_character=character;
    }

    bool Jump(const char *dir, const char *map);

    //CS_EVENTHANDLER_NIL_CONSTRAINSTS;


};
nomad
Posts: 53
Joined: Thu Jan 05, 2006 12:35 pm
Location: Wales

Post by nomad »

In one of my first attempts at Atari basic programming, must be about 24 years ago, I was trying to make a missile command type game. I spent days trying to figure out how to quickly plot the pixels to make a line between 2 points on screen. Then I found the DrawLine function.
Still makes me laugh.
Ecliptic Fate
Posts: 19
Joined: Tue Apr 26, 2005 6:10 am

Post by Ecliptic Fate »

lol that made me laugh
drarem
Posts: 81
Joined: Mon Mar 06, 2006 4:40 am
Contact:

Post by drarem »

On the MC10 (Radioshack model, bought it with babysitting money :/ ), I wrote out complete text adventures on paper and since I wasn't aware of for/next or arrays, each function call was more of a GOTO type thing - until I learned of the (ON .. GOTO and eventually, the ON .. GOSUB on the atari 800) accepted a 1-key command like N,S,E,W,U,D,A for attack, S to search, etc.

100 REM
101 print "You are in a large oval room."
102 if monsterc=1 then print "You see an orc."
103 a$=inkey$
104 if inkey$="N" then goto 120
105 if inkey$="A" then goto 140: rem attack
108 if inkey$="V" then goto 101: rem view
109 goto 103

*note: 105 would allow you to attack the orc even if it was dead.
Also, I think the commands were all CAPS and there were no cursor keys, you had to list the program and retype the program number to replace something. I didn't get to use the convenience of the cursor key until the Atari 800.

I didn't call it an orc back then either, it was probably something different like a living stone statue or medusa heh.
Post Reply