Text Map(for adcenture game)

This is a discussion on Text Map(for adcenture game) within the C++ Programming forums, part of the General Programming Boards category; ok, I am attempting to make a basic rundown program for a text based adventure game. the code: Code: /* ...

  1. #1
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790

    Text Map(for adcenture game)

    ok, I am attempting to make a basic rundown program for a text based adventure game. the code:
    Code:
    /* -----Hunt---------------------------------*\
    * By Matthew Valley Copyright 2003             *
    * The objective of this game is to gain 100pt  *
    * or die(yes this will be an objective).       *
    *                                              *
    \**********************************************/
    
    /* header files*/
    #include <windows.h>
    #include <stdio.h>
    #include <iostream>
    #include <math.h>
    #include <conio.h> 
    using namespace std;
    
    /* Definitions*/
    
    #define PLAYER_OUT 3
    #define MONSTER_OUT 8
    #define GRASS 1
    #define BUSH 2
    #define MAX_MONSTERS 10
    #define MAX_GRID 30
    /* global variable Declarations */
    
    
    int i, j;
    
                          //1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U
    
    int Map_Grid[MAX_GRID][MAX_GRID] = //editted out as would not fit.
    
    void DisplayMap()
    {
    
    	for (i = 0; i < MAX_GRID; i++)
    	{
    		for (j = 0; j < MAX_GRID; j++)
    		{
                 cout << Map_Grid[i][j];
    		}
    		cout <<"\n";
    	}
    };
    
    void BeginDisplay()
    {
    	cout <<"** -----BASEMENT-----------------------------** \n"
             <<"* By Matthew Valley Copyright 2003             * \n"
             <<"* The objective of this game is to gain 100pt  * \n"
             <<"*  contact: Mattat13@hotmail.com               * \n"
             <<"*                                              * \n"
             <<"************************************************ \n";
    
    };
    /*
    
      initialize player and monster classes, as well as
      those of the Items.
    
    */
    
    
    /* Main Player Class*/
    
    class PLAYER_C
    {
    
    public:
    	int weapon;
    	int  Dmg;
    	int Health;
    	int Res;
    	int Mag;
    
    
    
    	int Plyr_Char_Pos_X;
    	int Plyr_Char_Pos_Y;
    	
    };
    
    
    /* Main monster class */
    
    class MONSTER
    {
    public:
    	int Dmg;
    	int Health;
    	int Res;
    
    
    	
    	int Monster_Pos_X;
    	int Monster_Pos_Y;
    };
    
    /* Main Item Class*/
    
    class ITEM
    {
    public:
    	int ResAdd;
    	int ResSub;
    	int MagAdd;
    	int MagSub;
    };
    
    
    int main()
    {
    	
    	int End_Game;
    	int amulet = 0, sword, ring;
    
    	MONSTER monsters[MAX_MONSTERS];
        PLAYER_C  Plyr;
    
    	for (i = 0; i < MAX_MONSTERS; i++)
    	{
    
    		monsters[i].Dmg = 11;
    		monsters[i].Health = 5;
    		monsters[i].Res    = 0;
    		monsters[i].Monster_Pos_X = rand() % MAX_GRID;
    		monsters[i].Monster_Pos_Y = rand() % MAX_GRID;
    
    		Map_Grid[monsters[i].Monster_Pos_Y][monsters[i].Monster_Pos_X] = MONSTER_OUT;
    
    	}
    
    	Plyr.Plyr_Char_Pos_X =20;
    	Plyr.Plyr_Char_Pos_Y =20;
    
    	Plyr.Health = 100;
    	Map_Grid[20][20] = PLAYER_OUT;
    
    	BeginDisplay();
    	
    	
    	DisplayMap();
    	
    
    	for (End_Game = 200; End_Game > 0 ; End_Game--)
    	{
    
    		cout << End_Game/2 <<" turns left \n"
    			 << Plyr.Health<<"health left \n";
    		cout <<" Which Direction Do you wish to go,\n N(W)\n E(D) \n S(S)\n W(A)\n: ";
    		
    
    		switch (getchar())
    		{
    
    		case 'W':
    
    			if (Map_Grid[Plyr.Plyr_Char_Pos_Y - 1][Plyr.Plyr_Char_Pos_X] != 2)
    			if (Map_Grid[Plyr.Plyr_Char_Pos_Y -1][Plyr.Plyr_Char_Pos_X ] != 4)
    			{
    			Plyr.Plyr_Char_Pos_Y = Plyr.Plyr_Char_Pos_Y - 1;
    				Map_Grid[Plyr.Plyr_Char_Pos_Y][Plyr.Plyr_Char_Pos_X] = PLAYER_OUT;
    			Map_Grid[Plyr.Plyr_Char_Pos_Y + 1][Plyr.Plyr_Char_Pos_X] = GRASS;
    			break;
    			}
    
    				
    			else
    				break;
    
    		case 'S':
    
    			if (Map_Grid[Plyr.Plyr_Char_Pos_Y + 1][Plyr.Plyr_Char_Pos_X] != 2)
    				if (Map_Grid[Plyr.Plyr_Char_Pos_Y +1][Plyr.Plyr_Char_Pos_X ] != 4)
    				{
    			Plyr.Plyr_Char_Pos_Y = Plyr.Plyr_Char_Pos_Y + 1;
    				Map_Grid[Plyr.Plyr_Char_Pos_Y][Plyr.Plyr_Char_Pos_X] = PLAYER_OUT;
    			Map_Grid[Plyr.Plyr_Char_Pos_Y -1][Plyr.Plyr_Char_Pos_X] = GRASS;
    			break;
    			}
    
    		
    			else 
    				break;
    
    		case 'D':
    
    			if (Map_Grid[Plyr.Plyr_Char_Pos_Y][Plyr.Plyr_Char_Pos_X +1] != 2)
    				if (Map_Grid[Plyr.Plyr_Char_Pos_Y][Plyr.Plyr_Char_Pos_X +1] != 4)
    			{
    			Plyr.Plyr_Char_Pos_X = Plyr.Plyr_Char_Pos_X + 1;
    			Map_Grid[Plyr.Plyr_Char_Pos_Y][Plyr.Plyr_Char_Pos_X] = PLAYER_OUT;
    			Map_Grid[Plyr.Plyr_Char_Pos_Y][Plyr.Plyr_Char_Pos_X - 1] = GRASS;
    			break;
    			}
    			else
    				break;
    
    		case 'A':
    			if (Map_Grid[Plyr.Plyr_Char_Pos_Y][Plyr.Plyr_Char_Pos_X -1] != 2)
    				if (Map_Grid[Plyr.Plyr_Char_Pos_Y][Plyr.Plyr_Char_Pos_X -1] != 4)
    			{
    			Plyr.Plyr_Char_Pos_X = Plyr.Plyr_Char_Pos_X - 1;
    			Map_Grid[Plyr.Plyr_Char_Pos_Y][Plyr.Plyr_Char_Pos_X] = PLAYER_OUT;
    			Map_Grid[Plyr.Plyr_Char_Pos_Y][Plyr.Plyr_Char_Pos_X + 1] = GRASS;
    			break;
    			}
    			else
    				break;
    
    		default:
    			break;
    		}
    
    		
    
    		
    		cout << "\n\n\n\n\n";
    
    		DisplayMap();
    		cout << "\n\n\n";
    
    	}
    
    	cout << " GAME OVER !";
    	
    	return 0;
    }
    Now, I have a problem. when it displays the map, only the last 18 rows are displayed on screen. also, is there anyway I can more efficiently make maps, than writing them up over and over with different combinations?

    thanks,

  2. #2
    1.b4 e5 2.a3 d5 3.d4 exd
    Join Date
    Jan 2003
    Posts
    167
    I also would like to know how to do this
    AIM: MarderIII

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with my text adventure game.
    By Haggarduser in forum Game Programming
    Replies: 15
    Last Post: 10-26-2007, 01:53 AM
  2. Game Engine Link Prob
    By swgh in forum Game Programming
    Replies: 2
    Last Post: 01-25-2006, 11:14 PM
  3. How to use FTP?
    By maxorator in forum C++ Programming
    Replies: 8
    Last Post: 11-04-2005, 02:17 PM
  4. Game Independent Anti-cheat Project Needs Programmers
    By GIA Project Lea in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 09-15-2005, 07:41 PM
  5. My Pre-Alpha Version Rpg Text Game
    By knight543 in forum C++ Programming
    Replies: 1
    Last Post: 04-06-2002, 05:02 AM

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