User Tag List

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

Thread: Pixel By Pixel Custom Platform Movement, a Bad Idea?

  1. #1
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Pixel By Pixel Custom Platform Movement, a Bad Idea?

    Was going to attempt to make a custom platform movement for another game concept I was thinking of, but without using extensions since in my experience, they tend to crash.

    I came up with something that moved the player one pixel at a time, though via Fastloops, so that if it collided with a wall, it'd be pressed up against it instead of being several pixels off. (As in, if it's moving at a speed of 5 pixels per frame, and it collides with a wall, the Fastloop will have it stop against the wall instead of 4 pixels away).

    Now I'm also wanting to do that for enemies eventually, but I got to thinking. Would that kill performance if I put a bunch of enemies' movements in a bunch of Fastloops while also within For Each loops as well? Or is there an easier, extension-less example out there that'd have that kind of pixel precision?

  2. #2
    Clicker

    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)

    Join Date
    May 2015
    Posts
    135
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    This is entirely possible and as long as coded properly would have no great impact on performance. I use custom fastloop (with ForEach) movements for all of my game elements from playable characters and enemies to projectiles. There are a lot of examples in these forums and around the net. Search for "pixel perfect collision detection" here or on google to get started, but it sounds like you're on the right track. The biggest trick is limiting how often loops run and there are a variety of solutions for that around here.

  3. #3
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So I went with your advice. We'll see how things perform later on when there's lots more objects to deal with. I managed to make a player and enemy movement nearly identically (and pretty quickly too considering my experience these days!), and it's pretty much loops within loops to have it work. Thank you.

    I'll need to look around a bit more though, for a way to add in platform code that you can pass through from below, and things like moving elevators/platforms and slopes to act right.

  4. #4
    Clicker Fusion 2.5Fusion 2.5+ DLC

    Join Date
    Mar 2014
    Posts
    156
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Perhaps you might like this tutorial: https://www.youtube.com/watch?v=uQ7e...&index=27&t=0s

  5. #5
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A bit late, as I've been busy lately, but I finally got around to watching that tutorial and implementing it. It works great, thank you! Now at the moment, it's not working for multiple enemies simultaneously, but I'll figure that out later. Or I'll make them not able to pass across sloped surfaces, maybe.

    Now I'm looking for moving platforms and elevators and the like. If you know where I could find examples of those, I'd greatly appreciate it. :3

    EDIT: To clarify, I got it working fine for a player, but I think it's because there's only one instance of the player for the fast loops to worry about.

  6. #6
    Clicker Fusion 2.5Fusion 2.5+ DLC

    Join Date
    Mar 2014
    Posts
    156
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Yeah, using this method (FastLoop movement) for multiple enemies is a little tricky. You gotta go with For Each Loops. Hopefully someone here can explain it better because I'm a bit confused about how it's done myself.

  7. #7
    Clicker

    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)

    Join Date
    May 2015
    Posts
    135
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Edel View Post
    Yeah, using this method (FastLoop movement) for multiple enemies is a little tricky. You gotta go with For Each Loops. Hopefully someone here can explain it better because I'm a bit confused about how it's done myself.
    If you want the precision and speed of fast loops for multiple objects you can use a ForEach loop to trigger a scoped fast loop. Scoping is how you tell Fusion which object to affect when there is more than one copy. What you do is start a ForEach loop called something like "EnemyMovement" for your Enemy object (you can always run this ForEach, but if you don't need to it's best to figure out how often you do and avoid an "always" event).

    On that ForEach loop you need to do two things:

    1. You need to either use a global value or create an active object to hold an alterable value. This value will be called something like "ScopedEnemyID." On the ForEach loop you will FIRST set this value to the fixed value of your Enemy object. Fixed values are unique to every object created in the game, so this number will tell Fusion the unique identifier of whatever object you are scoping without you having to create one yourself.

    2. In the same event (but AFTER you set the ScopedEnemyID value to the Fixed value) you then start a fast loop called something like "EnemyFastLoopMove."

    Now you can trigger all of your movement code individually on each object, instantly, by simply using your code but with "On Loop "EnemyFastLoopMove" , AND "ScopedEnemyID = Enemy Object Fixed."

    What is happening is that the ForEach loop, one by one, picks one of your enemy objects, sets it's fixed value to the currently scoped value, and then runs a fast loop for just that object. It does this over and over for every one of those objects. Fast Loops can not, on their own, be scoped to specific objects. So without the ForEach loop, the fast loop will run every event that mentions the Enemy object for every Enemy object and you'll get some very weird results. I hope that helps.

  8. #8
    Clicker Fusion 2.5Fusion 2.5+ DLC

    Join Date
    Mar 2014
    Posts
    156
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by CuddlyGoose View Post
    If you want the precision and speed of fast loops for multiple objects you can use a ForEach loop to trigger a scoped fast loop. Scoping is how you tell Fusion which object to affect when there is more than one copy. What you do is start a ForEach loop called something like "EnemyMovement" for your Enemy object (you can always run this ForEach, but if you don't need to it's best to figure out how often you do and avoid an "always" event).

    On that ForEach loop you need to do two things:

    1. You need to either use a global value or create an active object to hold an alterable value. This value will be called something like "ScopedEnemyID." On the ForEach loop you will FIRST set this value to the fixed value of your Enemy object. Fixed values are unique to every object created in the game, so this number will tell Fusion the unique identifier of whatever object you are scoping without you having to create one yourself.

    2. In the same event (but AFTER you set the ScopedEnemyID value to the Fixed value) you then start a fast loop called something like "EnemyFastLoopMove."

    Now you can trigger all of your movement code individually on each object, instantly, by simply using your code but with "On Loop "EnemyFastLoopMove" , AND "ScopedEnemyID = Enemy Object Fixed."

    What is happening is that the ForEach loop, one by one, picks one of your enemy objects, sets it's fixed value to the currently scoped value, and then runs a fast loop for just that object. It does this over and over for every one of those objects. Fast Loops can not, on their own, be scoped to specific objects. So without the ForEach loop, the fast loop will run every event that mentions the Enemy object for every Enemy object and you'll get some very weird results. I hope that helps.
    Thank you for explaining this for me. It makes sense but I can't get it correctly. Could you be kind enough to fix this for me: Custom Movement with slopes (testing with FixedValues).mfa So that I can see how it's done. You create an enemy by left clicking but it's not scoping properly when the enemy touches the player all the enemies move at the same time.

  9. #9
    Clicker Fusion 2.5Fusion 2.5+ DLC

    Join Date
    Mar 2014
    Posts
    156
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    I think I figured it out:Custom Movement with slopes (testing with FixedValues).mfa Doing this for a lot of enemies / objects does take a performance hit!!Once you create about 250+ for me.

  10. #10
    Clicker

    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)

    Join Date
    May 2015
    Posts
    135
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    I cleaned some things up for you. This should be a bit more efficient. I don't have enough time to work on my own projects let alone others, so I won't be able to do much more, but I hope this helps. Custom Movement Updated.mfa

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Replies: 5
    Last Post: 14th July 2017, 09:18 PM
  2. How would you move an object in straight line pixel by pixel from location to another
    By Tsun in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 22nd December 2012, 11:38 PM
  3. [Request/idea]Pixel palette changer
    By VictorT in forum Extension Development
    Replies: 4
    Last Post: 5th September 2007, 09:46 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
  •