The Daily Click ::. Forums ::. Klik Coding Help ::. Moving Platforms
 

Post Reply  Post Oekaki 
 

Posted By Message

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
15th June, 2004 at 23:37:53 -

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

Tiri



Registered
  16/01/2004
Points
  78
16th June, 2004 at 00:08:47 -

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

Image Edited by the Author.

 
n/a

Teapot

Does he even go here

Registered
  02/10/2003
Points
  2631

VIP Member
16th June, 2004 at 02:43:59 -

WTF? People are overusing fastloop. Moving platforms are easy, you get the amount of pixels it is moving by, and make the character do the same.

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
16th June, 2004 at 04:11:05 -

The Teapot makes many a good points.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
16th June, 2004 at 06:51:21 -

you don't need to use fastloop

 
n/a

RapidFlash

Savior of the Universe

Registered
  14/05/2002
Points
  2712
16th June, 2004 at 12:25:25 -

Moving platforms are easy. All you need to use is one flag of the moving platform object. Example:
PlayerObject overlapping MPlatform + MPlatform Flag 0 is Off --> X("MPlatform") = X("MPlatform") + 2 (and) X("PlayerObject") = X("PlayerObject") + 2

PlayerObject overlapping MPlatform + MPlatform Flag 0 is On --> X("MPlatform") = X("MPlatform") - 2 (and) X("PlayerObject") = X("PlayerObject") - 2
MPlatform collides with background --> Toggle Flag 0

Hope that helps.

 
http://www.klik-me.com

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
16th June, 2004 at 19:56:57 -

*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).

Image 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

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
16th June, 2004 at 20:26:26 -

im not pretending to understand that code but it seems that you dont need so much code for such a thing
the fastloop overcomplicates it i think.

without fastloop and copying the event a few times will work

(honestly fastloop adds 1k to a game and a few extra events does about the same)

try it
http://www.ministryofklik.com/algamesuk/mpthingy.zip

i know its not what you want but i couldnt get fastloop to work properly with this.

 
.

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
18th June, 2004 at 23:15:26 -

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

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
19th June, 2004 at 17:41:24 -

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

File: http://home.att.net/~realnoyb/Platforms-nogroupfastloop.cca

Image 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

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
21st June, 2004 at 20:56:10 -

Help please?

 
"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.

Image Edited by the Author.

 

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
22nd June, 2004 at 16:26:49 -

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

RapidFlash

Savior of the Universe

Registered
  14/05/2002
Points
  2712
22nd June, 2004 at 17:17:53 -

You might need to check the direction of the moving platform in order to get rid of the bug.

 
http://www.klik-me.com

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
22nd June, 2004 at 18:31:12 -

"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.

Image 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
   

Post Reply



 



Advertisement

Worth A Click