Need Help With an RPG Style Game

This is a discussion on Need Help With an RPG Style Game within the Game Programming forums, part of the General Programming Boards category; I've been taking a Computer Science class during the year and I was doing well in it so a friend ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    6

    Need Help With an RPG Style Game

    I've been taking a Computer Science class during the year and I was doing well in it so a friend and I decided to attempt to make an rpg game. So far all we've done is try to make prototypes for the different aspects of the game such as saving and opening game data, fighting systems, defining character attributes in simple ways, and general functions that can be used for all characters. We've been attempting to do this with the use of random generation, vectors, matrices, apstrings, and filestreams. I created this topic so I could post problems that I'm encountering along the way so I could obviously get help. If anyone wants to help in the creation of an rpg style game (similar to the Final Fantasy Games) e-mail me. (We need a lot of help). I did have a few problems here when I first posted this topic but I solved them myself eventually.
    Last edited by JayDog; 03-30-2003 at 01:01 AM.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,701
    Its always a pleasure to see someone designing before they code!

    gg

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    6
    Well the first game I made was a tic tac toe game. I included player vs player and player vs computer. Now that I look back on it, it should have been easy, but I never planned out what I was doing. By the time I was done writing the program and I tried to build it for the first time I had 300 errors and even after I fixed the 300 errors it didn't work. So I just planned the program and rewrote it and it took me like two hours.

    That would be why I'm planning out my game as much as I can.

  4. #4
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    That is the first lesson people learn in making games. Planning is key. I remember starting a bunch of games, only to finish them off as demos because it was so hard to implement anything to it.

    Can you post some info that you have written up plz? I might get some ideas from it when I start my next RPG.

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    6
    Uh today I created a map editor, well not a great map editor, but it works nonetheless. Since I dont know how to insert graphics into C++, the map editor below allows you to input any symbol you want into it. To use it though you need to include these header files and source files I think...apvector.cpp, apvector.h, apmatrix.cpp, and apmatrix.h.

    I zipped the files together in a zip file.

    Code:
    #include <stdio.h> 
    #include <conio.h>
    #include "apvector.h"
    #include "apmatrix.h"
    #include "apstring.h"
    #include <time.h>
    #include <fstream.h>
    #include <windows.h>
    
    enum
    {
    	KEY_ESC     = 27,
    	ARROW_UP    = 256 + 72,
    	ARROW_DOWN  = 256 + 80,
    	ARROW_LEFT  = 256 + 75,
    	ARROW_RIGHT = 256 + 77
    };
    
    static int get_code ()
    {
    	int ch = getch();
    
    	if ( ch == 0 || ch == 224 )
    		ch = 256 + getch();
    	return ch;
    }
    
    struct pospass
    {
    	char terrain;
    	bool passable;
    };
    
    bool Valid(int a, int b);
    void Display(apmatrix<pospass> A);
    void sleep_ticks ( long ticks );
    void LoadFile (apmatrix<pospass> & B);
    void clrscr();
    
    int main ()
    {
    	cout<<"------------------------------------------------"<<endl;
    	cout<<"Welcome to Terrain Editor Verson 1.0"<<endl;
    	cout<<"This program was created by Jaymin Patel"<<endl;
    	cout<<"Any type of terrain can be added to the editor."<<endl;
    	cout<<"The keys used in this program are..."<<endl;
    	cout<<"The Arrow Keys: To move the cursor # around."<<endl;
    	cout<<"/: To place impassable terrain."<<endl;
    	cout<<"*: To place passable terrain."<<endl;
    	cout<<"C: To insert an empty space."<<endl;
    	cout<<"L: To load a file."<<endl;
    	cout<<"Esc: To stop and save progress."<<endl;
    	cout<<"------------------------------------------------"<<endl;
    	getch();
    	apmatrix<pospass> B(23, 79);
    	int i, k;
    	for (i=0; i<B.numrows(); i++)
    	{
    	for (k=0; k<B.numcols(); k++)
    		{
    			B[i][k].terrain = ' ';
    		}
    		cout<<endl;
    	}
    	for (i=0; i<B.numcols(); i++)
    	{
    		B[0][i].terrain = 'X';
    		B[0][i].passable = false;
    	}
    	for (i=0; i<B.numrows(); i++)
    	{
    		B[i][0].terrain = 'X';
    		B[i][0].passable = false;
    	}
    	for (i=0; i<B.numrows(); i++)
    	{
    		B[i][78].terrain = 'X';
    		B[i][78].passable = false;
    	}
    	for (i=0; i<B.numcols(); i++)
    	{
    		B[22][i].terrain = 'X';
    		B[22][i].passable = false;
    	}
    	for (i=1; i<B.numrows()-1; i++)
    	{
    		for (k=1; k<B.numcols()-1; k++)
    			B[i][k].terrain = '.';
    	}
    	i = 0;
    	k = 0;
    	B[i][k].terrain = '#';
    	int ch;
    	char temp;
    	temp = 'X';
    	char tterrain;
    	tterrain = ' ';
    	Display(B);
    	while ( ( ch = get_code() ) != KEY_ESC )
    	{
    		switch ( ch ) 
    		{
    			case ARROW_UP:
    			{
    				clrscr();
    				if (Valid((i-1), k) == true)
    				{
    					B[i][k].terrain = temp;
    					i=i-1;
    					temp = B[i][k].terrain;
    					B[i][k].terrain  = '#';
    				}
    				Display(B);
    				sleep_ticks (100);
    				break;
    			}
    			case ARROW_DOWN:
    			{
    				clrscr();
    				if (Valid((i+1), k) == true)
    				{
    					B[i][k].terrain = temp;
    					i=i+1;
    					temp = B[i][k].terrain;
    					B[i][k].terrain  = '#';
    				}
    				Display(B);
    				sleep_ticks (100);
    				break;
    			}
    			case ARROW_LEFT:
    			{
    				clrscr();
    				if (Valid(i, (k-1)) == true)
    				{
    					B[i][k].terrain = temp;
    					k=k-1;
    					temp = B[i][k].terrain;
    					B[i][k].terrain  = '#';
    				}
    				Display(B);
    				sleep_ticks (100);
    				break;
    			}
    		
    			case ARROW_RIGHT:
    			{
    				clrscr();
    				if (Valid(i, (k+1)) == true)
    				{
    					B[i][k].terrain = temp;
    					k=k+1;
    					temp = B[i][k].terrain;
    					B[i][k].terrain  = '#';
    				}
    				Display(B);
    				sleep_ticks (100);
    				break;
    			}
    
    			case '*':
    			{
    				cout<<"Enter your terrain: ";
    				cin>>tterrain;
    				temp = tterrain;
    				B[i][k].passable = true;
    
    				break;
    			}
    			case '/':
    			{
    				cout<<"Enter your terrain: ";
    				cin>>tterrain;
    				temp = tterrain;
    				B[i][k].passable = false;
    				break;
    			}
    			case 'C':
    			case 'c':
    			{
    				tterrain = '';
    				temp = tterrain;
    				B[i][k].passable = true;
    				break;
    			}
    			case 'L':
    			case 'l':
    			{
    				cout<<"You have chosen to load a file..."<<endl;
    				LoadFile(B);
    				cout<<"Your file has been loaded."<<endl;
    				getch();
    				clrscr();
    				Display(B);
    				break;
    			}
    		}
    	}
    	B[i][k].terrain = temp;
    	cout<<"------------------------------------------------"<<endl;
    	cout<<"You have quit the editor, you may now save your file."<<endl;
    	cout<<"Your file will be saved in two data files with similar names."<<endl;
    	cout<<"One file will record terrain and and one file will record"<<endl;
    	cout<<"passable related data in matrix format."<<endl;
    	cout<<"It is suggested that you do not edit the data files"<<endl;
    	cout<<"Unless you understand the program."<<endl;
    	cout<<"------------------------------------------------"<<endl;
    	getch();
    	cout<<"Once your file is saved copy the data files that"<<endl;
    	cout<<"have been created and paste them in another folder."<<endl;
    	cout<<"If you dont you will write over old maps."<<endl;
    	cout<<"------------------------------------------------"<<endl;
    	getch();
    	cout<<"Your file has been saved...later."<<endl;
    	cout<<"------------------------------------------------"<<endl;
    	ofstream output;
    	ofstream outputa;
    	int l, j;
    	output.open("map_terrain.txt");
    	for (j=0; j<B.numrows(); j++)
    	{
    		for (l=0; l<B.numcols(); l++)
    			output<<B[j][l].terrain;
    		output<<endl;
    	}
    	outputa.open("map_passable.txt");
    	for (j=0; j<B.numrows(); j++)
    	{
    		for (l=0; l<B.numcols(); l++)
    		{
    			if (B[j][l].passable == true)
    				outputa<<"1"<<" ";
    			else
    				outputa<<"0"<<" ";
    		}
    		outputa<<endl;
    	}
    	return 0;
    }
    
    void sleep_ticks ( long ticks ) 
    {
      clock_t limit, now = clock();
      limit = now + ticks;
      while ( limit > now )
        now = clock();
    }
    
    void Display(apmatrix<pospass> A)
    {
    	for (int i=0; i<A.numrows(); i++)
    	{
    		for (int k=0; k<A.numcols(); k++)
    		{
    			cout<<A[i][k].terrain;
    		}
    		cout<<endl;
    	}
    	return;
    }
    
    bool Valid(int a, int b)
    {
    	if ((a > -1) && (a < 22) && (b > -1) && (b < 79))
    		return true;
    	else
    		return false;
    }
    
    void LoadFile (apmatrix<pospass> & B)
    {
    	ifstream input;
    	ifstream inputa;
    	int l, j;
    	apmatrix<int> M(23, 79);
    	input.open("map_terrain.txt");
    	for (j=0; j<B.numrows(); j++)
    	{
    		for (l=0; l<B.numcols(); l++)
    			input>>B[j][l].terrain;
    	}
    	for (j=0; j<M.numrows(); j++)
    	{
    		for (l=0; l<M.numcols(); l++)
    			input>>M[j][l];
    	}
    	inputa.open("map_passable.txt");
    	for (j=0; j<B.numrows(); j++)
    	{
    		for (l=0; l<B.numcols(); l++)
    		{
    			if (M[j][l] == 1)
    				B[j][l].passable = true;
    			else
    				B[j][l].passable = false;
    		}
    	}
    
    
    	return;
    }
    
    void clrscr()
    {
        COORD                       coordScreen = { 0, 0 };
        DWORD                       cCharsWritten;
        CONSOLE_SCREEN_BUFFER_INFO  csbi;
        DWORD                       dwConSize;
        HANDLE                      hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        GetConsoleScreenBufferInfo(hConsole, &csbi);
        dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
        FillConsoleOutputCharacter(hConsole, TEXT(' '), 
                                   dwConSize, coordScreen, &cCharsWritten);
        GetConsoleScreenBufferInfo(hConsole, &csbi);
        FillConsoleOutputAttribute(hConsole, csbi.wAttributes, 
                                   dwConSize, coordScreen, &cCharsWritten);
        SetConsoleCursorPosition(hConsole, coordScreen);
    }
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    6
    I updated the map editor greatly, here's a new version. It includes character talking that doesn't interrupt map movement.

    The Zip File has a password, "JayDog"

    And you wanted a specific example of coding I'm using in the game. So below I've copied and pasted the structs I'm using to store character and monster data. They wont necessarily be exactly like that since a lot of those are exactly like final fantasy data. Generally the structs would be used during the program and matrices and textfiles are used to store the information.

    Code:
    //STRUCTS
    struct character
    {
    	//Main Information
    		apstring cname;
    		int chp;
    		int cmp;
    		bool clmagic;
    		bool cdmagic;
    
    	//Individiual Statistics
    		int clevel;
    		int cexp;
    		int cexplimit;
    		int cstrength;
    		int cmagic;
    		int caccuracy;
    		int cagility;
    
    	//Status Ailments
    		bool chaspoison;
    		bool chasmpabsorb;
    		bool dead;
    
    				
    	//Weapon/Damage Related
    		int climitattack;
    		int cweapon;
    		int carmor;
    				
    	//Distinctly Light Magic Related
    		bool ccure;
    		bool ccura;
    		bool ccuraga;
    		bool clife;
    		bool clifa;
    		bool cli$$$a;
    		bool cremeda;
    
    	//Distinctly Dark Magic Related
    		bool cfire;
    		bool cfira;
    		bool cfiraga;
    		bool cblizzard;
    		bool cblizzara;
    		bool cblizzaga;
    		bool cthunder;
    		bool cthundara;
    		bool cthundaga;
    		bool cbio;
    		bool cmpabsorb;
    };
    
    struct monster
    {
    	//Main Information
    		apstring mname;
    		apstring mtype;
    		int mhp;
    		int mmp;
    		bool mtruemagic;
    
    	//Individiual Statistics
    		int mlevel;
    		int mstrength;
    		int mmagic;
    		int maccuracy;
    		int magility;
    
    	//Status Ailments
    		bool mhaspoison;
    		bool mhasmpabsorb;
    
    				
    	//Damage Related
    		int melemattack; //1-9 Look at Magic
    		int mstatattack;
    
    			/*
    				1.) Poison
    				2.) MP Absorb
    			*/
    
    
    	//Armor/Blocking Related
    		int melemdefend; //1-9 Look at Magic;
    		int mstatdefend;
    
    			/*
    				1.) Poison
    				2.) MP Absorb
    			*/
    
    	//Distinctly Dark Magic Related
    		bool mfire; //1
    		bool mfira; //2
    		bool mfiraga; //3
    		bool mblizzard; //4
    		bool mblizzara; //5
    		bool mblizzaga; //6
    		bool mthunder; //7
    		bool mthundara; //8
    		bool mthundaga; //9
    
    	//Status Attacks
    		bool mpoison;
    		bool mmpabsorb;
    };
    Attached Files Attached Files
    Last edited by JayDog; 03-30-2003 at 08:42 PM.

  7. #7
    Registered User
    Join Date
    Mar 2003
    Posts
    6
    The game so far doesn't send information to saves it only takes it from saves, since I haven't really done anything with the game. For you to see whats happening you'll probably just have to look through the code (doesn't look like I did a damn thing if you run it).
    Attached Files Attached Files

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C# - Building a SCUMM-like game.. questions
    By Iyouboushi in forum Game Programming
    Replies: 0
    Last Post: 05-24-2008, 11:54 PM
  2. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 03:46 PM
  3. 2D RPG Online Game Project. 30% Complete. To be released and marketed.
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 10-28-2006, 01:48 AM
  4. My Pre-Alpha Version Rpg Text Game
    By knight543 in forum C++ Programming
    Replies: 1
    Last Post: 04-06-2002, 06:02 AM
  5. Writing a DOOM style game in VC++ & OGL
    By Zeeshan Zia in forum Game Programming
    Replies: 1
    Last Post: 10-20-2001, 05:13 AM

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