Jump to content
  • Advertisement

ndrul

Member
  • Content Count

    10
  • Joined

  • Last visited

Community Reputation

100 Neutral

About ndrul

  • Rank
    Member
  1. ndrul

    C++ or another language

    I'm not a programmer that is just looking for results. It just that I had heard that a working tetria game can be made in a week so I was worried. I already use the rand() func for fighting in the rpg. and I will post it when I finish. But I am still questioning whether I should switch to c#.
  2. Hello again. Several days ago I was on these forums, determined to make my first game, a text based rpg. I got the help I needed then continued with my project. I read an article about how C++ is a bad beginner language and you should start with a simpler language. That's when I realized that I had been working on a text-based game for a week and hadn't even done the hard stuff. Should I continue with C++? I have been learning it for almost 2 months, so I am rluctant to give up. But C#,C, or maybe even python/java, are supposed to be more productive and beginner friendly. So what do you recommend? I want to be productive and I also want to be able to create a halfway decent 3D game. In your answer, could you list your experience?
  3. ndrul

    C++ showing vectors problem

    Duh. Sorry about that. I changed it and now everything works. Thank you everybody. One last question. What is the reputation under your profile name?
  4. ndrul

    C++ showing vectors problem

    I'm really sorry to keep bothering everybody, but i just cant seem to figure this out. Now i get this error: [font="Consolas"][size="1"][font="Consolas"][size="1"]1>txt rpg.cpp(44): error C2660: 'gameloop' : function does not take 1 arguments [/font][/font] [/quote]
  5. ndrul

    C++ showing vectors problem

    I just tried that but now it is saying that i am re-declaring inventory. EDIT: That is when i tried yewbie's solution.
  6. ndrul

    C++ showing vectors problem

    Here is the code. DO NOT run it. I had to copy it to word first, so your compiler might break if you try (partly joking). // txtrpg.cpp : main project file. [font="Times New Roman"] [/font]#include "stdafx.h" [font="Times New Roman"] [/font]#include <iostream> [font="Times New Roman"] [/font]#include <string> [font="Times New Roman"] [/font]#include <vector> [font="Times New Roman"] [/font]// myfiles [font="Times New Roman"] [/font]#include "playerClass.h" [font="Times New Roman"] [/font]#include "enemyClass.h" [font="Times New Roman"] [/font]using namespace std; [font="Times New Roman"] [/font]//functions [font="Times New Roman"] [/font]voidtellStory(); [font="Times New Roman"] [/font]voidgameloop(); [font="Times New Roman"] [/font]voidinstructions (); [font="Times New Roman"] [/font]voidmerchant(); [font="Times New Roman"] [/font]voidtrain(); [font="Times New Roman"] [/font]voidhire(); [font="Times New Roman"] [/font]// main tells story and starts game loop [font="Times New Roman"] [/font]int main() [font="Times New Roman"] [/font]{ [font="Times New Roman"] [/font] tellStory(); [font="Times New Roman"] [/font] // createsinventory !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! [font="Times New Roman"] [/font] vector<string> inventory; [font="Times New Roman"] [/font] inventory.push_back("sword"); [font="Times New Roman"] [/font] inventory.push_back("shield"); [font="Times New Roman"] [/font] inventory.push_back("armor"); [font="Times New Roman"] [/font] // ready tobegin? [font="Times New Roman"] [/font] string ready; [font="Times New Roman"] [/font] string* pReady = &ready; [font="Times New Roman"] [/font] do [font="Times New Roman"] [/font] { [font="Times New Roman"] [/font] cout << "\n\nAre you ready to begin? (yes/no) \n\n"; [font="Times New Roman"] [/font] cin >> *pReady; [font="Times New Roman"] [/font] } while(ready != "yes"); [font="Times New Roman"] [/font] gameloop(); [font="Times New Roman"] [/font] cout << "youmust now fight the dragon"; [font="Times New Roman"] [/font] char f; [font="Times New Roman"] [/font] cin >> f; [font="Times New Roman"] [/font] return 0; } [font="Times New Roman"] [/font]// tellsstory [font="Times New Roman"] [/font]voidtellStory() [font="Times New Roman"] [/font]{ [font="Times New Roman"] [/font] // tell story [font="Times New Roman"] [/font] cout << "Thereonce was a nation of great power and might. It was called Costinole, and it wasthe most powerful country of all time. "; [font="Times New Roman"] [/font] cout << "100Costinolean soldiers could defeat an army of 1,000. The ruler of Costinole wasKing Ostincise. "; [font="Times New Roman"] [/font] cout << "Hewas a great warrior and had ruled Costinole since its creation. He ledCostinole with an iron fist and sage wisdom. "; [font="Times New Roman"] [/font] cout << "Oneday, a new threat arrived in Costinole : a dragon. Costinole had never fought adragon before. "; [font="Times New Roman"] [/font] cout << "Thefinest knights were sent and three days later, all were dead. Many more knightswere sent to the same fate. "; [font="Times New Roman"] [/font] cout << "Eventually,King Ostincise went with a group of elite knights. None of them ever returned."; [font="Times New Roman"] [/font] cout << "Afterthe death of its leader, Costinole fell apart. Since then, it has been waitingfor a great warrior to arise and lead it back to greatness. "; [font="Times New Roman"] [/font] cout << "Manyhave tried, and many have failed. Are you up to the task.? \n\n\n"; [font="Times New Roman"] [/font] // giveinstruction [font="Times New Roman"] [/font] cout << "Youare the latest young soldier to try and fulfill this task. In order to proveyourself, you have been given 100 days to prove yourself. "; [font="Times New Roman"] [/font] cout << "Duringthis time, you have a number of tasks you may do to keep yourself busy. On thehundredth day, you must defeat the dragon. "; [font="Times New Roman"] [/font] cout << "Inorder to prepare yourself, you can train, fight enemies, buy items, and hireallies. "; [font="Times New Roman"] [/font] cout << "Forfull instructions, insert 'instructions'. "; [font="Times New Roman"] [/font]} [font="Times New Roman"] [/font]// gameloop is the game loop [font="Times New Roman"] [/font]voidgameloop() [font="Times New Roman"] [/font]{ [font="Times New Roman"] [/font] for (int day = 1; day < 100;) [font="Times New Roman"] [/font] { [font="Times New Roman"] [/font] cout<< endl << endl << "Day" << day << endl; [font="Times New Roman"] [/font] string move; [font="Times New Roman"] [/font] cin >> move; [font="Times New Roman"] [/font] if(move == "instructions") [font="Times New Roman"] [/font] { [font="Times New Roman"] [/font] instructions(); [font="Times New Roman"] [/font] } [font="Times New Roman"] [/font] if(move == "fight") [font="Times New Roman"] [/font] { [font="Times New Roman"] [/font] ++day; [font="Times New Roman"] [/font] cout << "fight"; [font="Times New Roman"] [/font] } [font="Times New Roman"] [/font] if(move == "merchant") [font="Times New Roman"] [/font] { [font="Times New Roman"] [/font] ++day; [font="Times New Roman"] [/font] merchant(); [font="Times New Roman"] [/font] } [font="Times New Roman"] [/font] if(move == "train") [font="Times New Roman"] [/font] { [font="Times New Roman"] [/font] ++day; [font="Times New Roman"] [/font] train(); [font="Times New Roman"] [/font] } [font="Times New Roman"] [/font] if(move == "hire") [font="Times New Roman"] [/font] { [font="Times New Roman"] [/font] ++day; [font="Times New Roman"] [/font] hire(); [font="Times New Roman"] [/font] } [font="Times New Roman"] [/font] [font="Times New Roman"] [/font] if(move == "inventory") [font="Times New Roman"] [/font] { [font="Times New Roman"] [/font] ++day; [font="Times New Roman"] [/font] for(int i = 0; i < inventory.size(); ++i) [font="Times New Roman"] [/font] cout inventory; [font="Times New Roman"] [/font] } [font="Times New Roman"] [/font] } [font="Times New Roman"] [/font] return; [font="Times New Roman"] [/font]} [font="Times New Roman"] [/font]//instructions shows commands and info about stats [font="Times New Roman"] [/font]voidinstructions() [font="Times New Roman"] [/font]{ [font="Times New Roman"] [/font] //commands [font="Times New Roman"] [/font] cout << "Typefight to fight enemies. Fighting gives you gold and experience."<< endl; [font="Times New Roman"] [/font] cout << "Typetrain to train. Training allows you to increase a stat by 1."<< endl; [font="Times New Roman"] [/font] cout << "Typemerchant to visit the merchant. You can buy equipment from the merchant."<< endl; [font="Times New Roman"] [/font] cout << "Typehire to hire a soldier to fight with you. Soldiers will help you inbattle." << endl; [font="Times New Roman"] [/font] cout << "Typeinventory to display your inventory" << endl; [font="Times New Roman"] [/font] //stats [font="Times New Roman"] [/font] cout << "\nYourmain stats are health, defense, and damage. Health is the amount of damage youcan take before death."; [font="Times New Roman"] [/font] cout << "Usea health potion to receive some health. Damage is the amount of damage youdeal. Swords increase your damage."; [font="Times New Roman"] [/font] cout << "Defenseis your damage resistance stat. Every 3 defense reduce the damage you receiveby 1."; [font="Times New Roman"] [/font]} [font="Times New Roman"] [/font]//merchant lets player buy and sell stuff [font="Times New Roman"] [/font]voidmerchant() [font="Times New Roman"] [/font]{ [font="Times New Roman"] [/font] cout << "Hello,what would you like to buy? I have swords, armor, shields, and potions"; [font="Times New Roman"] [/font]} [font="Times New Roman"] [/font]//letsyou train [font="Times New Roman"] [/font]voidtrain() { [font="Times New Roman"] [/font] cout << "train"; [font="Times New Roman"] [/font]} [font="Times New Roman"] [/font]//letsyou hire help [font="Times New Roman"] [/font]voidhire() [font="Times New Roman"] [/font]{ [font="Times New Roman"] [/font] cout << “hire”; [font="Times New Roman"] [/font]} [/quote] Sorry for all your trouble. I tried to bold stuff about the inventory, but im having technology trouble.
  7. ndrul

    C++ showing vectors problem

    No want to be a parrot, but this is exactly that . Please could you post the whole code ? (The problem is that your vector 'inventory' is out of the scope of your display function. You are declaring it at a wrong place) [/quote] Ok. I will post it as soon as I get back to my computer ( around 9 I hope)
  8. ndrul

    C++ showing vectors problem

    But the idea of putting it inside the player class is a good idea. Thank you. Do you have any problem with me doing that (I'll assume not)
  9. ndrul

    C++ showing vectors problem

    Sorry. Inventory is declared int the main() function. Then comes the game loop() function. If the player inputs "inventory", then it goes to the showInventory(). That is where i try to display it. I would post the whole code, but i dont think it is very clean.
  10. Hello everybody, this is my first post so let me know if I do anything wrong. Anyways, I am teaching myself C++ with "Beginning C++ game programming" (Dawson). I have actually found it rather easy so far (chapter 8 and 1 1/2 months). Now I am trying to finally branch out a bit on my own and have encountered a problem. I am makng a text RPG and am trying to make the inventroy with a vector. I declare with the following code: vector<string> inventory; inventory.push_back("sword"); inventory.push_back("shield"); inventory.push_back("armor"); This compiles fine, so I assume it is correct. But two functions later, I use this code to display the inventory: for (int i = 0; i < inventory.size(); ++i) cout << inventory; I use microsoft visual 2010 express and it says "error C2065: 'inventory' : undeclared identifier". What have I done wrong? Thank you!
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!