![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Newbie
Join Date: Aug 2007
Posts: 24
Rep Power: 0
![]() |
Well no matter which way I try to arrange them, it doesn't work. Does anyone know why it restarts when I type Yes? It starts repeating I think all the questions in the program without waiting for input.
|
|
|
|
|
|
#12 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
The first thing you need to do is show your new code. You can say you did this and that, but we are not sitting in your chair looking at your screen. The compiler is, but even the compiler doesn't like what you're doing.
I could also explain to you in detail why you need to test your input for success, but I've already done that about forty-leben times on this forum, and it gets old. On another not, not important, does the scrambled case of your user name flag you as a 'hacker' to your friends? Just curious.
__________________
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 |
|
|
|
|
|
#13 |
|
Newbie
Join Date: Aug 2007
Posts: 24
Rep Power: 0
![]() |
Here is my new code, sorry for not posting it.
#include <iostream>
#include <string.h>
//Days of Legend. Programmed by Darin Beaudreau.
//Copyright© 2007-2012. All rights reserved.
//This code may not be redistributed.
using namespace std;
int main()
{
while(1)
{
string playername;
string playerrace;
string playerclass;
int Yes = 1;
int No = 2;
int status;
int ready;
int menuchoice;
//Opening
cout << "\aHello there, what is your name? ";
getline (cin, playername);
cout << endl;
cout << "Hello, " << playername << "!\n";
cout << "\aWhat race will you play? ";
getline (cin, playerrace);
cout << "\aAnd what class shall you play, brave adventurer? ";
getline (cin, playerclass);
cout << "\aYou have chosen to be a " << playerrace << " " << playerclass << "!\n";
cout << "Welcome, " << playername << " to Days of Legend!\n";
cout << "\aIn a world filled with evil, will you take up your\n";
cout << "sword and defend the innocent? ";
cin >> ready;
if (ready == Yes)
{
cout << "Then welcome to Narghoz, the first town in your\n";
cout << "no doubt epic adventure!\n\n";
cout << "What would you like to do, " << playername << "?\n";
cout << "1.) Check Status\n";
cout << "2.) Quit\n";
cout << "Make your choice! ";
cin >> menuchoice;
}
if (ready == No)
{
cout << "Then come back when you have some hair on your chest!\n";
return 0;
}
}
system ("PAUSE");
}And yes, this is my alias on almost all the hacking forums I visit, including my own. |
|
|
|
|
|
#14 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
You have a hacking forum? I don't know a single true hacker that can't write his or her own code.
Your user can not enter the value 1 or the value 2 unless your user knows all about how to press a key that will generate the appropriate control character. Your user will (you hope) enter '1' or '2', which is not the same thing. Even worse, what if the user enters 'zzzzzzzzzzzzzzzzzzz'. What will you do? Will your game perform correctly if the user enters, as his or her race, "Bantu"? "Nagger"? Simply the ENTER key? Go off and design your program before you code. Come back when you have some hair on your chest.
__________________
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 |
|
|
|
|
|
#15 |
|
Newbie
Join Date: Aug 2007
Posts: 24
Rep Power: 0
![]() |
First off, yes, I do have my own forum, but not everything related to hacking has to do with coding. The only coding related work I've done is with HTML, and Javascript.
Second, I asked for help, if you're not willing to help, then don't respond to my thread. I just started learning C++ this week so obviously I'm a noob at it, but who wasn't at one point? And third, I have a website designed for the game because originally it wasn't going to be a video game. That website has a list of the races and classes so I don't think people would enter something other than what is given there. So, sorry for being a noob, I guess I'm not welcome here. |
|
|
|
|
|
#16 |
|
Programmer
Join Date: Jul 2005
Posts: 66
Rep Power: 4
![]() |
Yeah DaWei seems like he doesn't have much else to do but lay around on these forums rambling about how he is better than C++ than the newbies.Sad, if you ask me. Anyways, on topic: What's your problem now? |
|
|
|
|
|
#17 |
|
Professional Programmer
|
Actually Dawei is right. He tells you straight up how it is. Bascially you need to experiment with your code and see how it behaves when you change.
If you are waiting for the user to enter a responce tell them what kind of a responce you are looking for. For example: Are you ready? Enter (y,n) : Then if the user enters y you can store that in a char and compare it to a 'y' or a 'n' If you are planning on starting a game company then prepare yourself and your mate to listen to people like DaWei. Good luck with the company:beard:
__________________
JG-Webdesign |
|
|
|
|
|
#18 |
|
Newbie
Join Date: Aug 2007
Posts: 24
Rep Power: 0
![]() |
I HAVE experimented with the code, and mixed it around numerous times, but nothing I try works, which is why I asked for help.
|
|
|
|
|
|
#19 |
|
hi: for(;;) goto hi;
|
http://www.cplusplus.com/doc/tutorial/
after cleaning up the code to make it make sense C:\DOCUME~1\PEACEO~1\Desktop> g++ -o lol_at_this_game main.cpp main.cpp:56:2: warning: no newline at end of file C:\DOCUME~1\PEACEO~1\Desktop>lol_at_this_game.exe Hello there, what is your name? pop Hello, pop! What race will you play? nagger And what class shall you play, brave adventurer? bloodhound You have chosen to be a nagger bloodhound! Welcome, pop to Days of Legend! In a world filled with evil, will you take up your sword and defend the innocent? (Yes: 1, No: 2) 2 Then come back when you have some hair on your chest! C:\DOCUME~1\PEACEO~1\Desktop>
__________________
How do you play Religious Roulette? Stand around in a circle and blaspheme till someone gets struck by lightning. Last edited by peaceofpi; Aug 11th, 2007 at 7:00 PM. |
|
|
|
|
|
#20 |
|
Newbie
Join Date: Aug 2007
Posts: 24
Rep Power: 0
![]() |
Ok now the program doesn't spaz out anymore when I enter yes, it just goes back to the beginning and asks me my name again.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What is wrong with this code? | c0ldshadow | Visual Basic .NET | 5 | Dec 5th, 2005 5:37 PM |
| How to post a question | nnxion | C++ | 10 | Jun 3rd, 2005 11:53 AM |
| How to post a question | nnxion | C++ | 0 | Jun 3rd, 2005 8:55 AM |
| How to post a question | nnxion | C | 0 | Jun 3rd, 2005 8:55 AM |
| Any ideas what i've done wrong? (Newb C Programmer) Code included | Ramlag | C++ | 10 | Mar 22nd, 2005 1:57 PM |