Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Jimmy on Sun 22/02/2004 10:35:46

Title: Can i count the number of clicks?
Post by: Jimmy on Sun 22/02/2004 10:35:46
I'm making this shooter where you have limited ammo, so is it possible? If so, how do i do it?
Title: Re:Can i count the number of clicks?
Post by: Scorpiorus on Sun 22/02/2004 11:35:15
To count a number of mouse clicks declare  a global variable at the top of main script and increase it inside the on_mouse_click() function located in that global script:

Counting mouse left button clicks:

//main global script

int mouse_clicks = 0;

function on_mouse_click(int button) {
 // called when a mouse button is clicked. button is either LEFT or RIGHT
 if (IsGamePaused() == 1) {
   // Game is paused, so do nothing (ie. don't allow mouse click)
 }
 else if (button==LEFT) {
   ProcessClick(mouse.x, mouse.y, GetCursorMode() );
  mouse_clicks = mouse_clicks + 1; // increasing mouse click counter
 }
 else {   // right-click, so cycle cursor
   SetNextCursorMode();
 }
}