The Daily Click ::. Forums ::. Klik Coding Help ::. Reposition object using rotation
 

Post Reply  Post Oekaki 
 

Posted By Message

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
22nd October, 2010 at 21:52:03 -

I am trying to make a game for the Xmas compo but i am having a problem with repositioning an object.

The main level is rotated and an object needs to keep it's relative position. i have got the rotation down but i cannot work out the placement of the object.

I have a feeling that its a cos sin formula i need but i cannot get it to work

 
n/a

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
22nd October, 2010 at 22:22:51 -

I have a feeling we're going to need a bit more detail than that.

 

  		
  		

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
22nd October, 2010 at 22:30:13 -

Thought as much

Don't want to reveal too much info on the game yet though so....

See if this makes sense:

There is a ball in the top left hand corner of a box. The player presses right and the box rotates right. At the same time the ball would normally stay in it's current position i need the ball to follow the box around on it's rotation path. so the top left hand corner would become the top right hand corner.

 
n/a

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
22nd October, 2010 at 23:14:53 -

Is the box an active object? Are there any other objects? Are you rotating around the hot spot?

 

  		
  		

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
22nd October, 2010 at 23:20:30 -

The box is one big active object. Its action point and hot spot are in the middle. The box is rotated around these points until it reaches a 90 degrees difference. The only other object is the ball. I could upload an mfa but again i don't want to give away too much.

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
22nd October, 2010 at 23:38:16 -

I know you don't want to give much away, but I think you're going to have to tell us a bit more than you have so far...

Do you mean something like this?
http://cid-b1e7ee094271bbda.office.live.com/self.aspx/Public/LevelRotate.mfa

 
n/a

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
22nd October, 2010 at 23:46:19 -

similar yes sketchy however i cannot work out what you have done. I have conceded and uploaded the basic mfa.

http://mfa.aquadasoft.com/view/1287787445-testgame

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
23rd October, 2010 at 00:07:54 -

http://cid-b1e7ee094271bbda.office.live.com/self.aspx/Public/LembiEdit.mfa

It does basically what you want, but there's a bug and I'm not sure how to fix it

 
n/a

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
23rd October, 2010 at 00:12:40 -

perfect sketchy. i'll try and fix the bug

I think i have fixed the bug. it was related to the ball getting stuck in the walls no?

Edited by lembi2001

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
23rd October, 2010 at 00:20:50 -

I think the problem is being caused by the rotation being out by 1 or 2 pixels (possibly due to the limited precision), and I may have a solution...

+ Rotation("Level") = 0
+ Only one action when event loops
-> Ball: Set X position to X("Ball")/CellWidth*CellWidth
-> Ball: Set Y position to Y("Ball")/CellHeight*CellHeight

That should snap the ball perfectly to a grid cell after the rotation.
Just make sure the level object is perfectly aligned to the grid itself.
I'll try and fix the example to show you...


EDIT:
Just saw your post - Yes, that's the bug I was talking about. If you've fixed it, I won't bother trying any more (I was ready to give up for tonight anyway).


Edited by Sketchy

 
n/a

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
23rd October, 2010 at 10:22:02 -

looks like i didn't fix it after all!! it was just a fluke.

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
23rd October, 2010 at 13:53:43 -

I think you're going to need to use detectors, and just push the ball out of the walls

 
n/a

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
23rd October, 2010 at 13:57:27 -

okay, cheers sketchy. you have been a huge help!

 
n/a
   

Post Reply



 



Advertisement

Worth A Click