User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14

Thread: saving multiple frames- example or detailed explanation using associative array

  1. #1
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Wodjanoi's Avatar
    Join Date
    Jun 2015
    Location
    Germany
    Posts
    665
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    saving multiple frames- example or detailed explanation using associative array

    I've stopped working on my platformer game for weeks(except drawing my graphics), because I can't find a way to save the game with multiple frames. I found a helpful example by nivram using the associative array object, but I don't understand how to save the player position and the collected coin at other frames.
    For my platformer I must save at least the player character position and deleted items(for items which give the player character special movement abilities). If there is a simple way, I would also like to know how to save the direction of the player character and position + direction of creatures and enemies (for multiple frames!).

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    You need to save those informations "per frame"?
    Meaning that you need collected coins on frame 1, collected coins on frame 2 etc.?

    Something pre-cooked should exist,
    however, this is quite easy once you grasp its basics.

    You just have to plan down what and how you want to save.
    And then store those informations in the format that will be handier for you.

    I.e. you could save informations per frame / type:

    frame1_coins: 30
    frame2_coins: 50
    frame1_X_position: 300
    frame2_X_position: 200

    for saving those you would just set the key in the expression editor as:
    "frame" + Str$(frame) + "_coins"


    This will be dynamic and no need to recode anything in different frame,
    same for loading.

  3. #3
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Wodjanoi's Avatar
    Join Date
    Jun 2015
    Location
    Germany
    Posts
    665
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    What's about moving creature AI? How can I save their current movement behaviour?
    Your explanation belongs to associative array?

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Yes, I wrote a general explanation on how to interact with your associative array,
    you can use it with whatever you want,
    if you need to save your monster's direction/animation etc.,
    just add relative lines to the array.

    The hardest part, depending on how your game is setup (different instances of same enemies or different enemies pre-set in frame?)
    will be recreating the monsters you need (some could've been destroyed)
    and give to the correct monster its saved position.

    But this highly depends on how your game is structured, so we should need much more informations for a detailed how-to

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Wodjanoi's Avatar
    Join Date
    Jun 2015
    Location
    Germany
    Posts
    665
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    It's not an action platformer with a whole bunch of enemies.
    Same creatures are few and far between and each unique creature has it's own group.
    I will prepare a mfa file with a similar environment with all important things included I need to save.
    I will upload it here. Maybe I can ask you to help me out with a more detailed explanation on how to use the associative array for my purpose properly then?

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Sure, if available I'll take a look.
    If I won't be hanging around, someone else will probably help too

  7. #7
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Wodjanoi's Avatar
    Join Date
    Jun 2015
    Location
    Germany
    Posts
    665
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    So here is the example mfa file.
    I want to save the following things: (Saving - If a certain key is pressed at
    a savepoint spot and Loading Always with another key)

    - on which frame the saving process occur
    - position and direction of player character and monsters
    - removed special ability items

    I'm hoping this isn't too much to ask.

    example1.mfa

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Here's a simple example.
    I did only for frame 2 (don't ask me why, I guess by chance..)
    you will find everything under associative array group in the event editor
    but I've placed it to position 1 in the storyboard, in order to test it quickly
    (since we jump to frame you must run application and not just frame to properly test)

    You can try making this on yourself for the other frame, copying events and doing same setup.
    Also, I didn't see collectible objects, so I made it only for frame, player and enemy(ies).

    Save with "S" and load with "L".

    ass_array_save.mfa

    Please read following notes and instructions :

    1. save file will be determined by global string "save_file", so you can setup multiple save files and a "save state selection" if you need
    2. save file will be placed in the same path as the application, in above filaname.sav file
    3. you MUST setup all enemies you want to track in this way:
    a) add them to the "enemies" qualifier
    b) write a unique name (you said they were all unique - no multiple instances right?) for each one of them in their "alt. string A"

    NOTE:
    loading in the example is done from the frame itself, but it makes little sense, since you want to save also the frame number.
    You should setup an external "loading" frame, then set global string "array_action" to "load" and go to frame number (get value from array), and at start of frame perform the load action on the array.
    Alos, in this way, you have not to take care of recreating the enemies if they were destroyed after saving,
    because the frame will be always restarted (the would only be destroyed if they didn't exist on save)

    Hope everything is clear!


    EDIT: forgot to say, if you prefer, you can also apply encryption in your save file, in order to make your save data hard to modify by players

  9. #9
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Wodjanoi's Avatar
    Join Date
    Jun 2015
    Location
    Germany
    Posts
    665
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much for this detailed explanation schrodinger.
    And your example of course.
    Here are some problems I discovered:
    - Only right direction of the character loads correctly
    - I used your code for my first frame, so for testing I started with the first frame and pressed S key on the second frame with the big enemy.
    If I press L key the first frame loads with the position of the character from the second frame, if I press L key again I'm on the right frame.
    - For my first frame it saves the double jump item, but the monster shrink item on the other frame - it's back after loading the second frame and therefore the ability is no longer active.

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Hi,

    you're right, when going multiframe there are some additional things to check!

    Here's the bugfix for multiframe:
    ass_array_save_multiframe.mfa
    (I've made both frames now)

    as for player direction: I tought that was inherited from the collider,
    you can just change the line when the direction is stored in the associative array to make it get the correct value,
    and then on loading assign to player instead of collider (or set left=1 or whatever you want to make player looking the correct direction)

    for the items: that's your homework
    try to do for collectible objects the same we did for enemies,
    if any problem let me know!

    Also, take into account that setting up a complete saving system is not so trivial,
    and requires an adequate planning.
    A few other things you should consider:

    - prevent loading when no file exists (the global string "save file" could be really handy for this)
    otherwise on loading you'll probably encounter unwanted happenings, like player-monsters disappearing

    - if your player can come back to previous frames from following,
    you should change a couple of things
    i.e. saving data for each frame even if player didn't save (maybe on frame change)
    but do so on a "temporary" file, since player could also chose not to save his progress and you don't want to overwrite his previous savestate

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Saving and loading multiple frames
    By EndarDude in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 7th May 2019, 08:16 PM
  2. Associative array object crashes when saving
    By AWK in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 15th August 2013, 04:14 PM
  3. associative array
    By iammfa in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 5th April 2009, 03:00 PM
  4. Associative Array
    By scottige in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 11th June 2007, 08:50 PM
  5. Associative Array 1.21
    By Jeff in forum Released Extensions
    Replies: 0
    Last Post: 22nd September 2006, 12:08 AM

Posting Permissions

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