Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: phillipPbor on Thu 05/11/2015 04:41:35

Title: ninja dash
Post by: phillipPbor on Thu 05/11/2015 04:41:35
do you know that if you double click with your walk button you can see your player "RUN".
so can someone tell me how can you double click to make your player run?
please?
Title: Re: ninja dash
Post by: Vincent on Thu 05/11/2015 08:15:31
You've forgotten the magic word. :cool:
Title: Re: ninja dash
Post by: phillipPbor on Thu 05/11/2015 10:58:35
please?
Title: Re: ninja dash
Post by: Vincent on Thu 05/11/2015 12:40:50
BINGO !!!
To detain a double click of the mouse I would do something like this :

// GlobalScript.ash
Code (ags) Select

#define MOUSE_DOUBLECLICK_RATE  10 // Double click delay



// GlobalScript.asc
Code (ags) Select

// top of the script
int double_click;

function repeatedly_execute()
{
  // DoubleClick recognizer
  if (double_click > MOUSE_DOUBLECLICK_RATE)
  {
    double_click = 0;
  }
  else if (double_click)
  {
    double_click ++;
  }
}



function on_mouse_click(MouseButton button)
{
  if (button == eMouseLeft)
  {
    if (!double_click)
    {
      // user performed a Single click (walk)
      double_click ++;
    }
    else
    {
      // user performed a Double Click (run)
    }
    ProcessClick(mouse.x,mouse.y, mouse.Mode);
  }
}


Not tested, however I think there are several ways to achieve that.
I hope it could give you the idea.
Title: Re: ninja dash
Post by: phillipPbor on Thu 05/11/2015 13:03:32
repeatedly_execute() ?  :confused:

GlobalScript.asc(78): Error (line 78): Variable 'repeatedly_execute' is already defined

this is bad.
Title: Re: ninja dash
Post by: Vincent on Thu 05/11/2015 13:16:07
Yes, Indeed.
The function repeatedly_execute() is already defined in the GlobalScript.
You will have to copy the inside of the repeatedly_execute that I wrote and paste it to the Global one.
Same for the function on_mouse_click.

However, in every each room, you can have a different repeatedly_execute from the Global one.
If you need that for a room only, paste everything to a room script.
Title: Re: ninja dash
Post by: phillipPbor on Thu 05/11/2015 16:03:09
but where and how?
can you tell me this easy?
Title: Re: ninja dash
Post by: Vincent on Thu 05/11/2015 16:57:33
I am not sure how to explain that easily.
If you can post your 'GlobalScript' here, I can show you where you will need to do that.
Title: Re: ninja dash
Post by: phillipPbor on Thu 05/11/2015 17:11:04
I think I already did.
Title: Re: ninja dash
Post by: Snarky on Thu 05/11/2015 19:18:23
Nope, you didn't.

It sounds like you're just starting out with AGS. You should begin by having a look at the manual that comes with it (under the Help menu) â€" you can also find it here (http://www.adventuregamestudio.co.uk/manual/) (slightly out of date, but it shouldn't matter). Go through the tutorial and have a look at the introduction to scripting. (The most relevant bit is here: http://www.adventuregamestudio.co.uk/manual/ags43.htm#repexec)

Making a game is not something that can be done without effort, so we expect people to do a little bit of studying before you come here asking questions.