Results 1 to 15 of 15

Thread: save/load

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    226

    save/load

    im hopeing maybe in here i might finally get my answer for this.....but before i ask my question u need to know games that u can save where u r then load back to where u left off.....for explain Final Fansty 7 is a great explain.....and final fansty games save/load.....devil may cry 1-3.....ect.....now my question is how do i add a save/load to my game so it keeps all the date like....for explain name, how far u r, life, items, ur char, ect....

  2. #2
    Fanatic Member damasterjo's Avatar
    Join Date
    Nov 2005
    Location
    In front of my Comp DirectX7 EXpert
    Posts
    827

    Re: save/load

    I would recommend storing everything in a text file. Write to it line by line or whatever when they save, then when they load, take that text file read it line by line and assign the data to the appropriate variables. This is very simple and allows you easy access to it, so you can edit the file yourself to put you indifferent areas of the game so you can test it.
    Software languages known:
    Qbasic - TI-Basic - Liberty Basic - Visual Basic 6
    Software API's known:
    Directx 7 and 8
    Internet languages, in the process of learning:
    HTML - JAVASCRIPT - PHP - CSS - MYSQL - AJAX

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    226

    Re: save/load

    Quote Originally Posted by damasterjo
    I would recommend storing everything in a text file. Write to it line by line or whatever when they save, then when they load, take that text file read it line by line and assign the data to the appropriate variables. This is very simple and allows you easy access to it, so you can edit the file yourself to put you indifferent areas of the game so you can test it.
    1 problem.....i want to so other user not just me can save n load without trouple

  4. #4
    Fanatic Member neicedover1982's Avatar
    Join Date
    Jun 2005
    Posts
    566

    Re: save/load

    Quote Originally Posted by Ebiru
    1 problem.....i want to so other user not just me can save n load without trouple
    What do you mean? If you do damasterjo idea, it wont be any trouble to anyone. You just have a menu option to "save" that when they click it will write all the data you need to save into the text file. When the form loads, just read from this file and assign the values. I do it in the game I am working on now. The game autosaves and when the form loads, it reloads all the data from the file into the proper variables and starts you where you last were.
    Kevin | New England Iced Over | http://www.kevincawleyjr.com

  5. #5
    Addicted Member
    Join Date
    Feb 2006
    Location
    The Sea of Tranquility
    Posts
    252

    Re: save/load

    Depends what language you are using if you are using VB then you can use a user difined type then stick it straight into a binary file. Then realoding is simple. No parsing of text needed.

    Rich

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    226

    Re: save/load

    Quote Originally Posted by Rich2189
    Depends what language you are using if you are using VB then you can use a user difined type then stick it straight into a binary file. Then realoding is simple. No parsing of text needed.

    Rich
    can u explain to me how i can do this?

  7. #7
    Addicted Member
    Join Date
    Feb 2006
    Location
    The Sea of Tranquility
    Posts
    252

    Re: save/load

    VB Code:
    1. Private Type MyType
    2.   setting1 as integer
    3. setting2 as string * 10
    4. setting3 as byte
    5.  
    6. End Type
    7.  
    8. Dim settings As MyType
    9.  
    10. 'save
    11.  
    12. Open "C:\settings.set" For Binary Access Write As #1
    13.   Put #1, , settings
    14. Close #1
    15.  
    16. 'load
    17.  
    18. Open "C:\settings.set" For Binary Access Read As #1
    19.   Get #1, , settings
    20. Close #1
    21.  
    22. 'access a setting
    23.  
    24. settings.setting1 = 1

    Rich

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    226

    Re: save/load

    Quote Originally Posted by Rich2189
    VB Code:
    1. Private Type MyType
    2.   setting1 as integer
    3. setting2 as string * 10
    4. setting3 as byte
    5.  
    6. End Type
    7.  
    8. Dim settings As MyType
    9.  
    10. 'save
    11.  
    12. Open "C:\settings.set" For Binary Access Write As #1
    13.   Put #1, , settings
    14. Close #1
    15.  
    16. 'load
    17.  
    18. Open "C:\settings.set" For Binary Access Read As #1
    19.   Get #1, , settings
    20. Close #1
    21.  
    22. 'access a setting
    23.  
    24. settings.setting1 = 1

    Rich
    1 it doesnt work 2 do i need to change anything n 3 how can i make it so when i click a button?

  9. #9
    Addicted Member
    Join Date
    Feb 2006
    Location
    The Sea of Tranquility
    Posts
    252

    Re: save/load

    Well you have to stick the relavent code in the correct place,

    this in the declarations

    VB Code:
    1. Private Type MyType
    2.   setting1 as integer
    3. setting2 as string * 10
    4. setting3 as byte
    5.  
    6. End Type
    7.  
    8. Dim settings As MyType

    this in the save routine

    VB Code:
    1. Open "C:\settings.set" For Binary Access Write As #1
    2.   Put #1, , settings
    3. Close #1

    this in the load routine

    VB Code:
    1. Open "C:\settings.set" For Binary Access Read As #1
    2.   Get #1, , settings
    3. Close #1

    to get it to work with a button, stick it in a buttons onclick event. So if you want to have a load button, place a button on your form and put the load code into it.

    Rich

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    226

    Re: save/load

    but how do i make it so that when i click load it will load me to the correct forum?

  11. #11
    Addicted Member
    Join Date
    Feb 2006
    Location
    The Sea of Tranquility
    Posts
    252

    Re: save/load

    forum or form?

    Rich

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    226

    Re: save/load

    form....srry for misspelling

  13. #13
    Member
    Join Date
    Mar 2006
    Posts
    33

    Re: save/load

    im no expert but..

    private sub command1_click()

    <code for loading>

    end sub


    I do this in my programs all the time..

    private sub command1_click()

    dim data as string
    dim info as integer
    dim fnum as freefile

    open app.path & "\data.file" for input as #fnum
    input #fnum,data
    input #fnum,info
    close #fnum

    msgbox data + " "+info

    etc etc etc

    end sub

    but of course you will need a command button and some info to read out of a file, you can test it by creating a file named data.file and putting :

    test
    1

    into it

    then run it..

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    226

    Re: save/load

    VB Code:
    1. Private Type MyType
    2.   setting1 as integer
    3. setting2 as string * 10
    4. setting3 as byte
    5.  
    6. End Type
    7.  
    8. Dim settings As MyType
    9.  
    10. 'save
    11.  
    12. Open "C:\settings.set" For Binary Access Write As #1
    13.   Put #1, , settings
    14. Close #1
    15.  
    16. 'load
    17.  
    18. Open "C:\settings.set" For Binary Access Read As #1
    19.   Get #1, , settings
    20. Close #1
    21.  
    22. 'access a setting
    23.  
    24. settings.setting1 = 1
    that code is fine, its just i want it so when the file is loaded it will resume w/e it left off....(w/e mean what ever if u didnt know....)

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    226

    Re: save/load

    srry for double posting but i need help with this....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width