A simple first program/semi game

This is a discussion on A simple first program/semi game within the Game Programming forums, part of the General Programming Boards category; Okay, so I was bored and decided to learn C++. This mini-monster of a source code took me about... 20 ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    8

    A simple first program/semi game

    Okay, so I was bored and decided to learn C++. This mini-monster of a source code took me about... 20 hours to type up including research and learning as errors occoured.

    It still isn't perfect but it runs without any major errors (Providing people follow instructions. Which is a lot to ask of today's gamers.)

    I'm just throwing this at you to try and get a few bits of information.

    Problems encountered: Infinite loop caused when character is entered but an integer is expeced on the starting menus.

    Text parsing problems, people who don't type commands in all lowercase letters will be frustrated, as I don't have any model to remove case sensitivity. Which I need.

    I'm sure my code is totally haphazard. I've gone from using "cin >>" to "cin.getline" halfway through, and from "return 0;" to "exit(0);" too. So I've still got both of those in my code.

    Here's the source for those who are interesed, I'm still a learner programmer and I'm learning on my own in my spare time at work.
    Attached Files Attached Files

  2. #2
    ---
    Join Date
    May 2004
    Posts
    1,379
    Quote Originally Posted by Jetlaw
    Text parsing problems, people who don't type commands in all lowercase letters will be frustrated, as I don't have any model to remove case sensitivity. Which I need.
    Code:
    #include <ctype.h>
    
    int tolower(int char);
    int toupper(int char);
    Declare all your functions at the top of your .cpp file or in a separate .h file
    Code:
    int roomOneDesc()  //Describe room one. Very inefficient but it works. May need optimising.
    {   
        int roomOneAct();  //Declare roomOneAct() so I can jump to it later despite the fact it
                           //appears AFTER this in the code and my compiler doesn't like it.
    is no good.

    Overall I think you need to go back to the basics. Read a book. Learn to use functions properly and use pointers. You have too many global variables.
    Last edited by sand_man; 03-16-2006 at 09:10 PM.

  3. #3

    Join Date
    May 2005
    Posts
    1,041
    I didn't feel like compiling it to be honest, but I just wanted to say this: you get better at programming by writing programs. It's good that you spent the time to go through with writing it, keep it up!
    I'm not immature, I'm refined in the opposite direction.

  4. #4
    Registered User
    Join Date
    Mar 2006
    Posts
    8
    Quote Originally Posted by sand_man
    Code:
    #include <ctype.h>
    
    int tolower(int char);
    int toupper(int char);
    I am unsure how to use this method, but I'll look it up. Thanks for pointing it out to me.

    Quote Originally Posted by sand_man
    Declare all your functions at the top of your .cpp file or in a separate .h file
    Code:
    int roomOneDesc()  //Describe room one. Very inefficient but it works. May need optimising.
    {   
        int roomOneAct();  //Declare roomOneAct() so I can jump to it later despite the fact it
                           //appears AFTER this in the code and my compiler doesn't like it.
    is no good.
    I have no experience at all with headers, but I'll experiment and see what I can come up with. It seems a fairly simple premise.

    Quote Originally Posted by sand_man
    Overall I think you need to go back to the basics. Read a book. Learn to use functions properly and use pointers. You have too many global variables.
    Pointers are a challenging concept to grasp and I never really figured out a good use for them in programs this simple. Naturally, that isn't to say I'm right, just that I don't find a use for them. If someone could point me in the direction of more of the theory behind pointers rather than the implementation (Since I can implement and apply things if I understand them, I can't always do so if I do not understand the theory behind them.)

    Thanks for the tips anyway, I'll get back with a more enhanced version soon.

    -Ciao

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating a simple Windows game
    By ejohns85 in forum C Programming
    Replies: 1
    Last Post: 05-22-2009, 01:46 PM
  2. i have to write simple car racing game?
    By iskelet in forum Game Programming
    Replies: 1
    Last Post: 04-01-2009, 05:34 PM
  3. craps game & dice game..
    By cgurl05 in forum C Programming
    Replies: 3
    Last Post: 03-25-2006, 07:58 PM
  4. Whats a very simple but good game i can try to make?
    By bluehead in forum C++ Programming
    Replies: 2
    Last Post: 11-06-2001, 09:24 PM
  5. Replies: 1
    Last Post: 11-06-2001, 02:15 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21