The Daily Click ::. Forums ::. Klik Coding Help ::. Rotating, dragging, and curved movement...
 

Post Reply  Post Oekaki 
 

Posted By Message

Tristan Clark



Registered
  28/07/2003
Points
  159
30th October, 2005 at 02:02:19 -

Hi guys,

I've got a game idea in mind, but there are (at least) three major things that I don't know how to do. I'll try and explain the concept as best as I can:

Imagine a big circle in the center of the screen. Around this circle is a ring made up of 8 smaller circles. Around this ring of circles is another ring made up of 16 circles, and so on. I want to be able to hold the mouse button down on any one ring of circles, and drag it around so the circles rotate around the center.

1. I guess the first problem is having an actual 'ring' that the circles can sit on top of. How can I get it so it is rotated around by the user dragging it with the mouse?

2. Then there's the problem of having the circles on top of the ring, and having them move around smoothly with the ring as it is rotated.

I've thought of using diff. directions with the ring, and making it look at the mouse whenever it is clicked on. But while this sort of works, it automatically just changes its direction to look at the mouse, and not just change its direction when the mouse is dragged around.

I hope that makes sense. Any help would be greatly appreciated! Do ask more questions if I've been unclear on anything.

Cheers.

 
n/a

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
30th October, 2005 at 02:21:02 -

Use some trig to locate the circles at a certain distance and angle from the center.

Use the Mouse object to calculate the distance rolled while the mouse is held after clicking on a ring. You can also use the Mouse object to reposition the mouse, so you can make it 'lock on' at an angle relative to the center that should rotate at the same rate as the ring currently being moved.

Easy.

 
n/a

Tristan Clark



Registered
  28/07/2003
Points
  159
30th October, 2005 at 03:13:58 -

Easy? Maybe I'm just not too smart. I'm certainly pretty dumb when it comes to most forms of maths, including trigonometry.

Here's what I've got so far: http://www.rowanclark.com/sphere1.cca
It really isn't much, but if you have the time, would you be able to make some quick examples in there to show what you're talking about? That'd be really awesome.

Cheers.

 
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
30th October, 2005 at 04:40:57 -

Always set ball1.x to 60, always set ball1.y to 60

Start of frame spread 0 in alt a of ball2.
Always set ball2.x to cos(Alt A * 15) * 40 + ball1.x
Always set ball2.y to sin(Alt A * 15) * 40 + ball1.y

Image Edited by the Author.

 
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

Tristan Clark



Registered
  28/07/2003
Points
  159
30th October, 2005 at 05:24:38 -

Thanks Andy. Which balls should I be applying this too? I've tried applying it to the ring you rotate, and the ball just sits there. Applying it to two smaller balls, one of which is fastened on to the Action Spot of the ring, just makes it stick near the rotating small ball. I don't suppose you'd be able to break those equations down so I know which part does what? That'd be great.


 
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
30th October, 2005 at 05:47:32 -

Sorry I was in a rush when I wrote it.
Always set ball2.x to cos(Alt A * 15) * 40 + ball1.x

Ball1 is the center ball. Ball2 is the first ring of balls, you will need a few of them.

The stuff in the brackets of the cos is the angle [ cos () ]The Alt A is the ball's ID, and the 15 is the 'distance' between the balls. For example this will make the balls angles:
15,30,45,60,75,90 etc.
The 40 is the distance away from the ball1, the center ball's x is then added to that. To rotate them you would need to add an offset to the cossine's angle. Something like this:

Press left, add 10 to counter (called angle)
Always set ball2.x to cos(Alt A * 15 + angle) * 40 + ball1.x
Always set ball2.y to sin(Alt A * 15 + angle) * 40 + ball1.y

 
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

Tristan Clark



Registered
  28/07/2003
Points
  159
30th October, 2005 at 16:13:12 -

Hey, now I'm getting somewhere! Thanks heaps for that Andy, that code worked wonders!

I guess the only other problem I have now is with the mouse. I tried using the mouse object as you suggested Radix, but the only useful command I could find is 'Get Distance Rolled', which is fine if you want the balls to rotate one way, but it has no way of detecting which direction the mouse rolls in. Is there a way to make it detect this?

 
n/a

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
30th October, 2005 at 21:55:51 -

Uh, yes? Try sampling the current position of the mouse and comparing it with the position a short period later before repositioning the mouse on the ring, and using distance rolled as a way to determine the speed of rotation.

 
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
30th October, 2005 at 22:45:22 -

Here's an example of what I've told you so far and the rotating in the direction of the mouse aswell. Needs Angle Calculator.

http://www.subsoap.com/ac/ballrotate.cca

Angle Calc:
http://www.clickteam.info/extensions/extview.php?id=223

 
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

Tristan Clark



Registered
  28/07/2003
Points
  159
31st October, 2005 at 03:45:37 -

Cool, thanks for that Andy. One thing with that though - at the moment, no matter where you click on the circle of diamonds, one particular one will always teleport to be under the mouse. Is there a way to factor in a calculation that means they don't ever move about except by being dragged?
Thanks for all this help!

 
n/a

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
31st October, 2005 at 04:08:47 -

When the user clicks on a ring create a special (and invisible) ball on that ring, located using the calculation for balls on that ring, and at the angle of the mouse relative to the center.
While the button is held, make the mouse cursor invisible and reposition it periodically, and at the moment the user lets the mouse button go, over this special ball. Do not reposition it constantly, just close to it. Use the cursor position relative to this point at any given time and the 'distance moved' function of the mouse object to have the ring rotate only when dragged. This will also have the effect of keeping the mouse at the same relative position when the ring moves.

All of this was already implied, by the way.

 
n/a

Tristan Clark



Registered
  28/07/2003
Points
  159
31st October, 2005 at 04:11:57 -

Just to make it a bit clearer, I've made the diamonds have diff. colours so you can tell when they jump about:

http://www.rowanclark.com/ballrotate.cca

 
n/a
   

Post Reply



 



Advertisement

Worth A Click