The Daily Click ::. Forums ::. Klik Coding Help ::. Mouse collision problem!
 

Post Reply  Post Oekaki 
 

Posted By Message

G. Hull



Registered
  07/01/2009
Points
  125

Wii Owner
21st January, 2009 at 16:58:23 -

Hey guys, I need help with something.
I am making a mouse controlled game. Your goal is to get the "Object"(Haven't figured out what exactly it is)to the goal. You cannot touch the wall or else you "Die" and start back at the beginning of the level. My problem is, If I go fast enough, I can just speed right through the walls and to the goal. (Instead of starting back at the beginning) Any suggestions?

Reply soon,
-Rannug


 
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!
21st January, 2009 at 17:15:52 -

Use the "move safely" extension.

Look at the example files (in the "mmf/examples/move safely 2/" folder) to find out how.

Edited by Sketchy

 
n/a

Peblo

Custom ratings must be 50 characters or less

Registered
  05/07/2002
Points
  185

Game of the Week WinnerVIP MemberI'm on a Boat360 OwnerAttention GetterThe Cake is a LieCardboard BoxHero of TimePS3 OwnerIt's-a me, Mario!
I'm a Storm TrooperSonic SpeedStrawberryI like Aliens!Wii OwnerMushroomGhostbuster!
21st January, 2009 at 17:28:37 -

Unfortunately, the mouse moves too fast sometimes and that's a problem you're going to come across. To remedy this, you can do this:

Create an active object as small as you can, 1x1 does fine, or you can go with the exact shape of the mouse if you want it so any part of the mouse collides with the wall.
Start of level>set active to mouse x,y

always>
set some counter or something to (Squareroot((xpos-xmouse)^2+(ypos-ymouse)^2) )
start fastloop move (previously mentioned counter) times

on loop move>
Xpos = xpos + Cos(Atan2( (ypos – ymouse ) , (xpos – xmouse) ) ) * Loop step/(previously mentioned counter)
Ypos = xpos + Sin(Atan2( (ypos – ymouse ) , (xpos – xmouse) ) ) * Loop step/(previously mentioned counter)



Uh, I think. I'm in class right now so I can't test it or actually see if the method has any validity so you might want to have someone look it over. It should be right or mostly right.

EDIT: Or the move safely extension.

Edited by Peblo

 
"Isn't it always amazing how we characterize a person's intelligence by how closely their thinking matches ours?"
~Belgarath
   

Post Reply



 



Advertisement

Worth A Click