Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Request] rpg text game code/tut C++

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
dkwannab
Advanced Cheater
Reputation: 0

Joined: 11 Apr 2008
Posts: 52

PostPosted: Wed May 21, 2008 6:39 pm    Post subject: [Request] rpg text game code/tut C++ Reply with quote

Edit: I think this sums it up: i will no longer be using the old code im starting from scratch, so im also changing this thread to what i need now ^_^

Code:
Hi every 1,

I have been creating this text based rpg in c++ using just a lot of  the basic commands from the iostream

so far i have developed things like:

-stats (health, strength etc)
-fighting monsters (monsters are by random)
-leveling up and earning stat points
-dying (loose 5 levels when you die, level zero or below = game over)
-different attacks (different attacks do different damage)
-stat bonuses (swords, potions)

I've been trying to develop my game a lot further using the same simple commands, but when i incorporated things like inventory, shop, exp, etc.
they didn't function properly.

I have realised that to further develop it i will need to use classes (I have a little bit of knowledge about how the work but not much)

Because of this i have to start my game again.

I am requesting a code snippet of  a text rpg made using classes. (I learn quicker this way then using tuts; I already read a tut on using classes but i'm still not sure on how i would incorporate it into a game)
   
If you don't have a code then a tut will be fine.

Thanks in advance 


Last edited by dkwannab on Fri May 23, 2008 12:10 am; edited 2 times in total
Back to top
View user's profile Send private message
Mussy69
Grandmaster Cheater
Reputation: 0

Joined: 09 Mar 2007
Posts: 842
Location: Sydney

PostPosted: Thu May 22, 2008 1:48 am    Post subject: Reply with quote

Aren't you a bit worried someone will steal your source and turn it into their own, but it's really helpful to ME not for stealing but learning because i've just started learning C++ xD
_________________
Back to top
View user's profile Send private message AIM Address
killersamurai
Expert Cheater
Reputation: 0

Joined: 10 Sep 2007
Posts: 197
Location: Colorado

PostPosted: Thu May 22, 2008 3:23 am    Post subject: Reply with quote

I would suggest making classes. Make a character class that would be the base for everything. Then makes two other classes, one for the player and one for the enemies. You would be able to make an exp system better if you take an OO approach.

For the shop, create a class that contains a structure that holds item information. Then, use a vector to hold all the items you add. Then, create functions that will interact with the user.

I have to go to work, so I can't provide an example right now. But when I get off, I can provide one if no one else has.

http://books.google.com/books?id=OA9vMnZrCrcC&pg=PA235&lpg=PA235&dq=critter+c%2B%2B&source=web&ots=Wza46iwuZ6&sig=TMftCa1LN55bgDfbptwJiINsCVs&hl=en#PPA247,M1


Last edited by killersamurai on Thu May 22, 2008 3:38 pm; edited 1 time in total
Back to top
View user's profile Send private message
WolfDm3
Grandmaster Cheater
Reputation: 0

Joined: 11 Jun 2007
Posts: 502
Location: Mississippi

PostPosted: Thu May 22, 2008 7:49 am    Post subject: Reply with quote

Alright, im on my cellphone so it is hard to be explanatory but you could try this
Code:
int exp = 0 if exp > 100 (level up function)
then put this on monsters, you may have to add more
Code:
  exp + 1
Back to top
View user's profile Send private message AIM Address
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Thu May 22, 2008 7:03 pm    Post subject: Reply with quote

Yeah, I agree with the OO approach;

also, you should create like a Monster data file or something; coding all of that stuff in is terrible practice.

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
dkwannab
Advanced Cheater
Reputation: 0

Joined: 11 Apr 2008
Posts: 52

PostPosted: Thu May 22, 2008 7:42 pm    Post subject: Reply with quote

EDIT:
WolfDm3 wrote:
Alright, im on my cellphone so it is hard to be explanatory but you could try this
Code:
int exp = 0 if exp > 100 (level up function)
then put this on monsters, you may have to add more
Code:
  exp + 1


I spent ages doing all this but it fails because its like my inventory, instead of adding on it just shows the exp from you last battle, the reason i can have it keep adding on stats is because its a set amount each time, but with items, messos and exp it changes everytime so when you look at your exp/inventory it will only show what you got from your last battle =(

i need help on the oo method :s

I still need help with setting up an equip menu aswell =\ but basically like i said i needa know how i can make stuff add on instead of only showing from last battle =\

(ill post full code up top)
Code:
 case 'W':
            case 'w':
                if (equip >= 1) {
                 cout << "You currently equiped with a " << equipName << ".\n";
                 cout << "Your currently carrying a " << itemName << "\n";
                 cout << "Do you want to equip this as your current weapon? <y/n>\n";
                 choice = getch();
                 clear();
                 }else {
                 cout << "You currently equiped with nothing.\n";
                 cout << "Your currently carrying a " << itemName << "\n";
                 cout << "Do you want to equip this as your current weapon? <y/n>\n";
                 choice = getch();
                 clear();
                 
             }if (choice == 121) {
                equip++;
                cout << "The " << itemName << " has been equiped\n";
                pause();
                break;
            }else if (choice == 110) {
                cout << "The item has not been equiped\n";
                pause();
                break;
            }else {
                cout << "You Didn't input 'y' or 'n' try again\n";
                pause();
                break;
                }   
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites