Use mouse to move (more complex)SOLVED

Started by R4L, Wed 08/03/2006 20:25:33

Previous topic - Next topic

R4L

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

DoorKnobHandle

Shouldn't this work by putting this line into the repeatedly_execute function:

Code: ags

// 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.

R4L

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.

Scorpiorus

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.

Khris

#4
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.

R4L

Wow! Thanks for the feedback! I'll try that code scorpiorus.

R4L

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!

SMF spam blocked by CleanTalk