Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Nov 19th, 2005, 9:15 PM   #1
jayme
Professional Programmer
 
jayme's Avatar
 
Join Date: Nov 2005
Location: Canada
Posts: 495
Rep Power: 0 jayme is an unknown quantity at this point
Send a message via MSN to jayme
Text based game

Well, im about to embark on my very first program that will actually take some effort, well.. newb effort. This is going to be the hardest thing i've accomplished and i know i will finish because i never start something i wont finish because i believe its a waste of time if i dont finish, and i love programming! So.. here is the basics of the game:

Evil monsters

Poisonous frog
Fanged rabbit
Seagul
King cobra
Toothless farmer(Boss)


The game will consist of a hero(you) and there will be an experience system, health, mana, damage, and stats[Strength, Health, Agility]. It is a rpg type game that will simply let you level up to level 5, then you will face the farmer boss. Any help will be accepted, if your skills are needed.. not too much to help with though since its just text and im pretty sure i know how to do all of this on my own.. since it is infact another test for me. Any ideas will also be accepted if they appeal to me. I will update this thread daily, maybe every 2 days with the source, so people know what i've completed.

The main purpose of this is so that i will understand more clearly the basics of a game platform, and how the system works in general. Hopefully will help other people once i get posting the first couple segments of code. The Stats system i first created will be used in this game, although it might be tweaked slightly, since it did work.. but there were definately some small problems with it.

P.S The games name needs to be determined, so let me know if you have a name for it and it will most likely end up being called the name you decide, unless its something like "text game".. im looking for a little bit of a serious name.
__________________

Quote:
Originally Posted by Mohamed Jihad
Durka durka!
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it.

Download Code::Blocks now!

Last edited by jayme; Nov 19th, 2005 at 9:39 PM.
jayme is offline   Reply With Quote
Old Nov 20th, 2005, 1:47 AM   #2
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 6 bl00dninja is on a distinguished road
i would suggest using a pen and paper to carefully plan things out. as the program grows and you test it out, you'll discover most of your own mistakes and just crap you forgot or other stuff that would be neat to do. build piece by piece and get your basic framework up and running. after it "works" then you can tweak it ad nauseum. good luck!
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Old Nov 20th, 2005, 8:51 AM   #3
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
BN's right - pencil and paper are the best way to go. Don't be afraid to get messy. I would personally start by drawing the GUI, then pull out every single element (both tangible, such as the player, enemies, and inventory, and non-tangible, such as movement, combat etc.) and detail exactly how they work. If you'll be using a database, draw an Entity-Relationship diagram. Draw pictures, write pseudocode, and do anything else you think might help before you even touch the compiler.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Nov 20th, 2005, 12:29 PM   #4
jayme
Professional Programmer
 
jayme's Avatar
 
Join Date: Nov 2005
Location: Canada
Posts: 495
Rep Power: 0 jayme is an unknown quantity at this point
Send a message via MSN to jayme
Here is the first part, the character creation process. It is based off the one i made when i first came here, but it has been fixed a bit so that there is now reseting, so that you can reselect your skill points if you dont like what you have. Also now you cant be stuck at 0 skill points when you reach intelligents, or agility even.. I think this part is pretty close to complete except for a few minor errors.

#include <iostream>



using namespace std;

int main()
{    

     int reset = 0;
    int Points = 20;             // These are the max points you can spend on your skills (agility, strength, and intelligents.
    int Str;                // This is your characters strength skill level.
    int Int;                 // This is your characters intelligents skill level.
    int Agi;                 // This is your characters agility skill level.
    char Name[15];             // This is your characters name.
    int Frog;
    cout << "Welcome to Monster Fighter!\nThis is a text based game based on the RPG game-type.\n\n";
    cout << "Created by: Jay[dX], www.deceptiondesigns.com\n";



/* Stats System */

  
    cout << "Press enter to continue to the character creation proccess.\n\n"; // This is the initialization of the program. It tells you whats going to happen.
    cin.get();
    system("cls");
    cout << "Name your character: "; // Character naming process.
    cin >> Name;
    cout << "Ok, so now we have your characters name.\n\n";
    cout << "Now we will continue to your character's stats. You only have 20 points, so use them wisely.\n\n"; // Point system, add skill points to your abilities with these points.
    system("cls");


/* This is the Strength skill code.*/
   do {
    do{ // This is the strength loop, if you enter a number larger than 20 or less than 1, you will be taken back to this step.
    Points = 20;
    cout << "Enter your strength: "; 
    cin >> Str;
          if ( Str < 1 ) { // If the input is less than 1, the string below is executed and you will be asked to input a new integer.
               cout << "You Must spend at least one point!\n\n"; 
               }
          if ( Str > Points - 2 ){ // If the input is greater than the existing points, the string below will be executed and you will be asked to input a new integer.
          cout << "You don't have enough points!\n\n";
          }

} while ( Str > Points - 2 || Str <= 0 );
        cout << "Strength leveled up to " << Str << "!" << endl; // Lets you know that your selected integer was successfully added.
         Points = Points - Str; // Adds the selected points on to strength and reduces that same amount from your remaining skill points.
         cout << "You have " << Points << " skill points remaining.\n\n";


/* This is the Agility skill code.*/

    do{   // This is the agility loop, if you enter a number larger than 20 or less than 1, you will be taken back to this step.
          cout << "Enter your agility: ";
          cin >> Agi;
    
          if ( Agi < 1 ) { // If the input is less than 1, the string below is executed and you will be asked to input a new integer.
               cout << "You Must spend at least one point!\n\n"; 
               }
    
          if ( Agi > Points - 1 ){ // If the input is greater than the existing points, the string below will be executed and you will be asked to input a new integer.
          cout << "You don't have enough points!\n\n";

}
} while ( Agi > Points - 1 || Agi <= 0 );
        cout << "Agility leveled up to " << Agi << "!" << endl; // Lets you know that your selected integer was successfully added.
        Points = Points - Agi; // Adds the selected points on to agility and reduces that same amount from your remaining skill points.
        cout << "You have " << Points << " skill points remaining.\n\n";


/* This is the Intelligents skill code.*/

    do{ // This is the intelligents loop, if you enter a number larger than 20 or less than 1, you will be taken back to this step.
    cout << "Enter your Intelligents: "; 
    cin >> Int;
          if ( Int < 1 ) { // If the input is less than 1, the string below is executed and you will be asked to input a new integer.
               cout << "You Must spend at least one point!\n\n"; 
               }
          if ( Int > Points ){ // If the input is greater than the existing points, the string below will be executed and you will be asked to input a new integer.
          cout << "You don't have enough points!\n\n";
}
} while ( Int > Points || Int <= 0 );
        cout << "Intelligents leveled up to " << Int << "!" << endl; // Lets you know that your selected integer was successfully added.
         Points = Points - Int; // Adds the selected points on to intelligents and reduces that same amount from your remaining skill points.
         cout << "You have " << Points << " skill points remaining.\n\n";


/* This is the last segment of the code, it prints to the screen the name of your new character and your characters stats. */

   system ("cls");
   cout << "Congratulations, you have created your character successfully!\n\nHere is your character:\n\nCharacter name: " << Name << "\nAgility:-------- " << Agi << "\nStrength:------- " << Str << "\nIntelligents:--- " << Int << "\n\n\n\n\n\n\n\n\n\n";

         cout << "Enter either 1 to reselect hero skill points, or 0 to finish.";
         do {
         cin >> reset;
         
         if ( reset > 1 || reset < 0 ) {

              cout << "To reselect hero skill points enter\n1 = Yes, reselect skills.\n0 = No, they're fine.\n\n";
              }
              } while ( reset > 1 || reset < 0 );
              system ("cls");
} while ( reset == 1 );
   cin.get();
   system("PAUSE");
}
__________________

Quote:
Originally Posted by Mohamed Jihad
Durka durka!
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it.

Download Code::Blocks now!
jayme is offline   Reply With Quote
Old Nov 21st, 2005, 6:15 PM   #5
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,120
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by Ooble
BN's right - pencil and paper are the best way to go. Don't be afraid to get messy. I would personally start by drawing the GUI
What GUI? The OP said text-based. Perhaps you meant menus, assuming it's menu-driven, and not a (pseudo-) sentence-parser, in the style of the old Infocom games.

@jayme: There are two things that will improve that code a lot. First, you should use a function to get the user's input, rather than hard-coding it for each attribute. For example:
// assumes you have a variable called pointsRemaining that
// is properly initialized
cout << "Please enter your character's strength: ";
strength = getStat(pointsRemaining); // get the strength score
pointsRemaining -= strength;// reduce the number of points left
You The getStat function accepts an argument that tells it how many points the player has left, and verifies that the value is legal (ie, is a number, is not less than 1, is not greater than the number of points the player has left). Then, in the future, if you change the number of points a user gets when building a character, or the minimum/maximum ranges for each stat, you only have to change one or two lines of code.

Second, every time (this means every time!) that you get input from the user, verify that it's valid. Sometimes this means checking to make sure it's the right type of data (I guarantee your program will choke if the user enters "abc" for their strength score), and other times it means validating that the data falls within acceptable limits (is a number from 1 to 20, for example), or matches a pattern (useful when checking if something is, say, a valid postal/ZIP code, email address, or whatever).

Minor nitpick: it's 'intelligence', not 'intelligents'.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick

Last edited by lectricpharaoh; Nov 21st, 2005 at 6:27 PM.
lectricpharaoh is offline   Reply With Quote
Old Nov 21st, 2005, 7:11 PM   #6
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Quote:
Originally Posted by lectricpharaoh
What GUI? The OP said text-based. Perhaps you meant menus, assuming it's menu-driven, and not a (pseudo-) sentence-parser, in the style of the old Infocom games.
Cross out the "G" then.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Nov 22nd, 2005, 1:10 AM   #7
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 6 bl00dninja is on a distinguished road
"G" stands for "gay" :p
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Old Nov 22nd, 2005, 3:46 AM   #8
ivan
Professional Programmer
 
ivan's Avatar
 
Join Date: Sep 2005
Location: serbia & montenegro
Posts: 484
Rep Power: 4 ivan is on a distinguished road
GUI -> Gay User Interface LOL
ivan is offline   Reply With Quote
Old Nov 22nd, 2005, 5:43 AM   #9
BadBit
Programmer
 
BadBit's Avatar
 
Join Date: Oct 2005
Location: UK, South West
Posts: 33
Rep Power: 0 BadBit is on a distinguished road
no thats only if it's programmed in java.

Your code looks well organized, and programming syntax is good. apart from the systems options, i have always been told to trie and avoid these, as it can cause cross platform programming problems.

use getch(); instead.
Keep up the good work.
__________________
The GNU documentation says that this bit is set when the stream is "unusable". Presumably the intent is that once this bit becomes set, all bets are off on that stream forever.
BadBit is offline   Reply With Quote
Old Nov 22nd, 2005, 9:21 AM   #10
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Quote:
cause cross platform programming problems.
Quote:
use getch(); instead.
Oxymoron. Getch is NOT (or at least, rarely) cross-platform.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei 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 5:21 PM.

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