Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,767 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
count the mouse click per second. #412944
12/05/12 12:19
12/05/12 12:19
Joined: Oct 2012
Posts: 53
K
kenced Offline OP
Junior Member
kenced  Offline OP
Junior Member
K

Joined: Oct 2012
Posts: 53
hi!. I want to count the player clicks in a second. If 3 consecutive clicks done by the player it will do something, else the counter for clicks will return to 0. Is this possible?. Can anyone help me about this? thanks.

Last edited by kenced; 12/05/12 19:01.
Re: count the mouse click. [Re: kenced] #412947
12/05/12 13:23
12/05/12 13:23
Joined: Jul 2008
Posts: 2,110
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,110
Germany
Code:
...
 ..
 var interval_time = 0;
 var max_time = 1000; //fex
 var mclicked = 0;
 while(interval_time < max_time){
    interval_time += time_step;
    if (mouse_left) mclicked += 1;
    if (mclicked >= 3) { _do_something;break; }
    wait(1);
 }  
 ...
 ..


Greets


Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: count the mouse click. [Re: rayp] #412959
12/05/12 16:20
12/05/12 16:20
Joined: Oct 2012
Posts: 53
K
kenced Offline OP
Junior Member
kenced  Offline OP
Junior Member
K

Joined: Oct 2012
Posts: 53
it didnt work. in my first clicked it always do the (mclicked>=3) condition, maybe because,once you clicked the left mouse button the condition is always true thats why mclicked continue in incrementing.

Re: count the mouse click. [Re: kenced] #412972
12/05/12 17:34
12/05/12 17:34
Joined: Jul 2008
Posts: 2,110
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,110
Germany
Maybe checking for mouse_left is hold ? Maybe use another while ?
Code:
var interval_time = 0;
 var max_time = 1000; //fex
 var mclicked = 0;
 while(interval_time < max_time){
    if (mouse_left) 
    { 
       mclicked += 1; 
       while(mouse_left && interval_time < max_time){
          interval_time += time_step;
          wait(1); 
       }
     }
    else interval_time += time_step;
    if (mclicked >= 3) { _do_something;break; }
    wait(1);
 }


I guess this works not tested cause iam working btw.

Last edited by rayp; 12/05/12 18:47.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: count the mouse click. [Re: rayp] #412978
12/05/12 19:00
12/05/12 19:00
Joined: Oct 2012
Posts: 53
K
kenced Offline OP
Junior Member
kenced  Offline OP
Junior Member
K

Joined: Oct 2012
Posts: 53
I try it but again it not work. but then thank you for your help laugh

Re: count the mouse click. [Re: kenced] #412980
12/05/12 19:33
12/05/12 19:33
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Here you go:
Code:
#include <acknex.h>

void on_mouse_left_event()
{
	static fixed t0 = -16;
	static fixed t1 = -16;
	if (total_ticks <= t0 + 16)
	{
		beep(); // Do whatever you want to do here instead.
		t0 = t1 = -16;
	} else {
		t0 = t1;
		t1 = total_ticks;
	}
}


Last edited by Uhrwerk; 12/06/12 04:01. Reason: Fixed a bug in the code

Always learn from history, to be sure you make the same mistakes again...
Re: count the mouse click. [Re: Uhrwerk] #412983
12/05/12 19:40
12/05/12 19:40
Joined: Jul 2008
Posts: 2,110
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,110
Germany
But hes asking for 3 clicks in time if i understood him right.

Edit: Just saw the thread starter changed topic and problem description.

Last edited by rayp; 12/05/12 19:42.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: count the mouse click. [Re: rayp] #412985
12/05/12 19:47
12/05/12 19:47
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Originally Posted By: rayp
But hes asking for 3 clicks in time if i understood him right.

That is exactly what my sample does?


Always learn from history, to be sure you make the same mistakes again...
Re: count the mouse click. [Re: Uhrwerk] #412987
12/05/12 20:21
12/05/12 20:21
Joined: Jul 2008
Posts: 2,110
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,110
Germany
sry only read with one eye. ^^


Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: count the mouse click. [Re: rayp] #412994
12/06/12 03:01
12/06/12 03:01
Joined: Oct 2012
Posts: 53
K
kenced Offline OP
Junior Member
kenced  Offline OP
Junior Member
K

Joined: Oct 2012
Posts: 53
Thanks Uhrwerk,I really dont understand your code. why it should be -16?. but then it works!. It really helps.

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1