Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 17th, 2006, 9:37 PM   #1
Varrickmana
Newbie
 
Varrickmana's Avatar
 
Join Date: May 2006
Posts: 21
Rep Power: 0 Varrickmana is on a distinguished road
Talking Text-Based RPG

I'm new at C++ and I want to make a cool text-based rpg. My complier is Dev-C++. Can someone help me out get started? Maybe if you have one of your own I could examine the source code. It would be really cool if someone with some experiance could help me with this. Please help as much as you can, but don't sweat it. Thanks. :banana: (I'm so excited lol)
Varrickmana is offline   Reply With Quote
Old May 17th, 2006, 9:46 PM   #2
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
What type of help are you looking for exactly? If you're looking for source-code to use as an example, you could try searching at www.planetsourcecode.com .
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old May 17th, 2006, 10:55 PM   #3
mrynit
Hobbyist Programmer
 
mrynit's Avatar
 
Join Date: Mar 2006
Location: WA, USA
Posts: 340
Rep Power: 3 mrynit is on a distinguished road
Send a message via AIM to mrynit Send a message via MSN to mrynit Send a message via Yahoo to mrynit Send a message via Skype™ to mrynit
this is my half arse attempt at stratego. it is not an rpg but it would help. i need to comment more. do not the modular programing useing functions.

main code
#include <iostream>
#include <conio>
#include <string>
#include <fstream>
using namespace std;

//players 2-10. spy, bomb, flag
//flag = 0
//bomb = 1
//spy = 11
//freespace = -1
//water = -2
//map 10 X 10
//(0,0) = (5,3)

void printMap(); //pints map grid on screen
void printArray(int map[10][10]);//test to see whats in the map array
void printUnit(int x, int y, int unit);// print on screen units
// this is the for loop for the templet
void mainPlace(int map[10][10], string unitName[12], int amount[12], int arrayVal[12]); 
//this is the repeted code
void placeTemp(int map[10][10], string unit, int mount, int val);
//return checkOpen(int map[10][10], int x, int y);
int main()
{
   int map[10][10];
   int amount[12] =   {1,6,1,8,5,4,4,4,3,2,1,1};
   int arrayVal[12] = {0,1,11,2,3,4,5,6,7,8,9,10};
   string unitName[12] = {"Flag","Bombs","Spy","Scouts","Miners","Sergeants",
   "Lieutenants","Captains","Majors","Colonels","General","Marshal"};

   getchar();   
   system("cls");

   printMap();
  
   mainPlace(map, unitName, amount, arrayVal);
  
   //printArray(map);
   
   getchar(); 
      
   return 0;
}

void printMap()
{   
  string mapImage;
  ifstream myFile ("map.txt");
  if (myFile.is_open())
  {
    while (! myFile.eof() )
    {
      getline (myFile,mapImage);
      cout << mapImage << endl;//have this be into into array
    }
    myFile.close();
  }

  else cout << "Unable to open file"; 
}

void printArray(int map[10][10])
{
   for (int y = 0; y < 10; y++)
   {
      for (int x = 0; x < 10; x++)
      {
         cout << map[x][y] << " ";
      }
      cout << endl;
   }
}


void printUnit(int x, int y, int unit)
{
   gotoxy((2 * x) + 5,(2 * y) + 3);

   if ((unit > 1) && (unit < 10))
      cout << unit;
   else
   {
      switch (unit)
      {
         case 0 : cout << "F";//flag
         break;
         case 1 : cout << "B";//bomb
         break;
         case 10: cout << "M";//marshal, 10's unit to big to be displayed on map
         break;
         case 11: cout << "S";//spy
         break;
      }
   }

}

void mainPlace(int map[10][10], string unitName[12], int amount[12], int arrayVal[12])
{
   gotoxy(30,5);
   cout << " Place ";
   gotoxy(30,6);
   cout << "-------------------";
   
   for (int i = 0; i < 12; i++)
   {
      placeTemp(map, unitName[i], amount[i], arrayVal[i]);
    }
}

void placeTemp(int map[10][10], string unit, int mount, int val)
{
   int x,y;

   gotoxy(37,5);
   cout << unit << "      " << endl;
   for (int i = 0; i < mount; i++)
   {
      gotoxy(30,7);
      cout << "location( , ) " << (mount - i);
      gotoxy(39,7);
      cin >> x;
      gotoxy(41,7);
      cin >> y;
      map[x][y] = val;
      printUnit(x,y,val);
   }
}

map
 X  0 1 2 3 4 5 6 7 8 9
Y   - - - - - - - - - -
0  | | | | | | | | | | |
    - - - - - - - - - -
1  | | | | | | | | | | |
    - - - - - - - - - -
2  | | | | | | | | | | |
    - - - - - - - - - -
3  | | | | | | | | | | |
    - - - - - - - - - -
4  | | |w|w| | |w|w| | |
    - - - - - - - - - -
5  | | |w|w| | |w|w| | |
    - - - - - - - - - -
6  | | | | | | | | | | |
    - - - - - - - - - -
7  | | | | | | | | | | |
    - - - - - - - - - -
8  | | | | | | | | | | |
    - - - - - - - - - -
9  | | | | | | | | | | |
    - - - - - - - - - -

is this too long?
__________________
i dont know much about programming but i try to help
mrynit is offline   Reply With Quote
Old May 18th, 2006, 7:46 AM   #4
Varrickmana
Newbie
 
Varrickmana's Avatar
 
Join Date: May 2006
Posts: 21
Rep Power: 0 Varrickmana is on a distinguished road
Thanks

Yeah, this definitly helps alot. I'm a newb so I am just looking for source code examples. Mjordan2nd, I'll definitly check out that site. mrynit, your Strategeo game looks pretty good, and when it's done, my I suggest submiting it to gamehippo.com. It's a website that allows you to download freeware games. It would probably have a nice turnout, as they review every game, and there's only one other Stratego game on it that was made with Java and normally doesn't work. Just an idea. Thanks. :banana:
Varrickmana is offline   Reply With Quote
Old May 18th, 2006, 12:05 PM   #5
Varrickmana
Newbie
 
Varrickmana's Avatar
 
Join Date: May 2006
Posts: 21
Rep Power: 0 Varrickmana is on a distinguished road
Any more posts on this thread would be gratefully accepted.
__________________
Kids, every year, more than 400,000 people die from tobacco chewing, smoking, an-
MY GOD, HERE COMES A ZOMBIE PIRATE NINJA!!!!!!
Varrickmana is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:54 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC