Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
If you are here, I have some questions to ask you.
------------------ And so the problem remained; lots of people were mean, and most of them were miserable, even the ones with digital watches. Many were increasingly of the opinion that they had all made a big mistake in coming down from the trees in the first place. And some said that the trees had been a bad move and that no one should ever have left the oceans. - Douglass Adams
Quote
Originally posted by theKestrel: **If you are here, I have some questions to ask you. **
Ask away!
------------------ -- Jeff
"This is a teaching hospital, you're here to learn. We'd call it a learning hospital, but that would scare the patients."
I don't know C++, but I know C. I might be able to help.
------------------ Andrew Schaaf CEO of (url="http://"http://www.frontiernet.net/~pschaaf/imrom")IMROM Software(/url) ------------------------- May the schwartz be with you!
Alright!!
Here it is:
I want to make a text-based game, similar to say, "Hitchhiker's Guide to the Galaxy", if you have played that. What I can't figure out is how to set up the variables/whatever, so that it recognize "where" you are in the game. E.G. If you go north from the original position, how will it recognize you went north when you give your next direction. I guess I did figure out how to do this, but my way would take a long time, and I don't think it is the best way. Right now, I just want to be able to move around in different rooms, although later I want to implement picking up items and using them, and if possible, do combat somehow. Here is what I have so far:
#include <apstring.cpp> #include <apstring.h> #include <iomanip.h> #include <conio.h>
int main() {
apstring direction; cout<<"You are in a small room with two exits."<<endl; cout<<"Which direction would you like to go?"<<endl; cout<<endl; cin>>direction;
if (direction == "N") { cout<<"Here this is"<<endl; }
else if (direction == "S") { cout<<"You fall into a pit and die!"<<endl; }
//Module for next move if first direction was North. { if (direction == "N") { cin>>direction;
if (direction == "S") { cout<<"You are in a small room with two exits."<<endl; } } }
//Module for if first direction was South.
{ if (direction == "S") { cin>>direction;
if (direction == "N") { cout<<"You are in a small room with two exits."<<endl; } } }
getch(); return 0; }
Note: I am a very new programmer. I don't even know what getch is, but I was working of someone elses program as a model.
Well, the game you're proposing to make is fairly complex. It's OK that you're a very new programmer (everyone has to start somewhere!) but it would probably be better if you learned more about programming and C++ before tackling a problem like this one. I'm not entirely sure it's possible to answer your question without explaining away the whole language first.
Do you have a book or a patient friend to learn from? If not, you should probably get one or the other.
------------------
That's not a good way to do it.
You should have a variable "int gCurrentRoomID;". Also, you should learn about structs, so you can keep information about the rooms in "RoomStruct gRooms(kMaxNumRooms);" In the RoomStruct, you should have "bool canGoNorth, bool canGoSouth, etc..." and "int northRoomID, int southRoomID, etc..." Then when you want to go north:
if(userInput == "N") { if(gRooms(gCurrentRoomID).canGoNorth) { gCurrentRoomID = gRooms(gCurrentRoomID).northRoomID; } }
// Do the same for the other directions
------------------ Andrew Schaaf CEO of (url="http://"http://www.frontiernet.net/~pschaaf/imrom")IMROM Software(/url) ------------------ May the schwartz be with you!
Haven't learned anything that you said Aschaaf, BUT I think I got a better way figured out.
My computer can't read the Metronub extension (if anybody has a clue why, tell me. It is CW 11) so I can't test this out, but will this work?
#include <iomanip.h> #include <iostream.h> #include <conio.h> #include <apstring.h>
int main() { apstring room, direction, Start = "You are in a dining hall.", Study = "You are in a study.", Library = "You are in a Library.";
room = Start cout<<Start<<endl; cin>>direction;
if (room == Start, direction == North) room = Study; cout<<Study<<endl; cin>>direction; if (room == Start, direction == South) room = Library; cout<<Library<<endl; cin>>direction; if (room == Library, direction == North) room = Start; cout<<Start<<endl; cin>>direction; if (room == Study, direction == South) room = Start; cout<<Start<<endl; cin>>direction;
return 0; }
So will it?
Originally posted by theKestrel: **Haven't learned anything that you said Aschaaf, BUT I think I got a better way figured out.
So will it? **
Well, it "will", but it's not much better than your first try. I HIGHLY recommend you learn about typedef structs, #defines, and loops.
You need to have a "while()" or a "do {} while()" loop.
Example:
(CODE) while(userWantsToQuit == false) {
cout << curRoomDescriptionString << endl;
cin >> userInput;
if(userInput == "q") userWantsToQuit = true;
// handle movement here
}
(QUOTE)Originally posted by theKestrel: I want to make a text-based game, similar to say, "Hitchhiker's Guide to the Galaxy", if you have played that. What I can't figure out is how to set up the variables/whatever, so that it recognize "where" you are in the game.
REPLY: If you're looking to simply write a text based RPG, you could do worse than to find a copy of TADS - Text Adventure Development System - which does most of the hard work behind the scenes. If on the other hand you're simply doing this as a learning exercise, then good luck, it's some starter project
DarkSide
You cannot defeat what you do not understand
Thanks for the advice.....would you believe somebody else told me this also? Hehe, I guess TADS must be famous. Anyway, I am doing it mostly as a learning exercise, but still, thanks for taking the time to help out.
Glad someone brought the topic up. Let me pose a few of my own questions, since I am fairly new at this as well.
Using CodeWarrior, I put in this:
#include <iostream.h>
int hithere;
cout << "Enter a digit:" << endl; cin >> hithere; cout << "Your digit is" << hithere << "." << endl;
END PROGRAM
I am basing what I type off of Visual C++, taught on a PC at school. CodeWarrior gives me 50 errors or more and pulls up strange documents that I did not write. What's going on here?
Furthermore, what makes a GUI program a GUI program? I don't see how I'm going to be able to make the jump from console programming to the crown jewel of Mac programming.
------------------ I find it disturbing that Bush, a man with one-and-a-half terms of being a governor in a state that doesn't give that official any real duties, can consider himself qualified to be President. Is there a solution? VOTE GORE.
That code seems fine to me. I think you didn't setup the CW project right.
As for the GUI:
Have you looked at apps in ResEdit? If you have, you'll see 'MENU's, 'WIND's, 'DLOG's, etc.
Some sample GUI code: myWindowPtr = GetNewCWindow( 128, nil, (WindowPtr)-1L); loads 'WIND' #128 SetControlValue( myControlHdl, 1); checks a Checkbox. myDialogPtr = GetNewDialog( 128, nil, (WindowPtr) -1L ); loads 'DLOG' #128
Foundations of Macintosh Programming is a nice book for learning Mac Toolbox (GUI) basics. (url="http://"http://www.mactech.com/macintosh-c")Macintosh C(/url) is MUCH more detailed.
Here's a sample modal dialog:
void SimpleModalDialog() { DialogPtr theDialog; short theItem; Boolean doneWithDialog = false; Â Â theDialog = GetNewDialog( 128, nil, (WindowPtr) -1L ); Â Â if(theDialog == nil) Â Â Â ExitToShell(); Â Â ShowWindow( theDialog ); Â Â Â Â Â Â SetDialogDefaultItem( theDialog, 1 ); Â Â Â Â Â Â while(doneWithDialog == false) { Â Â Â ModalDialog( nil, &theItem; ); Â Â switch(theItem) { Â Â case 1:// OK Â Â doneWithDialog = true; Â Â break; Â Â } } DisposeDialog( theDialog ); }
-Andrew
------------------ Andrew Schaaf CEO of (url="http://"http://www.frontiernet.net/~pschaaf/imrom")IMROM Software(/url) ------------------ "Families is where our nation finds hope, where wings take dream." -- G.W. Bush "It's clearly a budget. It's got a lot of numbers in it." -- G.W. Bush "Will the highways on the Internet become more few?" -- G.W. Bush Bush is a moron! VOTE FOR ALBERT GORE!
(This message has been edited by aschaaf_86 (edited 10-23-2000).)
Originally posted by aschaaf_86: **That code seems fine to me. I think you didn't setup the CW project right.
(snip)
**
I understand the ResEdit component of it; it just remains to understand how to use those in programming skills.
Normally I would use the UBB code to link a picture of my failed project right here. But, thanks to the nastiness of Crosswinds of which I plan to bail out of soon, they won't let me link to anything directly except my index.html. Sooooo...go to (url="http://"http://www.crosswinds.net/~spamguy")http://www.crosswinds.net/~spamguy(/url) , look for my link to the screenshot, and take a look. CW says it's in the code, since it never got past my source before giving me errors.
(This message has been edited by spamguy (edited 10-23-2000).)
Originally posted by spamguy: **I understand the ResEdit component of it; it just remains to understand how to use those in programming skills.
Normally I would use the UBB code to link a picture of my failed project right here. But, thanks to the nastiness of Crosswinds of which I plan to bail out of soon, they won't let me link to anything directly except my index.html. Sooooo...go to http://www.crosswinds.net/~spamguy , look for my link to the screenshot, and take a look. CW says it's in the code, since it never got past my source before giving me errors. **
The project seemed fine from what I could see of it. Are you compiling it as C++?
(This message has been edited by aschaaf_86 (edited 10-24-2000).)
Originally posted by spamguy: **thanks to the nastiness of Crosswinds of which I plan to bail out of soon, they won't let me link to anything directly except my index.html. **
Maybe you should use iTools. It gives you 20MB space, and it has no banners.
------------------ Andrew Schaaf CEO of (url="http://"http://www.frontiernet.net/~pschaaf/imrom")IMROM Software(/url) ------------------ "Families is where our nation finds hope, where wings take dream." -- G.W. Bush
Man oh man that's an old version of CW It looks like CW Lite. Or is it just that the non-Pro versions look like that?
I would also recommend Macintosh C. I haven't read through it yet, only looked through all the demos (all my Toolbox knowledge is System 7-based :p)
Just in case anyone is wondering, the code example aschaaf posted would need to be changed if it were to be carbonized
------------------ -- Jeff "This is a teaching hospital, you're here to learn. We'd call it a learning hospital, but that would scare the patients."
(This message has been edited by Merciless (edited 10-24-2000).)
Originally posted by Merciless: **Man oh man that's an old version of CW:) It looks like CW Lite. Or is it just that the non-Pro versions look like that?
Ouch. That hurt my feelings. j/k
It's an Academic version of CW from 1996/7. For $50, you get the better-than-lite version, plus a large mass of PDFs teaching from Java to Pascal.
I'm not upgrading 'til I learn an acceptable amount of C++.
As far as I know, I'm compiling in C++. Why, is there something that tells it to compile in C++ and not C? Right now I have thought that since the two fall under a single project type, you don't tell it in what language to compile.
As for the comment about iTools: I don't have OS 9. I don't want to get it, because it's 90% like 8.5, all for $50.
Originally posted by spamguy: **As far as I know, I'm compiling in C++. Why, is there something that tells it to compile in C++ and not C? Right now I have thought that since the two fall under a single project type, you don't tell it in what language to compile.
As for the comment about iTools: I don't have OS 9. I don't want to get it, because it's 90% like 8.5, all for $50. **
When you create a project, you can choose to make a Standard Console C, or a Standard Console C++. If you make a Mac Toolbox one, you don't have to choose between C and C++. Try creating a Standard Console project.
As for iTools, you don't need OS 9! (url="http://"http://www.acts.org/itoolstrick/")http://www.acts.org/itoolstrick/(/url) However, I think you can't sign up using 8.x anymore, so you'll need to get an OS9-using-friend to create an acount for you.
Originally posted by DarkSide: ** If you're looking to simply write a text based RPG, you could do worse than to find a copy of TADS - Text Adventure Development System - which does most of the hard work behind the scenes. **
If you're still there, DarkSide, where can I get a copy of this "TADS"? I'll try to search for it, but where can you get it? I'm doing a project simalar to what you're explaining what "TADS" can do.
------------------ Ferazel Rocks!