My Version of Tetris

By Shamus Posted Monday Mar 8, 2010

Filed under: Programming 72 comments

In 1990 I was given my first IBM PC as a graduation gift. The machine came with a copy of Borland Turbo C, which was a programming environment. I didn’t know the C programming language at the time. Before then, I’d been using Basic. I realized that Basic wasn’t going to cut it in the professional world, and it was time for me to learn a grownup programming language.

The machine came with the Borland reference books. You could use these to look up individual functions and remember their syntax. And that’s all. They contained no real instruction on the structure and behavior of the language itself. Learning C with these books was like trying to learn English using only an English dictionary, or learning to drive using only the owner’s manual for your car.

This was also pre-internet (for me) so I couldn’t look up anything online. I didn’t even know any C programmers. I’d graduated and it was summer, so I no longer had any teachers to ask. Looking back, I suppose a trip to the library might have been worth a try, although that didn’t occur to me and I’m not sure if they would have kept any relevant books on hand.

So my only way forward was to sit in my bedroom and try to puzzle out the language based on my own guesses and whatever truths could be gleaned from the three-line code snippets scattered throughout the book.

So I wound up with some gaps in my knowledge. Specifically, I didn’t know you could make your own functions. This is a hilarious thing to not know. A C program might look like this:


void DoAwesomeThing ()
{
     be awesome here;     
}
 
void DoNeatThing ()
{
     do some stuff;
     DoAwesomeThing ();
}
 
void main ()
{
     do some stuff;
     DoNeatThing ()
     do some more stuff;
     DoNeatThing ()
     do still more stuff;
     DoNeatThing ()
}

But if you don’t use functions – if you can’t (or don’t know how to) make DoAwesomeThing or DoNeatThing – then the program will turn into this:


void main ()
{
     do some stuff;
     {
          do some stuff;
          {
               be awesome here;     
          }
     }
     do some more stuff;
     {
          do some stuff;
          {
               be awesome here;     
          }
     }
     do still more stuff;
     {
          do some stuff;
          {
               be awesome here;     
          }
     }
}

If you find a bug in awesome thing, then you need to fix it in three different places. Copy & paste errors will propagate and the code gradually becomes an unreadable mess. Doing things this way basically defeats the most important features of the language. (I did things this way because I was trying to map my knowledge to C to my knowledge of Basic.)

Most programmers will look at the above code and get all twitchy. It’s just so perfectly wrong.

Never one to settle for small, reasonable goals, I decided that the best project after Hello World was a full-featured graphical version of Tetris.

I wrote Tetris without a single function call. The entirety of the program was contained within main (). Start screen, the game loop, user input, line removal, scoring, increasing levels of difficulty, game over, high score list. Everything. All in main (). I cannot stress how convoluted this was. The code indenting was so deep that if you scrolled halfway down the (terrifyingly long) page, you would see nothing but blank space. The line indents were all the way off the right side of the screen. You had to scroll a full page width horizontally in order to see the code.

I finally got my hands on real C code and learned how things are supposed to work. I wrote and re-wrote Tetris a few times over the next few years. I had a friend who would put the new versions up on a BBS for me. When you exited the game, it printed out my real, actual home address and invited you to send a postcard. (I got three. Furthest away was from Japan. I was so excited. I communicated with someone in Japan! I’m sure I do that every single day now.)

The program and the source vanished ages ago in one of my early computer migrations. Shame. I would pay good money to see the no-function version of the Tetris source again, if only to gape at the horrifying awfulness of the thing.

On a whim, I Googled around to see if it had made the jump from BBS to internet. It did:

shamus_tetris.png

That’s a 16 color graphics mode. I made it look like it had more colors by using dithering. (I was SO proud of figuring that out. Wrote a whole bunch of code to do smooth dithered fades. Spent ages on it, experimenting and looking for ways to make the blend as natural as possible. But the whole system was obsolete before I wrote the first line of code. 256 color mode was all the rage and 16 bit color mode was on the horizon.)

The program was more future proof than many. It still runs on my computer and is still playable. The only thing that breaks is that there was no CPU throttle on the PC speaker based sound effects, so the sounds are reduced to almost completely inaudible millisecond long blips. (Sounds work right under Dosbox, though.)

You can get it here.

Controls:

Arrow keys. And you use the < and > keys for rotate left and right. For some reason.

And the source is gone. If it doesn’t work for you, then there is nothing to be done. Good luck.

 


From The Archives:
 

72 thoughts on “My Version of Tetris

  1. Zyzzyva says:

    Could have been worse – you could have been trying to program in Lisp with no user-defined functions. Now that would have been source code for the ages.

    1. MichaelG says:

      You were so spoiled! Trying teaching yourself to program in APL… On a Selectric-typewriter terminal to a timeshared mainframe.

      I had a huge binder of printed APL programs from my past that I carried around for years. It’s long gone now. Just as well.

      1. Cody says:

        Psh, try learning triple double x total hardcore awesome code on a computer made entirely out of recycled cardboard in the snow, uphill, BOTH WAYS.

        1. Gavin says:

          Pah. I taught myself a language that didn’t exist, wrote a WOW clone in the Notes section at the back of my microwave’s manual with a blunt 2B pencil and ran it on a broken Betamax VCR. And it liked it!

      2. Erik says:

        Ohmigod. I thought I was the only person strange enough to have done that one. Except I was using a Teletype terminal instead of a Selectric, so I didn’t even have the APL font, and did everything with the escape codes. (Del = $DL, rho = $RO, etc.)

        That lasted for most of a year, until my friend got one of the very first TRS-80s and I switched over to learn Basic. But I think it actually did me good – learning to program in a workspace environment made certain things much clearer than they were in a monolithic language like Basic.

        1. MichaelG says:

          APL without the special keys?! You win.

        2. Bryan says:

          That reminds me of my C64 programming days. Except that I finally broke down and wrote some of it in machine code. I made a sprite cycler in machine code that made a man walk (yes, actually walk, not pan across the screen, by cycling 16 sprites) in the direction you pushed the joystick, too. Woo-hoo!

  2. Spluckor says:

    How do I make them spin?!?!?!

    1. Marc says:

      Doesn’t work for me either

      1. Tobias says:

        I bet you’re on a non-QERTY keyboard. The QERTY layout features seperate keys for > and < while just about every other latin layout maps those outputs to one key, alternating with Shift, which probably renders this game completely unplayable. Shame on past-Shamus for poor localization! ;)
        That said, I have no idea how to make it work.

        EDIT: Ooh, found it! Almost trivial. You just need to find out which keys sit in the same place in your layout as > and < in QERTY. Just look here: http://en.wikipedia.org/wiki/Keyboard_layout
        For reference: If you're on QWERTZ like me, it's , and .

        1. Tobias says:

          *Deleted for completely wrong thread* Stupid me.

  3. swimon says:

    Bummer I was all hyped up to play 16 colour tetris but it won’t work :/ says it doesn’t support fullscreen mode or whatever. Oh well.

    1. Ian says:

      Yeah, that’s a Vista/7 thing. I’m not sure where it stuffs up, but you can’t run a full screen text prompt or DOS mode graphics display in full screen in either the 32-bit or 64-bit editions. You’ll have to use DOSBox if you want to see it.

      It’s strange, since it does seem to support entering full screen (though that might be a holdover from XP) it’s just that it gets stopped at some point. I’ve tried disabling Aero but to no avail.

      Not a huge deal, since I mostly use 64-bit Windows 7 (if I ever need to run any 16-bit applications I use either Virtual XP Mode or DOSBox), but still puzzling.

  4. SolkaTruesilver says:

    Shamus, don’t think “how lame I was to be excited I contacted somebody in Japan while I do it on a daily basis now”

    Think: “My life is so awesome I contact people in Japan on a daily basis. If my past-self could see me right now, he’d probably wet himself out of joy and anticipation”

    1. Shamus says:

      That’s actually how I intended it. Or at least, how I felt when I wrote it. Yeah. It came across as a little… ungrateful, didn’t it?

      We’re actually at the point now where I would be much more amazed to happen to communicate with someone from my own town than someone from Japan.

      Amazing times, and all that.

      1. lazlo says:

        And you’d be right. Japan’s a lot bigger than your home town.

      2. Eddeman says:

        I actually had this happen a day or so ago when I met someone from my home town (about 6k people live there) in a random pick up group in WoW. And I was indeed more surprised than talking to someone from Japan :P Amazing times indeed.

    2. Monkeyboy says:

      It is amazing isn’t it?

      My music gets beamed into my car by satellite, unless I plug in 1000 songs and three movies on this small box, and the GPS directs us anywhere.

      As for coding that game, it’s amazing to me to think you did that all free hand.

  5. Felblood says:

    I’ve got two years of training, in C++ and I couldn’t create a program like this, without looking up the correct functions in a reference manual, just the way you did.

    Nobody teaches you how to actually use C++ anymore. C++ courses are all about general coding fundamentals (like defining functions and classes) and data structures (like stacks, ques and arrays). The programs I learned to write will read and output text to a terminal window, in black and white.

    This is done for two reasons. They don’t want to endorse any specific kind of graphics code, like OpenGL, or DirectX, so as to be platform neutral, and still useful in five years. Also, there is a powerful fear that if you teach your students to do graphical stuff, they will throw away their careers and become video game makers, as if it was possible to produce marketable business software with a text terminal interface, in this millennium.

    For all the money I owe in student loans, it looks like I’m going to have to teach myself how to handle user interactions in C++. It’s nice to have a reminder that people have done this before and produced code that, while flawed, is fully functional.

    1. Jabor says:

      I’m currently going through a software degree, and it seems to be a lot like

      1st year: “Teach yourself VB in 10 days” (sort of like how Shamus originally learned C)
      2nd year: Datastructures, algorithms, and the like
      3rd year: Graphics
      4th year: HCI

      That last one is, I think, the most important for the “one guy in a basement” software company. (Of course, in a larger firm, you’ll have one guy who just knows the HCI and you’ll do what he says when it comes to the user interface, so you don’t need to know it in too much depth).

  6. ReluctantDM says:

    Thanks for sharing that. It brought back tons of memories from my early programming days. I learned in a language called Turing (http://en.wikipedia.org/wiki/Turing_%28programming_language%29) in my high school. I remember spending so much time trying to get the language to do things it wasn’t designed for. It was actually a very good learner language.

  7. Adamantyr says:

    I agree with Felblood, school is almost useless about how to program in C++. In their defense, they’d argue that it’s their job to teach the theory and practice of programming, and such practical focus is the job of trade schools and the real world. Yeah, well, that didn’t make me feel better when I saw my first working C++ code source and realize school hadn’t prepared me at all.

    I did have a graphics programming class that used C++. It consisted of complicated math theory taught by a professor who most of us were certain had never coded a line in his life. (A brilliant Russian professor, mind you, with multiple doctorates in math.) We used the OpenGL platform for most of our lab assignments, and we had a final course project to do anything we wanted.

    I wrote an OpenGL 2D vector version of the old Star Trek games that were popular on mainframes and 8-bit BASIC, where you flew around and destroyed Klingons. Unlike Shamus, I did know how to do functions. What I didn’t know how to do was manage multiple header and source file dependencies without causing conflicts and breaks. So I made one huge file that contained everything.

    I put a lot of work into the graphics, though, and was particularly proud of the explosions, which were comprised of:
    – A bunch of pixels that spread out from center to outer positions
    – A bunch of polygons that erupted from the middle outwards, spinning as they moved
    – A circle that came out like a shock wave that started forming gaps past a certain diameter than eventually made it disappear

    I got an A on the project, since it was not only a good example of graphics usage, it also was fully functional as a game. My own personal grade on the code would be a C- at best…

    I have my GL-Trek Game up for download here: http://www.adamantyr.com/misc/gltrek.html

    I haven’t looked at it in a long while, but I suspect it runs overly fast now; I had no CPU frame rate limits. You also have to have the OpenGL DLL in your Windows folder for it to work.

    1. Felblood says:

      The thing is that C++ get’s treated like the new BASIC.

      C++ courses never teach you how to use the language in a practical environment, because they’re too busy doing data structures and object oriented programming.

      I understand that in a large dev team, you would need to produce functions that just manipulate data in proscribed ways, and would never need to know about how that data reaches the users. However, in order to get hired for such a position, you’re going to want to produce a portfolio of complete programs, and a two year degree does not prepare you to do that. i.e. a two year degree is basically worthless, especially if you didn’t get the actual diploma, on account of failing humanities courses.

      That last bit is probably the real reason that I’m coding functions pro-bono , just to get something that I can pawn off as real work experience, but I’m broke, prospect-less and hounded by school loans,
      I get to be bitter.

    2. Allerun says:

      I hear this a lot. You seem to be looking at it from the wrong perspective. It seems you want the school to teach you a specific language that you think will be beneficial for getting a career.

      The school is focused on teaching you the foundations of Information Systems/Computer Science/Software Engineering (whatever program you are in). Without the foundations of OOP, algorithms, data structures and HCI it won’t matter what language you code in, it will probably be inefficient and unreadable at best and horribly broken at worst; like the code presented in this post.

      With the foundations secured, you should be able to learn the syntax and structure of almost any language and apply those foundations. You should be able to look at a problem, recognize an existing algorithm or form a new algorithm to solve that problem, use the data structures given in the language and build an OOP based on that info.

  8. Tim Reynolds says:

    Shamus,

    This is amazing, it really touched me. Reading that first paragraph was almost like reliving my youth. I was self taught on qbasic on an IBM PS/2 (one of many assets acquired in my mother’s second marriage). I wrote what seemed to me at the time fairly complex games using no functions. Didn’t even know they existed as a concept. I knew that if I typed the word SUB my editor would disappear and it was a pain to get back.

    I wrote D&D simulators (always in an arena, so I only had to deal with one or two opponents) where every menu operated differently because I would rewrite the menu code from scratch. I kept a notebook where I would write down the labels of all my ‘functions’ so I could look it up when I needed a GOTO. I am saddened that I lost track of that thing. I eventually was given a copy of Borland Turbo C with the C programming language book and my lunacy continued there as well. Fortunately I managed to get into a formal programming course (C++) and learned real programming techniques. I miss those days sometimes.

    Great read!

  9. Vegedus says:

    Hm, maybe I should save some of my old programs as well. For nostalgia’s sake and all that.

    Also, if I understand it right, you were essentially treating C as if it was a procedural, rather than object-oriented language?

    1. Tim Reynolds says:

      C isn’t an object oriented language. It is an imperative language.

      1. wtrmute says:

        C is an imperative language, but so is C++ or Java. If you want to oppose “Object-oriented”, then C is “procedural” or “structured”.

        1. Tim Reynolds says:

          Thank you, yes, you are correct.

  10. Axle says:

    I tried to make a game once on my SPECTRUM computer thingy in basic…. It was about a man jumping over things coming towards him.. I waas 10.
    When I was 15 (or 16) a friend and I programmed a text adventure called “Time quest”. It sucked in so many ways, but fun to make.

    By the way.
    Before I download, I would like to know what kind of DRM your game have?

  11. Shinjin says:

    “I wrote Tetris without a single function call. The entirety of the program was contained within main ()”

    I can’t tell you how much heartburn reading these two sentences just gave me. I’m not someone prone to anxiety, but this really got me.

    1. Will says:

      I hear you, upon reading those sentances my code monkey slit his wrists. I’m going to need to find another one now, and apparantly i’ll need to keep him away from this site.

  12. Mari says:

    What makes me most sad isn’t the goofball code. It’s the fact that you needed to provide a wikipedia link to the term “BBS.” So much of my youth was wasted on something that is now so obsolete as to require a wikipedia link for the uninitiated (ie most people under 30 and a whole lot over as well).

    You sir, rock, though for your “cutting edge” graphical bling.

    1. Samuel Erikson says:

      Are you aware of Jason Scott’s BBS: The Documentary?

    2. Sauron says:

      For the record, 21 here, and I remember using BBSes when I was 10 or 11.

    3. Sem says:

      27 here and also used BBSes when I was 16/17. I remember it clearly because of the giant telephone bill I racked up… I don’t know what I would have done if DSL wasn’t introduced into my area 2 months later.

    4. KremlinLaptop says:

      Recently Valve had a viral campaign to announce Portal 2 – you may have heard about it. One of the points in the viral campaign was dialling into a BBS for ASCII images.

      I shed tears everytime someone came and asked, “What’s the IP for the BBS? HOW DO I CONNECT? Do I use my FTP client?”

      … “What’s a dial-up?”

      (Alright, that last one never occurred.)

      1. Groboclown says:

        Don’t forget that it wasn’t JUST a BBS you connected to. It was a BBS running with FidoNet extensions!

  13. sree says:

    off topic but in ur cut scene relationship graph what about the relationship between cut scene length and eagerness to kill something

  14. Hobo says:

    Nice game. One thing I found funny, when I wanted to close the game I tried to alt-f4 it, but instead of closing the window something in your coding caused alt-f4 to move the block left while alt-f6 moves it right.

    1. Jabor says:

      I suspect it’s the way the keyboard mapping works :)

      Unlike CTRL+C and the like, Alt+F4 doesn’t send a signal of any kind – the application is just supposed to recognize that specific keyboard combination and respond by exiting.

      As it turns out, the Windows virtual key code for F4 looks an awful lot like the ‘<' character :)

      1. WJS says:

        I did not know that. I mean, we all know that programs don’t have to respect alt-F4, but I always assumed that it sent the windows equivalent of SIGTERM, not that it was something that you had to make your program handle yourself. (Can you tell that I don’t write stand-alone programs?)

  15. Evan says:

    The idea of a full Tetris game inside of a single method made some part of me weep tears of pain.

    Still, quite impressive that you managed to hack anything together at all with little to no outside help. More than I could have done.

  16. Galad says:

    That was an inspiring read, thank you!

  17. Joe says:

    I was on an Odyssey of the Mind team in middle school and for one of our tasks we had to build two robots that would perform a variety of tasks. I got stuck on the programming end of the project and went through the EXACT same process as this. Everything was in a giant loop, one huge long program.

    My dad took one look at it and asked why I wasn’t using subroutines for all of the repetitive tasks. A three day mind-bender ensued and suddenly I saw the light and began programming like a normal human being; it was marvelous.

  18. Louis says:

    I couldn’t even look at that Awesome/Neat main method. I had to scroll past it as quickly as possible.

    Anyway, nice result you had on the Tetris project, although I was surprised to see that you didn’t include an in-game Quit functionality, like hitting Esc.

    In college, I had to produce a Tetris program for my Windows Programming class. Nothing notable about it, nor my creation of it, but my first test run was interesting- I apparently wasn’t thinking in the proper direction, and the blocks wound up starting at the bottom and “falling” up. It was funny, and I thought about leaving that in as an Easter Egg, but didn’t have the time to integrate it properly. Ah well.

  19. Carra says:

    Well, it’s where my BASIC knowledge comes to mind ;)

    10. Do Awesome
    20. return
    30. GOSUB 10

    If BASIC has it, C++ surely has it would have been the logical thought.

    Ah, I remember a time where I only knew a bit of BASIC . I’m pretty sure I didn’t even know how to properly use a GOSUB back then. Now I could just look up the command in the C64 wiki. I probably messed around with Gotos…

    Of course the most complicated thing I wrote was something to draw Lissajous figures. Creating an entire tetris program? You must be insane to try that ;)

    1. octopusfluff says:

      ‘GOSUB’ is not a universal element of BASIC, actually. The concept was grafted back into certain variants of it later, and some of them got them much later than others, or not at all.

  20. McGurker says:

    Man oh man, I started “programing” in Java when I took a one-semester class last year on the basics. I couldn’t make an applet if you asked me to, I can’t do a single thing with images, but damned if I won’t do every single thing with prime numbers that you want. Prime factors? Gotcha. isPrime? Gotcha. They may not be fast or efficient but I love ’em.

    I will be honest Shamus, my FAVORITE FAVORITE FAVORITE thing about your blog is the programming. I love reading about it in a non-sterile (I.E. tutorial) environment. I don’t understand 90% of the things you say about it (maybe because it’s your job and my hobby) but I just love how enthusiastic you are. Golly I sound like a fanboy?

    Moral is, keep it comin’ my friend, it never gets old.

    1. Carra says:

      Souns like you’d have fun on Project Euler ;)

  21. Aelyn says:

    I cannot stress how convoluted this was.

    I cannot stress how unnecessary stressing that would be. I could envision it…

    That reminds me of a day early in my programming career. I was writing VB3 code (/shudder). When a user clicked a button, I had to do something, then wait for some other user input. So…

    Do_some_stuff

    bUserClicked = false

    While bUserClicked = false
    DoEvents()
    Wend

    Wrap_it_up

    As you can guess, when they clicked the other button it flipped my busy wait flag to true. Pathetic, pathetic, pathetic. Saw that about 6 months later and retched.

  22. drow says:

    i’m sure i could write a perl script to employ genetic algorithms to recreate something very similar to your functionless tetris source code…

    1. FatPope says:

      I’d like to see you try and make that fitness function!

  23. ClearWater says:

    I thought there was something wrong with the jpeg or my monitor until I realised that was dithering. That’s awesome!

  24. Brendan says:

    Not to make anyone feel old or anything, but that program was published three days before I was born.

  25. Jabor says:

    So, without functions – I wonder how difficult it would be to disassemble? Sure you’d lose variable names, but … you could probably recreate close to the original source.

    EDIT: Just had a look at it in IDA’s graph mode. That is one godawfully huge loop.

  26. toasty says:

    This was an awesome story. I myself remember really enjoying my programming class, but also being entirely frustrated because I couldn’t get anything to work. So now I’ve decided to major in English. :p

  27. Skeeve the Impossible says:

    I remember the night you got that computer. It is one of those vivid memories that is burned into my brain. I was just as excited as you were i think.

  28. Angie says:

    The machine came with the Borland reference books. You could use these to look up individual functions and remember their syntax. And that's all. They contained no real instruction on the structure and behavior of the language itself.

    Huh? That had to have been a bare-bones edition just for the bundled version of the software. I bought Borland Turbo C in… 1988? 89? Something like that, and it came with multiple manuals — the function look-up, the structure manual, all the basic references, plus a full-up tutorial book. All were clear and well written; Borland has been my touchstone for excellent product references ever since. They must’ve skimped on yours because it was an extra with your system. :/

    Angie

    1. Shamus says:

      The system was a hand-me-down from an Uncle. I don’t know if we had different editions or if books were missing. The books were well-worn by the time I got them.

      The computer itself was an IBM clone that ran at ~4mhz, but had a math co-processor that “turbocharged” it up to ~7.4-ish.

      Powerful stuff indeed.

      1. Angie says:

        Ahh, that makes more sense. [nod]

        My first computer was a PC clone at 4.7 MHz, with a “turbo” button that took it up to 10 MHz, which seemed awesomely zippy at the time. Those were the days, heh.

        Angie

  29. MaxEd says:

    I suspect that it’s just the normal course to write everything is a single function, when you move from BASIC to C. When I was writing games in QuickBasic in school, they rarely had more than one sub-routine, until I started my own Graphic Editor (called VGADraw, because it was intended for SCRENN 13 mode). Then, I just had to learn to use modules, sub-routines and functions, because thing got complex quite soon.

    Buy, oh boy, how bad my first programs in C were!! I could not figure how to return string from function, so I wrote something like

    char *GetString( … )
    {
    char c[255];

    return c;
    }

    And got myself some nice broken pointers. Lost pointers were what killed my first two attempts to write games in C.

  30. Wakela says:

    “I was so excited. I communicated with someone in Japan! I'm sure I do that every single day now.”

    I live in Japan, and I read your blog almost every day.

  31. Axle says:

    By strange coincidnece I bumped into this today:

    http://abstrusegoose.com/249

  32. Ah, the good old DOS coding. I would have given you money to show me that dithering was an awesome extension for graphics back in my QBasic days. The last time I used it I made an Atomix-like-motion puzzle game were you had to guide a ball to the exit. Since I had no idea how the heck to read in bitmaps in QBasic (and very little internet access), I made my own paint program to draw all the sprites. Talk about the long way round.

    I remember being so proud when I learnt how to use Turbo Pascal at school and made a garden landscaping program out of it. My step-mom actually sued it to lay out the footpath at the front of her garden. Like you, Shamus, I have since (to my sadness) lost all source and executables.

  33. beno says:

    I’m impressed!

  34. Groboclown says:

    I’ve been fortunate to hold onto most of my old PC programs and source that I wrote after ’92. All my old Apple //e BASIC stuff is lost to the ages (I used to have it all printed out with the nice hole ribbons on the sides, but that’s been lost to time), and so are most of my old high school programs.

    The stuff that remains includes lots of nasty Pascal, assembly, and C programs.

  35. illiterate says:

    that reminds me of when I had a “game programming class”, and ended up building a game using wildTangent and javascript.

    1800 lines of java fricking script. Ow my brain.

  36. Kdansky says:

    I honestly cringed when I saw your sample code up there. ;)

    Better than this:

    main() {
    player1();
    }

    player1() {
    doStuff
    player2()
    }

    player2() {
    doStuff
    player1() {
    }

    It works. Until you run out of stack… Good thing I never did that…
    Also, the [code] tag does not work (with > signs of course)

  37. Daf says:

    Aww, it was working on my XP box until I got to line 25 -> 27 and then it locked up.
    Still it was fun while it lasted. :)

  38. Ander the Halfling Rogue says:

    Wow. My second C++ project (after Hello World, of course) is a calculator to figure out how many days it’s been since you were born. For practice, I created calculate() instead of doing everything in main(). The thing is hardly 35 lines, and that’s only ’cause of the comments and liberal, multi-line use of cout (I left out leap years and generalized the lengths of months, but I could probably add them and still clock in under 50 or so lines).
    I cannot imagine trying to create Tetris at this level of my programming knowledge.

Thanks for joining the discussion. Be nice, don't post angry, and enjoy yourself. This is supposed to be fun. Your email address will not be published. Required fields are marked*

You can enclose spoilers in <strike> tags like so:
<strike>Darth Vader is Luke's father!</strike>

You can make things italics like this:
Can you imagine having Darth Vader as your <i>father</i>?

You can make things bold like this:
I'm <b>very</b> glad Darth Vader isn't my father.

You can make links like this:
I'm reading about <a href="http://en.wikipedia.org/wiki/Darth_Vader">Darth Vader</a> on Wikipedia!

You can quote someone like this:
Darth Vader said <blockquote>Luke, I am your father.</blockquote>

Leave a Reply to ClearWater Cancel reply

Your email address will not be published.