| jaywash (14) | |
| I just got "Sam's teach yourself c++ in one hour a day" for Christmas and its taught me quite a bit, however, I looked ahead in the book and it doesn't seem to cover text based games, I'm working on one and improving it as I read, but I want to be able to save, load, and erase the process done in game. It wouldn't be used right away, I'd program it in then comment it out for when I need it, but it would be nice to know how. Hope someone answers :) | |
|
|
|
| metulburr (278) | |
|
I also grabbed that book when i first started to learn programming. But that was when i was naive enough to think that i could actually learn c++ within a couple months. Don't let the title fool you. It takes a long time of practice to understand concepts, basic flow of a program, etc. Even people with 10+ years experience here say they are still learning and will always be learning. http://norvig.com/21-days.html Just because it does not explicitly say how to make a text game, does not mean that you can not use the advice from the book to make one. To save, load, etc.for example: you can save to a text file, to load you can load a text file, and to erase you can just delete the text file, This will save your data and be able to retrieve it later when the program closes. This is somewhat like making your own database, and making your own way of saving and retrieving from your own database. There are more efficient ways like MySQL, but for a text based game beginner, i would stick to file input/output as it also helps you learn that basic concept also. http://www.cplusplus.com/doc/tutorial/files/ | |
|
Last edited on
|
|
| jaywash (14) | |
| I know that it isn't possible to learn in a matter f months, I wanted to get this book as a way to get started, so far its helped :) as for the writing text files and stuff, how do I do that? | |
|
|
|
| metulburr (278) | |||
|
http://www.cplusplus.com/doc/tutorial/files/
| |||
|
Last edited on
|
|||
| jaywash (14) | |
| Alright, cool :) how do I use that to save the game? I can't seem to figure that out, I've only been coding for about a week :3 | |
|
|
|
| metulburr (278) | |
|
you make your own function to create the text file layout, and extract it the same. for example: this: filer << "Hey this is my first written text file. POOP\n";could be: filer << "10 3 5";where your function knows the the first number is (for example) 10 lives, and the second number 3 as hearts, and 5 something else whatever. So your function split the line by whitespace and puts it in an arrayknowing the indexes as specific meaning. at that point your functions returns those values back at the start of the game (which simulates the act of loading the game) as it knows when you left off or last saved. There are a few more things in between, but you'll have to figure them out yourself. | |
|
Last edited on
|
|
| jaywash (14) | |
| Lol I'm confused, I'll give it a while(3-4 weeks) and if I don't got it by then, I'll have more questions xP thanks for the help | |
|
|
|
| pogrady (525) | |
| Have you tried to create anything yet? | |
|
|
|
| metulburr (278) | |
|
i agree with pogrady. Don't start off by trying to make a text game, start off with some of these exercises http://www.cplusplus.com/forum/articles/12974/ spend a few days doing each, after you succeed, manipulate the program to do something else, to add 1 thing at a time. Then when you feel comfortable with that one move on to the next. Those alone could take awhile. Don't try to make something like Zork on your first week. | |
|
|
|
| jaywash (14) | |
| Lol I'm not trying anything like zork | |
|
|
|
| lucan74 (1) | |||
|
hi, i'm also doing a text base game.step by step. the code is show below.
i have problem with the random number generater. wonder anyone can help to improve it? thanks. | |||
|
|
|||