Thread: text rpg

  1. #31
    Registered User
    Join Date
    Dec 2001
    Posts
    8
    http://games.neikous.com

    im working on an rpg

  2. #32
    Registered User
    Join Date
    Aug 2001
    Posts
    403

    text rpg's

    If you're really interested i can pull together some really old stuff from the CoZ archives for you... I wouldn't be able to post it here probably but I could give you bits and pieces of some really old stuff (I can't promise it's good code, this was some of the first stuff that I wrote with CoZ)

    I bet you already have better code from the others, but if you're interested email [email protected].

  3. #33
    Registered User
    Join Date
    Aug 2001
    Posts
    106
    yo cozman, what happened to your site? it never loads it, always says there isnt a web page for it. have you just stopped dealing with it? just wondering, thanks,

  4. #34
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    ok i think this will work for the map function but im not sure so if some one could check this out and help me it would be a big help



    Code:
    ...
    int board[5][5] = {
             0,0,0,0,0,
             0,0,0,0,0,
             0,0,0,0,0,
             0,0,0,0,0,
             0,0,0,0,0,};
    char choice;
    int player[x][y];
    char Player = 1;
    
    void PlayerMove()
    {
           cin<<choice;
           switch(player[x][y]) 
           case 'UP':
                x++;
                break;
           case 'DOWN':
                x--;
                break;
            case 'LEFT':
                y--;
                break;
            case 'RIGHT':
                 y++;
                 break;
            system("cls");
            Board();
    }
    ...
    void Board()
    {
           playermove();
           board[x][y]=player;
           for(int i = 0; i <= 5; i++)
               for(int j = 0; j<= 5; j++)
                        cout<<" ";
    }

    would this work?

  5. #35
    Registered User
    Join Date
    Aug 2001
    Posts
    106
    won't work. in your switch statement there are two problems:
    1) there is no point in having the
    cin >> choice;
    line if you arent going to use it. to use it, you need to have the var 'choice' in the switch() part...so, it should look something like this...
    cin >>choice;
    switch(choice) {
    etc etc etc
    }

    2) case statements can only handle a single character/number. so instead of having case 'UP', you need something along the lines of case 'U', etc. if this wont work youll have to think of something else, sorry.

    i havent dissected everything in the code, those are just the things that i catch off-hand. once you get those fixed and if you can fix anything else just post the new code and we can see if there is anything else.
    hope this helped.
    later

  6. #36
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    Code:
    ...
    int board[5][5] = {
             0,0,0,0,0,
             0,0,0,0,0,
             0,0,0,0,0,
             0,0,0,0,0,
             0,0,0,0,0,};
    char choice;
    int player[x][y];
    char Player = 1;
    
    void PlayerMove()
    {
           cin<<choice;
           choice=tolower(getch());
           switch(choice)
           case 'y':
                x++;
                break;
           case 'h':
                x--;
                break;
            case 'j':
                y--;
                break;
            case 'g':
                 y++;
                 break;
            system("cls");
            Board();
    }
    ...
    void Board()
    {
           playermove();
           board[x][y]=player;
           for(int i = 0; i <= 5; i++)
               for(int j = 0; j<= 5; j++)
                        cout<<" ";
    }
    is this any better??

    im more conserned about displaying the map and the player than anything else because switch statements arent that hard to figure out. so does the "void Board();" work or do i still need to change one or two things?
    Last edited by c++.prog.newbie; 12-21-2001 at 04:20 PM.

  7. #37
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    a question for all the intelegente people out there that know how to spell, could you tell mw ehat i did wrong here what i was trying to do is to display a player on the map and be able to move hom around using the U, J, H, K, keys but after i press on of the letters it displays the decimal value(eg, 0x204785(not exactly)) and then just exits the program




    Code:
    #include <iostream.h>
    #include <stdlib.h>
    #include <conio.h>
    #include <ctype.h>
    
    
    char board [5][5] = {
     		0,0,0,0,0,
                    	0,0,0,0,0,
    		0,0,0,0,0,
    		0,0,0,0,0,
    		0,0,0,0,0,};
    char player = 2;
    int x;
    int y;
    int u, h, k, j;
    char choice;
    
    void Board();
    void movement();
    
    
    
    
    
    void Board()
    {
    	system("cls");
    	board[x][y]=player;
    	movement();
    	for(int i = 0; i<5; i++)
    		cout<<"\n";
    		for(int j = 0; j<5; j++)
    		{
    			cout<<board;
    		}
    }
    void movement()
    {
    if (keyhit==UP) { x--; } 
    if (keyhit==DOWN) { x++; } 
    if (keyhit==LEFT) { y--; } 
    if (keyhit==RIGHT) { y++; } 
    }
    
    void main()
    {
    	Board();
    }
    Last edited by c++.prog.newbie; 12-21-2001 at 08:26 PM.

  8. #38
    Registered User
    Join Date
    Aug 2001
    Posts
    106

    Post

    for(int i = 0; i<5; i++)
    cout<<"\n";
    for(int j = 0; j<5; j++)
    {
    cout<<board;
    }

    should be....

    for(int i = 0; i<5; i++)
    cout<<"\n";
    for(int j = 0; j<5; j++)
    {
    cout<<board[i][j];
    }

  9. #39
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    oh... ok i get it now

    but ehat header do i need to use the keyhit and RIGHT, LEFT, UP, DOWN, functions
    Last edited by c++.prog.newbie; 12-23-2001 at 02:28 PM.

  10. #40
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    ok i fixed one of my problems instead of using keyhit im using kbhit() but i still need to know how to use UP DOWN LEFT RIGHT... could some one please help

    heres the code i have so far
    Last edited by c++.prog.newbie; 12-23-2001 at 09:39 PM.

  11. #41
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    sorry i forgot the code

  12. #42
    Registered User
    Join Date
    Aug 2001
    Posts
    106
    well i think the problem is that youre using kbhit the wrong way. im not exactly sure how to use it but i don't believe thats how. maybe im wrong. but i still think that a switch statement would be easier...

    void movement()
    {
    char move;
    board[x][y]=board[0][0];
    move=toupper(getch());
    switch(move) {
    case 'U': x--; break;
    case 'J': x++; break;
    case 'H': y--; break;
    case 'K': y++; break;
    case '1': Rest(); break;
    case '2': Mix(); break;
    }
    }

    try using something like that, why wont that work?

    i tried running your program...its got some problems with some of the other code as well. you dont have anything to tell it to keep running after it displays the map once. after the first time its drawn, it quits.

  13. #43
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Look no further... I take it none of you have played a 'Rogue-like game'? Or perhaps a MUD?

    Quzah.
    Hope is the first step on the road to disappointment.

  14. #44
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    Code:
    #include <iostream.h>
    #include <stdlib.h>
    
    const char player = 1;
    char boards[5][5];
    int x=0, y=0;
    char choice;
    char U, J;
    
    
    void board();
    void movement();
    
    void board() {
    	system("cls");
    	boards[x][y]=player;
    	for(int i=0; i<5;i++) {
    		cout<<"\n";
    		for(int j=0; j<5; j++) {
    			cout<<boards[i][j];
    		}
    	}
    	movement();
    }
    
    
    void movement(){
    	cin>>choice;
    	if(choice=='U' || choice=='u') {boards[x--][y];} 
    	if(choice=='J' || choice=='j') {boards[x++][y];} 
    	if(choice=='h' || choice=='H') {boards[x][y--];}
    	if(choice=='k' || choice=='K') {boards[x][y++];}
    	system("cls");
    	board();
    
    }
    ok i have this code and it works except that it doesnt delete the previous there for it will just leave a trail of rather than just were you are could some one please help

  15. #45
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    heres the previous file if you wnat to download it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. text rpg help
    By xxwerdxx in forum Game Programming
    Replies: 1
    Last Post: 11-26-2005, 08:16 PM
  2. Replies: 3
    Last Post: 05-25-2005, 01:50 PM
  3. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 04:49 PM
  4. mygets
    By Dave_Sinkula in forum C Programming
    Replies: 6
    Last Post: 03-23-2003, 07:23 PM
  5. Check out My Text Rpg Game
    By knight543 in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2002, 10:40 PM