Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: R4L on Wed 08/03/2006 20:25:33

Title: Use mouse to move (more complex)SOLVED
Post by: R4L on Wed 08/03/2006 20:25:33
When I mean use the mouse to move I mean like, say you had a character who just kept walking and moved wherever you put the mouse. I was wondering how this would be done. I tried just using a simple MoveCharacter command but the game just loads and loads and loads...

BTW: I'm using 2.61
Title: Re: Use mouse to move (more complex)
Post by: DoorKnobHandle on Wed 08/03/2006 20:32:09
Shouldn't this work by putting this line into the repeatedly_execute function:


// update the player position NON-BLOCKING
MoveCharacter ( EGO, mouse.x, mouse.y );


Basically just make sure you are calling the move-function non-blocking! I never tried this, there may be problems with this.
Title: Re: Use mouse to move (more complex)
Post by: R4L on Wed 08/03/2006 20:37:07
That's what I tried, but the game just loads, even when I don't put in a blocking function. Maybe I have something in my room script that prevents me from doing this.
Title: Re: Use mouse to move (more complex)
Post by: Scorpiorus on Wed 08/03/2006 20:48:58
Hmm, what do you mean with "loads"?

Try the following method:

int delay = 0;

function repeatedly_execute() {

   if (delay > 0) delay --;
   else
   {
      MoveCharacter ( EGO, GetViewportX() + mouse.x, GetViewportY() + mouse.y );
      delay = 50;
   }

}

I think someone tried that before and he didn't like the result it produced. A little we can do about it, though.
Title: Re: Use mouse to move (more complex)
Post by: Khris on Wed 08/03/2006 20:59:10
Maybe MoveCharacterStraight will produce better results, since it doesn't use A*, so calling it 40 times a second won't be as "unfriendly" to the engine.
Title: Re: Use mouse to move (more complex)
Post by: R4L on Thu 09/03/2006 19:57:29
Wow! Thanks for the feedback! I'll try that code scorpiorus.
Title: Re: Use mouse to move (more complex)
Post by: R4L on Sun 12/03/2006 05:07:04
That code got it Scorpiorus. I just had to change the delay to 10 so that my character was more responsive. Anyways, thanks for all the help!