I tried to use fastloops to easily make moving platforms that could change directions at active objects... it didn't work out too well. My current fastloop method is stolen from http://www.create-games.com/article.asp?id=1082 after my first try using loop position didn't work. What's wrong with my code? Don't feel like explaining it (basically uses alterable variables to determine how to move each platform each MMF loop), so the file is uploaded at http://home.att.net/~realnoyb/Platforms.cca
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames
well whats wrong with it if you tell me that ill look at it for you also if your doing it by using active objects just make each object a certain direction and the platform a ball object when it hits the object make its direction change to that of the active object no fastloop or alterable values involved in that and much simpler
*Sigh* I shouldn't have been so vague. My problem isn't moving the player with the platform, but differentiating between different platforms in fastloops. I want to use fastloops in order to have fast movement, but without having platforms accidentally overshooting a direction changer.
Group 0 are platforms- Alterable Value A is X speed (+ is right, - is left)
Alterable Value B is Y speed (+ is up, - is down)
Alterable Value C- spread value
Counter contains loop step (see above)
Code:
Always-- set Counter to 0, start loop # 12 for NObject("Group 0") Loops
Loop Trigger 12-- Group 0(spread value 0 in Alterable Value C)
4 Events to determine X/Y movement:
Loop Trigger 12 + Alterable Value C("Group 0") = Counter + Value A > 0 --trigger Loop 8 for Alterable Value A("Group 0") loops.
Loop Trigger 12 + Alterable Value C("Group 0") = Counter + Value A < 0 --trigger Loop 9 for Alterable Value A("Group 0") * -1 loops.
Loop Trigger 12 + Alterable Value C("Group 0") = Counter + Value B > 0 --trigger Loop 10 for Alterable Value B("Group 0") loops.
Loop Trigger 12 + Alterable Value C("Group 0") = Counter + Value B < 0 --trigger Loop 11 for Alterable Value B("Group 0") * -11 loops.
Loop Trigger 12- Add 1 to Counter
4 Movement Events
Loop Trigger 8 + Alterable Value C("Group 0") = Counter -- Group 0(set X pos to X("Group 0") + 1), Redraw Frame
Loop Trigger 9 + Alterable Value C("Group 0") = Counter -- Group 0(set X pos to X("Group 0") - 1), Redraw Frame
Loop Trigger 10 + Alterable Value C("Group 0") = Counter -- Group 0(set Y pos to Y("Group 0") + 1), Redraw Frame
Loop Trigger 11 + Alterable Value C("Group 0") = Counter -- Group 0(set Y pos to Y("Group 0") - 1), Redraw Frame
Change Direction
Loop Trigger 8 + Alterable Value C("Group 0") = Counter + Group 0 is overlapping Group 1 -- Set Alterable Value A("Group 0") to Alterable Value A("Group 1"), Set Alterable Value B("Group 0") to Alterable Value B("Group 1")
Loop Trigger 9 + Alterable Value C("Group 0") = Counter + Group 0 is overlapping Group 1 -- Set Alterable Value A("Group 0") to Alterable Value A("Group 1"), Set Alterable Value B("Group 0") to Alterable Value B("Group 1")
Loop Trigger 10 + Alterable Value C("Group 0") = Counter + Group 0 is overlapping Group 1 -- Set Alterable Value A("Group 0") to Alterable Value A("Group 1"), Set Alterable Value B("Group 0") to Alterable Value B("Group 1")
Loop Trigger 11 + Alterable Value C("Group 0") = Counter + Group 0 is overlapping Group 1 -- Set Alterable Value A("Group 0") to Alterable Value A("Group 1"), Set Alterable Value B("Group 0") to Alterable Value B("Group 1")
*phew* My problem is that when any Group 0 platform collides with a Group 1 direction changer, they all change direction (see .cca above).
Edited by the Author.
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames
The plot thickens... not really. Trying to debug, I replaced all instances of Group.0 with "Moving Platform" just in case the problem was with MMF's handling of groups... it wasn't. I'm now convinced that the problem lies in the code that's supposed to tell MMF to differentiate between the different instances of the platform active object (loopstep/Counter = Alterable Value C[spread value 0]), but I don't see anything that should be wrong in the code. I don't want to give up the freedom of being able to directly control platforms with pixel-perfect collision detection at high speeds!
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames
Okay, took out fastloop per your suggestions, but I still have problems. It seems when two different platforms overlap direction changers (group 1) at the same time, then both platforms change to the same direction.
New Code:
Start of Frame-- Bring platform to front, bring group 1 to back.
Always-- set X to X + Alterable Value A, set Y to Y - Alterable Value B
Platform is overlapping Group 1-- set Platform's Value A to Group 1's Value A, set Platform's Value B to Group 1's Value B
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames
Deleted User
21st June, 2004 at 21:14:19 -
go read my article. You dont even need fast loop.
Its easy. Make a box with an arrow pointing in whatever direction. When the platfrom touches it, it goes in that direction. No flags, no fast loop. Simple code.
Did you read the whole topic, MarvelHero? In my second attempt (see where it says New Code), I appear to move the platforms similar to your article, but putting the direction changers in a group instead of having individual events, in order to save code. However, mine bugs out when two platforms overlap two direction changers at the same time (both platforms go the same direction). Why does it do that and how can I fix it?
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames
"Bah!" at MMF's treatment of groups! Putting a separate event for each direction changer fixes it, but bloats my code. Abandoning Fastloop forces me to use slow platforms so the Fastlooped character movement/detection doesn't have collision problems. Oh well, I guess this is the best I can do for now. Thanks for your help, everyone! A demo/alpha of "Rocket Skater" is on the way.
Edited by the Author.
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames