Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: I did it! Yay!  (Read 9723 times)

0 Members and 2 Guests are viewing this topic.

Dilbert

    Topic Starter
  • Moderator


  • Egghead

  • Welcome to ComputerHope!
  • Thanked: 44
    I did it! Yay!
    « on: March 15, 2007, 01:16:40 AM »
    It's currently 12:08 at GMT-8 as I type this. :)

    I needed to do a project for my Health class, and I was sick of the same ol' posters and crap. "Game" was on the list, and, well, the rest is history.

    Long story short: I wrote a C++ command-line menu-driven game revolving around Suicide, the last topic of our unit. In it, the player attempts to talk some guy out of jumping off a tall building. I worried my parents greatly, because I've never finished a "real" C++ program to date.

    How did I write a fully-fledged game (by 1990 standards, anyway) within a week, you ask? I'm almost ashamed to say it, but I nearly completely abandoned the concept of OOP. I wrote purely procedural code. I had a one-variable class out of habit, but actually, a global variable would have been easier for something of this small scale. I also stripped the program of all exceptions and error logic, since I'll be the one at the helm. :)

    The game is actually simple enough for a one-page flow chart. Luckily, debugging is a small chore when all conceivable paths are marked. I'm proud to announce my first real program was a Gold-star program -- it compiled and ran to specifications perfectly the first time. (I'm not counting the delays in the couts I added later; I left them out at first intentionally for debugging purposes.)

    ^^^^I'm not sure whether to be proud or scared. What can I say, other than I'm done ahead of time and did a good job? Oh, maybe I should get to bed. :)
    "The geek shall inherit the Earth."

    Neil



      Expert
    • Fear me Track. Noone can escape my wrath.
    • Thanked: 3
      Re: I did it! Yay!
      « Reply #1 on: March 15, 2007, 12:00:49 PM »
      Well done! You also learnt a valuable lesson: OOP is just one style of programming available. Each different situation requires a different style and with experiance you will be able to weigh up the pros and cons of each style. Sometimes it can be disastrous to force a particular style "just because".

      For small simple projects, OOP can be more trouble than it's worth. Forcing OOP for them can be fine for learning purposes but when it comes to create a "real" (wasn't sure of the correct word to use) program, then consider the best style.

      I'm still looking forward to your escape game! ;)

      Dilbert

        Topic Starter
      • Moderator


      • Egghead

      • Welcome to ComputerHope!
      • Thanked: 44
        Re: I did it! Yay!
        « Reply #2 on: March 22, 2007, 07:45:04 AM »
        I'd rather not use a "software creator" program to make programs. Not only is it "one step removed"* from actual programming, it's Visual Basic. There's nothing wrong with VB as a language, but it's extremely removed from Assembler, which causes unnecessary overhead.

        Besides, anything that uses VB requires the .NET framework. Since we're talking 2006-07, it's probably the Framework 2.0. I'd rather not make other users download a 20-something MB thing just so my 400 KB EXE works. When you write in C/C++/Java/Assembler/alltheothers, no additional stuff is required -- it runs on its own.

        *FrontPage is "one step removed" from writing HTML. The code it makes is a mess, and it usually causes only IE to render properly. Not my idea of fun.
        « Last Edit: March 22, 2007, 07:45:23 AM by Timothy_Bennett »
        "The geek shall inherit the Earth."

        Neil



          Expert
        • Fear me Track. Noone can escape my wrath.
        • Thanked: 3
          Re: I did it! Yay!
          « Reply #3 on: March 22, 2007, 11:15:45 AM »
          Learn how to use apostrophes.

          Dilbert

            Topic Starter
          • Moderator


          • Egghead

          • Welcome to ComputerHope!
          • Thanked: 44
            Re: I did it! Yay!
            « Reply #4 on: March 22, 2007, 04:55:40 PM »
            You mean DeltaSpider, right? If so, then add periods, commas and capital letters to the list. :)
            "The geek shall inherit the Earth."

            steelegbr

            • Guest
            Re: I did it! Yay!
            « Reply #5 on: March 23, 2007, 06:50:39 AM »
            Quote
            When you write in C/C++/Java/Assembler/alltheothers, no additional stuff is required -- it runs on its own.

            I thought you needed at least the JRE to run Java programs / applets (~16-20Mb download from SUN). :)

            Quote
            *FrontPage is "one step removed" from writing HTML. The code it makes is a mess, and it usually causes only IE to render properly. Not my idea of fun.

            100% accurate there. I'll take notepad over it any day. When you use any WYSIWYG system for programming or websites it usually makes it 100x harder to maintain (and understand the code) than if you went away and learned the HTML/Java/C(++)/etc...

            Dilbert

              Topic Starter
            • Moderator


            • Egghead

            • Welcome to ComputerHope!
            • Thanked: 44
              Re: I did it! Yay!
              « Reply #6 on: March 23, 2007, 08:26:19 AM »
              *Reads up on Java

              Oops! Oh well, the rest of my statement stands. :)

              As for WYSIWYG, Dreamweaver is fairly good at not totally botching up the code it makes. It's still hard to maintain, though. :) And I'd never use a C++ code generator; the mess of code it makes would be a nightmare.

              Side-Note: Do you know about the old compilers that would try to correct programmer's mistakes at compile time, so stupid things like forgetting a ; at the end of a line or missing a ) or two wouldn't cause a program that takes 5 minutes to compile to spit back an error instead of linking.

              It was a noble quest, but like most of mankind's projects it went way too far. One infamous example is a compiler that someone typed only one word into: "if". No includes, no "int main()", nothing. Would you believe that it created a 200-line command-line which successfully compiled and ran? ;D
              « Last Edit: March 23, 2007, 08:34:57 AM by Timothy_Bennett »
              "The geek shall inherit the Earth."

              steelegbr

              • Guest
              Re: I did it! Yay!
              « Reply #7 on: March 23, 2007, 08:59:47 AM »
              Quote
              Side-Note: Do you know about the old compilers that would try to correct programmer's mistakes at compile time, so stupid things like forgetting a ; at the end of a line or missing a ) or two wouldn't cause a program that takes 5 minutes to compile to spit back an error instead of linking.

              Now if only you could do that with javac.... Then I wouldn't get pages of console text telling me I missed a couple of ;s. It ticks you off enough to check what you type before sending it to the "compiler". Especially when you have to ssh it to the server first as it's running a different version of Java.

              CBMatt

              • Mod & Malware Specialist


              • Prodigy

              • Sad and lonely...and loving every minute of it.
              • Thanked: 167
                • Yes
              • Experience: Experienced
              • OS: Windows 7
              Re: I did it! Yay!
              « Reply #8 on: March 28, 2007, 03:57:51 AM »
              Sheesh, a suicide negotiator game?  I think I lose by default.
              Quote
              An undefined problem has an infinite number of solutions.
              —Robert A. Humphrey

              Dilbert

                Topic Starter
              • Moderator


              • Egghead

              • Welcome to ComputerHope!
              • Thanked: 44
                Re: I did it! Yay!
                « Reply #9 on: March 28, 2007, 10:29:58 AM »
                Nah, a monkey could beat it. You see, as long as the Suicide Meter is below 50% after five moves, you win a technical victory. It's really not hard at all, but it does include a lot of the things we covered in the Suicide unit at school, and it's playable and, for about a minute or so, interesting to play. Which is why I received an A+ stamped on the printed source code. (It's kinda hard to write the grade on a file...)

                For anyone interested, here's the program and the source code. Note that I didn't comment a single line, which is completely out of character for me, I assure you. The only reason for that is that I didn't ever... EVER... want to return to this program and modify it further.

                Only other thing to mention is that the dialog is rather cheesy. But hey, a week deadline is an hour or so of creativity. ;D

                *grumble grumble* stupid 128KB attach limit... you'll have to compile the source code with Dev-C++ or a similar C++ compiler. But the compiled game is 130 KB -- 2 over the limit. :-/

                [old attachment deleted by admin]
                "The geek shall inherit the Earth."

                Neil



                  Expert
                • Fear me Track. Noone can escape my wrath.
                • Thanked: 3
                  Re: I did it! Yay!
                  « Reply #10 on: March 28, 2007, 12:12:46 PM »
                  You need this:

                  http://upx.sourceforge.net/

                  It's so amazing. I got a game, with graphics included in the exe, to 114kb. And the guy on the other end doesn't need to do anything or have anything. He just runs like normal.

                  Edit: On my compiler it is 68kb, and 16kb after upx.

                  Dilbert

                    Topic Starter
                  • Moderator


                  • Egghead

                  • Welcome to ComputerHope!
                  • Thanked: 44
                    Re: I did it! Yay!
                    « Reply #11 on: March 28, 2007, 12:22:27 PM »
                    I wonder if I can attach a .7z file...

                    Sweet! 104 KB! ;D

                    That's amazing... the uncompressed is 400+ KB... (pre-UPX and 7-zip) :o

                    [old attachment deleted by admin]
                    "The geek shall inherit the Earth."

                    Calum

                    • Moderator


                    • Egghead

                      Thanked: 238
                      • Yes
                      • Yes
                    • Certifications: List
                    • Computer: Specs
                    • Experience: Beginner
                    • OS: Other
                    Re: I did it! Yay!
                    « Reply #12 on: March 28, 2007, 12:26:06 PM »
                    I like that game.
                    Nice job there.

                    Dilbert

                      Topic Starter
                    • Moderator


                    • Egghead

                    • Welcome to ComputerHope!
                    • Thanked: 44
                      Re: I did it! Yay!
                      « Reply #13 on: March 28, 2007, 12:26:42 PM »
                      Thank you! ;D
                      "The geek shall inherit the Earth."

                      Neil



                        Expert
                      • Fear me Track. Noone can escape my wrath.
                      • Thanked: 3
                        Re: I did it! Yay!
                        « Reply #14 on: March 30, 2007, 06:34:29 AM »
                        Again, I got it down to 16kb so I still win. :P