User Tag List

Results 1 to 5 of 5

Thread: ForEach + Fastloop Gravity Help

  1. #1
    Clicker Fusion 2.5Android Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    MasochisticGamer's Avatar
    Join Date
    Nov 2012
    Location
    Gravois Mills. MO USA
    Posts
    73
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    ForEach + Fastloop Gravity Help

    So, I have one object to govern items, but I'm having trouble getting their individual gravity. I got this working once before back in the MMF2 days using the ForEach object, but it's not working the same as the one built into CTF2.5 The gravity functions for the most part, but tends to jitter when multiple item objects are spawned.

    Code:
    * Grav("Items") < 7
        - Add 0.325 to Grav("Items")
    
    * Number of ("Items") > 0
        - Start loop for each one of ("Items"), loop name "ItemGravEach"
    
    * On each of ("Items"), loop name "ItemGravEach"
        - Set LoopIndex("Items") to ForEachLoopIndex("Items")
    
    * On each of ("Items"), loop name "ItemGravEach"
        - Start loop "ItemGrav" Abs(Grav("Items")) times
    
    * On loop "ItemGrav"
    * Grav("Items") < 0
    * Pick object which Alterable Value G = ForEachLoopIndex("Items")
        - Set position ("Items") to Y ("Items") - 1
    
    * On loop "ItemGrav"
    * Grav("Items") > 0
    * Pick object which Alterable Value G = ForEachLoopIndex("Items")
        - Set position ("Items") to Y ("Items") + 1
    Any help would be greatly appreciated.

  2. #2
    Clicker Fusion 2.5Android Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    MasochisticGamer's Avatar
    Join Date
    Nov 2012
    Location
    Gravois Mills. MO USA
    Posts
    73
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Alright, so. Did some tinkering and found a tutorial by AlmightyZenTaco that helped IMMENSELY. Here's the fixed code.

    Code:
    * Number of ("Items") > 0
        - Start loop for each of ("Items"), loop name "ItemGrav"
    
    * On each one of ("Items"), loop name "ItemGrav"
        - Set Y Position ("Items") to Y ("Items") = Grav("Items")
    
    * Grav("Items") < 7
        - Add 0.325 to Grav("Items")
    
    * On each one of ("Items"), loop name "ItemGrav"
    * ("Items") is overlapping a backdrop
        - Start loop "ItemCollide" 16 times
    
    * On loop "ItemCollide"
    * ("Items") is overlapping a backdrop
        - Set Y Position ("Items") to Y( "Items" ) - ( Grav( "Items" ) / Abs(Grav( "Items" )) )

  3. #3
    Clicker Fusion 2.5Android Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    MasochisticGamer's Avatar
    Join Date
    Nov 2012
    Location
    Gravois Mills. MO USA
    Posts
    73
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I've uploaded an example file for anyone that would like to use these functions for their game. The example shows how to setup stage items with a spread value at the state of a frame (Can be left as is or governed by a Global String/INI/Array to determine which one has been picked up) and Dropped Item functions which will fade away after a set time. All of the item sprites are a single shared object using IDs to determine which item is being displayed. All items are affected by gravity as well, using an embedded collision detector (Since the example is based off Mega Man items, this allows for the one pixel into the ground effect those games share). Optimization of the events is more than possible with this, as I just used simple events to get it working.

    itemtest.mfa

  4. #4
    Clicker Fusion 2.5 DeveloperSWF Export Module
    N64Mario's Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,276
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Huh....... Interesting example.

  5. #5
    Clicker Fusion 2.5Android Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    MasochisticGamer's Avatar
    Join Date
    Nov 2012
    Location
    Gravois Mills. MO USA
    Posts
    73
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks, @N64Mario

    Update: I tweaked the gravity due to an issue involving powerups getting lodged in ceilings.

    itemtester-ceilingfix.mfa

Similar Threads

  1. Replies: 5
    Last Post: 1st August 2015, 06:19 PM
  2. Platformer AI Fastloop within a ForEach loop
    By kirkmet in forum Fusion 2.5
    Replies: 1
    Last Post: 6th January 2015, 04:24 AM
  3. Game loop: ForEach or FastLoop?
    By King_Cool in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 20th December 2011, 12:49 PM
  4. Foreach Object in collection (using fastloop)
    By AndyH in forum File Archive
    Replies: 1
    Last Post: 28th June 2009, 12:38 PM

Posting Permissions

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