|
Save: SAVE: I CAN'T SAVE! |
Taiko Keiji
Member #8,307
February 2007
|
does anyone know how you can take the current game and save it into the disc for the player to continue later??? Life could be better, machines could program themselves. Taiko Keiji- |
GameCreator
Member #2,541
July 2002
|
What are you coding in?
|
Taiko Keiji
Member #8,307
February 2007
|
I'm coding in allegro. Life could be better, machines could program themselves. Taiko Keiji- |
HoHo
Member #4,534
April 2004
|
FILE* f=open_file_for_writing(); write_gamestate_to_file(f); close(f); Now you simply have to fill in the first two functions Loading goes exactly the same, only instead of writing to file you read from it __________ |
Taiko Keiji
Member #8,307
February 2007
|
is there any source code i could look at as a resource, it seems to be the best way for me to learn. Life could be better, machines could program themselves. Taiko Keiji- |
Onewing
Member #6,152
August 2005
|
Keep in mind there is no save_game() function, just like there isn't any play_game() or make_my_game_the_most_popular_game(). You've setup your game, you know what needs to be set to make things occur, you just need to write functions to store it and load it from an external file. Maybe you could start with your initilization functions to give you some direction. Perhaps you set "score" to 0 in the initilization function, well, you probably don't have 0 in the saved game. ------------ |
Taiko Keiji
Member #8,307
February 2007
|
Wow, I don't get it. ...It wont write to file?? Edit: Life could be better, machines could program themselves. Taiko Keiji- |
HoHo
Member #4,534
April 2004
|
__________ |
Taiko Keiji
Member #8,307
February 2007
|
Sweet, got it. Thanx alot.;D EDIT: Can anyone show me an example using these because when I tried to write to the file and then read from it it only says 0.
Life could be better, machines could program themselves. Taiko Keiji- |
Kauhiz
Member #4,798
July 2004
|
Use the code tags! And why do you have END_OF_FUNCTION after everything? --- |
Audric
Member #907
January 2001
|
ouch... |
Matthew Leverton
Supreme Loser
January 1999
|
What you need to do is learn how to read and understand manuals. For example, see fread: size_t fread(void *buffer, size_t size, size_t number, FILE *file); Description This function reads size*number characters from file to buffer. Return Value The number of items of size size read, or less if there was an error. ------ What you're trying to do is making absolutely no sense. Programming isn't like scrap booking. You cannot just copy and paste from this and that example, rename a few variables, and think that anything will work like what you are imagining. return fread(load1,sizeof(int),w,stdin); Examine what you are doing with what the manual says to do. |
Jeff Bernard
Member #6,698
December 2005
|
Here's somewhat of an example that may help you...
You also probably do not know what stdin is. stdin is a special variable (of type FILE* or _iobuf*, although those are basically the same thing, I think) that reads user input. Similarly, stdout is a special variable that outputs stuff, such as writing to the console screen. -- |
Taiko Keiji
Member #8,307
February 2007
|
Thanks alot, I understand now. Life could be better, machines could program themselves. Taiko Keiji- |
|