The Daily Click ::. Forums ::. Klik Coding Help ::. Circling enemies
 

Post Reply  Post Oekaki 
 

Posted By Message

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
7th September, 2011 at 19:08:26 -

Hey, remember these assholes?

Image

I'm adding them to my game but I'm not sure how to differentiate between "sets". The basic stuff is no problem, I would do something like ("angle" = spread value * interval between objects in degrees). But if I wanted a bunch of different wheels - THESE guys are spaced around THIS point, THESE guys are spaced in the same way around THIS point, etc. - I'm not sure what I should do. And I'm feeling uncommonly lazy. Any help?

 
n/a

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
7th September, 2011 at 23:42:32 -

Assuming you already know how to make the objects move in a circular pattern - do a distance calculation.

I haven't tested it, but I'm pretty sure it will work . . .

We'll call the objects Center and Floater

+Always
- Spread 1 into Value A of Center

+Always
- Set Value B of Floater to Distance from Floater to Center

+Value B of Floater < 200
- Set Value A of Floater to Value A of Center

Then position the Floaters accordingly.

You'll have to tweak it a bit, and be careful not to put two centers too close together. . . this should give you an option though.





Edited by GamesterXIII

 
n/a

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
8th September, 2011 at 01:18:22 -

Thanks for the reply but I don't really understand what you're saying - is that an elaborate way of giving the objects a value in common? (I feel dumb.)

I think my problem is mostly spacing the objects - as far as I know MMF deals with the parent/child issue pretty well automatically, e.g., if you do this...

Start of frame
- Create Floater at 0,0 from Center

Always
- (rotate Floater around Center)

... then each Center will have one Floater rotating around it. And if you create 18 Floaters at each Center, each Center will have 18 Floaters rotating around it (Someone tell me if I'm wrong here, I'm not 100%).

Now, if I had just one Center, I would be able to spread 0 in one of the Floaters' values, then modify each Floater's angle by that value * the desired interval in degrees. Once you add a second Center, MMF seems to want to distribute the values 0, 2, 4, 6 to the Floaters around one Center, 1, 3, 5, 7 to the Floaters around the second Center.

Obviously my approach to object selection is incredibly primitive in the example above, but after dicking around for a few hours now, it's still the best starting point I have.

Hope the above makes more sense than my original post. Cheers

 
n/a

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
8th September, 2011 at 01:34:33 -

Example - this version works, ish, if your preferred interval-between-objects is divisible by the number of ring-centers, and you don't mind a slight offset in each ring: http://www.theredswanhotel.com/misc/test.mfa

I hope I can come up with something more robust, if anyone has any suggestions I'd love to hear 'em

 
n/a

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
8th September, 2011 at 04:08:16 -

Oh wow I just made one from scratch and had it working 100% . . . I saved it and uploaded it and couldn't find it. Seems as if it never got saved, but MMF let me close it without the save box popping up . . . I'll remake it and post it up soon. Stand by.

 
n/a

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
8th September, 2011 at 04:10:21 -

^Nevermind that, I found it . . . LOL.

Here you go.
I'm surprised I got this working.

Clicking on the rotators will destroy them.

http://www.megaupload.com/?d=9G2FTVF5

edit:
Fixed a small problem, but for some reason if you have more than 11 objects per center it leaves a gap >_<. I have no idea what is causing it.

edit:
Fixed the gap! Now it supports a seemingly infinite number of rotators per center.

Changed the 360 to 360.0 in

Angle Modifier( "Rotator" )*(360.0/NObjects( "Rotator" ))

enjoy!


Edited by GamesterXIII

 
n/a

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
8th September, 2011 at 14:01:46 -

Awesome, thanks so much! I'll have a proper look at your example when I'm free this evening, but it looks solid

 
n/a

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
12th September, 2011 at 14:48:58 -

Finally back working on this - hah!

That really helped, my new version so far looks like this:

Start of frame
- [create the required amount of Rotators at each Center]
- Spread value 0 in ID("Center")
- Spread value 0 in ID("Rotator")
- Set value Group("Rotator") to ID("Rotator") mod NObjects("Center") [shortcut for the first loop in your example!]

Always
- Start loop "circles" NObjects("center") times

On loop "circles" AND ID("Center") = Loopindex("circles") AND Group("Rotator") = Loopindex("circles")
- Spread value 0 in ID("Rotator")
- [insert trig here, modify angle with ID("Rotator")*(desired interval between objects)]

I've ditched the auto-spacing from your example (sorry) because I don't really gain anything from being able to vary the number of rotating objects - it just needs to be a solid wall with a gap where the player can safely enter and exit.

The one thing that bothers me now is that I don't want to loop through every single Center in the level, just the ones on screen (i.e., screen edge + diameter). This seems like a much dumber problem but I can't figure it out, I'm not sure how object focus carries across to Pick or Count-type events - any ideas anyone? Cheers

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
12th September, 2011 at 18:09:02 -

Use "distance from edge of the frame" or something like that to select the ones on or close to the screen (use a negative number)

Set their Alterable value to 1 or something then spread value on those:
Remeber to reset all of them every loop though

So:

Always
-Set Alterable Value A of "circles" to 0

If object "circles" is closer than -50 to windows edge
-Set Alterable Values A of "circles" to 1

If Alterable Value A of "circles" equals 1
-Spread values 1 in Alterable Value A of "circles"



Then run your loops or whatever. Also your object names may vary.

Hope this helps.

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
12th September, 2011 at 19:50:12 -

Spreading values and repeatedly running fastloops is bad practice. Either use the ForEach extension, or just run the fastloop once at the start of the frame:

https://skydrive.live.com/self.aspx/Public/RotateAround.mfa?cid=b1e7ee094271bbda&sc=documents

 
n/a

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
12th September, 2011 at 20:53:20 -


Originally Posted by Sketchy
Spreading values and repeatedly running fastloops is bad practice. Either use the ForEach extension, or just run the fastloop once at the start of the frame:

https://skydrive.live.com/self.aspx/Public/RotateAround.mfa?cid=b1e7ee094271bbda&sc=documents

Yeah I typically keep my loop usage to a minimum and don't like to run loops over and over, but I'm also not an avid extension user due to stability issues. I tried not looping it over and over, but when objects would get destroyed they would reassign themselves to a different center object for some reason =/.

Thanks for fixing it up.

Edited by GamesterXIII

 
n/a

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
12th September, 2011 at 21:27:42 -

Awesome method Sketchy! Cheers!

 
n/a
   

Post Reply



 



Advertisement

Worth A Click