Carl Cash! My new game!

This is a discussion on Carl Cash! My new game! within the Game Programming forums, part of the General Programming Boards category; Okay, it's not a game yet it's just a concpet with 2 rooms and the ability to move around... this ...

  1. #1
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262

    Carl Cash! My new game!

    Okay, it's not a game yet it's just a concpet with 2 rooms and the ability to move around... this is like my 3rd game, my first being Tic-tac-toe and my second being Yahtzee... this is like a text based adventure game... enjoy!

    I need lots of feedback and advice, such as how can I have the player use the arrow keys instead of w,a,s and d... also is there an easier way to make sure people don't go through walls? Thanks in advance!
    Attached Files Attached Files

  2. #2
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Code:
    switch (userinput)
    {
        case 8:
                code for north;
                break;
        case 6:
                code for east;
                break;
    
    ................
    
    }
    the other two are 2 (south) and 4 (west)....also u can use virtual keys. this example is crued and uses a custom header file (attached):

    Code:
    if (input == K_UP)
    	{
    		User_Location_Y = User_Location_Y++;
    	}
    
    	if (input == K_DOWN)
    	{
    		User_Location_Y = User_Location_Y--;
    	}
    
    	if (input == K_LEFT)
    	{
    		User_Location_X = User_Location_X--;
    	}
    
    	if (input == K_RIGHT)
    	{
    		User_Location_X = User_Location_X++;
    	}

  3. #3
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    i forgot to post this, a crude way of making "walls"

    Code:
    /* Check user position.*/
    	if (User_Location_Y == 25)
    	{
    		cout <<"You cannot continue in this direction\n";
    		User_Location_Y--;
    		getch();
    	}
    
    	else if (User_Location_Y == -25)
    	{
    		cout <<"You cannot continue in this direction\n";
    		User_Location_Y++;
    		getch();
    	}
    
    	else if (User_Location_X == 25)
    	{
    		cout <<"You cannot continue in this direction\n";
    		User_Location_X--;
    		getch();
    	}
    
    	else if (User_Location_X == -25)
    	{
    		cout <<"You cannot continue in this direction\n";
    		User_Location_X++;
    	}

  4. #4
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Originally posted by RoD

    User_Location_Y = User_Location_Y++;
    User_Location_Y = User_Location_Y--;
    User_Location_X = User_Location_X--;
    User_Location_X = User_Location_X++;
    RoD, this code should not be used. It's behavior is undefined. In C++, the same variable cannot be modified twice in the same statement (without the use of a comma).

    User_Location++ would suffice.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  5. #5
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    i'm jus giving him an idea. This program was written in my first week of c++, and i dont suggest it be directly used, but it gives an idea.

  6. #6
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    You might just want to adjust it then before advising to use
    it while it might be infested with beginner mistakes.

  7. #7
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    im thinking rod should update that one program he keeps showing noobs
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  8. #8
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    1) i never told him to use it. its newbie code i used as an example .

    2) im involved in too much other crap to update it. it was never written to be good, it was written to help me learn a little. there is, somewhere, a version written in november that is de-newb and well done, but i havent been able to find the source.

    Its a crued example, nothing more.

  9. #9
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by RoD
    1) i never told him to use it. its newbie code i used as an example .
    Yeah, Well if it's bad code then simply don't post it, That's like
    offering people drugs knowing it's bad for them
    Erhm...oke that example sucked, anyway.......

  10. #10
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    such as how can I have the player use the arrow keys instead of w,a,s and d... also is there an easier way to make sure people don't go through walls?
    I showed him how he could do it, i never said to do it. Look i said it was newb code, i said it could be made better, and thats the bottom line. Dont like the example? Then dont use it, i didnt give him code to use, i gave him an idea. Use the idea or not, i dont honestly care.

  11. #11
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by RoD
    i gave him an idea. Use the idea or not, i dont honestly care.
    Well you should, As beginners probably would love to follow
    a forum's veteran's advice. That's what i think at least.

  12. #12
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    I care if his program works out, not if he uses or goes off my particular example. I'm not going to argue over the quality of the example when i myself said its only an idea, dont use it.

  13. #13
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by RoD
    I showed him how he could do it, i never said to do it.
    Why post code if you don't mean them to use it???
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  14. #14
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    to give him an idea or a direction...

  15. #15
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Thank you RoD but if you looked at my code you could understand that I'm not retarded and I'm not an udder n00b, the problem was how do I read input from the arrow keys(or the virtual keys I guess). I mean like getch() or cin or what?

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 20q game problems
    By Nexus-ZERO in forum C Programming
    Replies: 24
    Last Post: 12-17-2008, 04:48 PM
  2. Need book to program game into multiplayer...
    By edomingox in forum Game Programming
    Replies: 3
    Last Post: 10-02-2008, 09:26 AM
  3. Try my game
    By LuckY in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 09-15-2004, 11:58 AM
  4. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 04:19 AM
  5. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM

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