The Daily Click ::. Forums ::. Klik Coding Help ::. Objects flying around center object
 

Post Reply  Post Oekaki 
 

Posted By Message

Blue66



Registered
  24/05/2008
Points
  1186

GOTW JUNE 2010 WINNER!Hero of TimeVIP Member
18th November, 2008 at 20:44:01 -

I admit, I really suck at math. But maybe some1 can help me with this:

The player can create a shield consisting of a maximum of 4 objects that spin around him. Each object has a fixed distance between eachother.

But if you only have 3 or less objects flying around you, every one has also the same distance between eachother. It should calculate different distances so for example if you only have 2 objects they are at front and back side. And they always rotate around the player wherever he goes...

Kinda like this:
Image

I can imagine this is only a very simple math thing for most of you, but my brain evacuates itself if I only try to begin doing math
I'm happy if I get MMF2 to do what I want without the use of extensive coding... excessive coding means for me trial and error until everything runs like I want

Anyway would be gr8 if you can help me a little with this
Thx!

Image Edited by the Author.

 
www.paulinthenet.de
www.gungirl2.com

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
18th November, 2008 at 21:09:29 -

Put these expressions in the rotating object's events

X( "player" )+8+(Alterable Value A( "rotatingobject" )*Sin(Alterable Value C( "player" )))

X( "player" )+8+(Alterable Value A( "rotatingobject" )*Sin(Alterable Value C( "player" )))

Then always add 1 to rotating object's alterable value 1. I guess you can change the starting A value to change it's starting position.

 
.

Blue66



Registered
  24/05/2008
Points
  1186

GOTW JUNE 2010 WINNER!Hero of TimeVIP Member
19th November, 2008 at 07:34:19 -

It's not working. The dot stands still and slowly moves away from the player. They have to spin around him like the Wood-Man shield of Megaman 2

Maybe tell me what alterable value C of the player should mean? And why both time X? I suppose you mean Y offset?

Image Edited by the Author.

 
www.paulinthenet.de
www.gungirl2.com

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
19th November, 2008 at 15:57:31 -

If you want a non-math and inefficient way (and how I'd do it most likely) just make an active object called "shields" or whatever that has different animations for 0 shields, 1 shield, 2 shields, 3 shields, and 4 shields. Draw them, space them apart how you like, and manually move each orb around a little at a time for the next frame, until you have a complete circle and loop the animation.

Then you can test collision against this orb shield object to deflect enemy bullets. Just set an alt value on the player somewhere called NumShields and use that to control which animation of the orb shield object is always playing. You can even give the shield object HP so if it takes enough damage it'll downgrade and subtract an orb or just fizzle out altogether when they're all gone.

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
19th November, 2008 at 16:23:39 -

Oops, i meant to say always subtract 1 from rotating object's Value C

 
.

Blue66



Registered
  24/05/2008
Points
  1186

GOTW JUNE 2010 WINNER!Hero of TimeVIP Member
19th November, 2008 at 20:15:12 -

Thanks Del Duio, and that's kind of the way I would do it on my own, but this "shield" is something I don't want to look sloppy in the end.

Please AndyUK, I appreciate your help, but I try figuring out what you are trying to say and everything I try looks nothing like I need it

Could you please explain it so an idiot like me understands it?

Image Edited by the Author.

 
www.paulinthenet.de
www.gungirl2.com

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
19th November, 2008 at 20:44:34 -

andyuk put it in the wrong order by accident


do this:

X(Shield) = X(Enemy) + 30 * Cos(Value A(Shield))
Y(Shield) = Y(Enemy) - 30 * Sin(Value A(Shield))

When you create your shields, do a "Spread 90" in their Value A. This will set their Value A's to 90,180,270 & 360.
Then just create an "Always: Add 1 to Value A", and watch them spin. The number "30" represents the pixel distance that they will always keep, and value A is the angle of each one from the enemy

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Fifth

Quadruped

Registered
  07/05/2003
Points
  5818

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
19th November, 2008 at 20:48:22 -

Something like this should work. I'm calling the objects "Player" and "Orbital" here. And the angle of rotation is based off of one of the Player's alterable values in order to keep everything consistently spaced:

Always
Set Alterable Value A( "Player" ) to (Alterable Value A( "Player" )+5) mod 360

Spread 0 In Alterable Value A( "Orbital" )

Set X( "Orbital" ) to X( "Player" )+32*Sin(Alterable Value A( "Player" )+Alterable Value A( "Orbital" )*(360/NObjects( "Orbital" )))

Set Y( "Orbital" ) to Y( "Player" )+32*Cos(Alterable Value A( "Player" )+Alterable Value A( "Orbital" )*(360/NObjects( "Orbital" )))


The 5 refers to the rotation speed, the 32 refers to the radius. If you want it spinning the other direction, just change the X to -32 instead of +32.

 
Go Moon!

Blue66



Registered
  24/05/2008
Points
  1186

GOTW JUNE 2010 WINNER!Hero of TimeVIP Member
19th November, 2008 at 22:28:32 -

Wow, thanks Pixelthief and Fifth! Both methods work perfectly and Fifths version got exactly what I was trying to do!

You are teh awesomeness! Thanks guys!!

 
www.paulinthenet.de
www.gungirl2.com

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
20th November, 2008 at 01:41:47 -

Oh yeah I forgot that spread 90 doesn't work, Fifth's is right. To initialize as something like 0,90,180,270, you need to do:
Spread 0 in value A
Set value A to Value A * 90

spread 90 would just make them 90,91,92,93

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456
   

Post Reply



 



Advertisement

Worth A Click