Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Mouse Click "Buffer" Clear Help needed

Author
Message
DemonHill
16
Years of Service
User Offline
Joined: 20th Mar 2008
Location:
Posted: 3rd Nov 2009 23:29
I have a simple menu selection with a next event key

However as I click my button it seems to fill up a buffer and even if I release quickly the next events are triggered.
The waitbtn method I found in thsi forum doesn't seem to help.
Session numbers are incremented on completion of the session with in the qualifying gosub statements...

Any one can help me ?




DemonHill
16
Years of Service
User Offline
Joined: 20th Mar 2008
Location:
Posted: 4th Nov 2009 00:06
Thought I'd share what I managed to do to solve this

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Nov 2009 01:28
A variation of your code:



Enjoy your day.
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 4th Nov 2009 12:55 Edited at: 4th Nov 2009 12:56
Can you explain & to me again?

If I take 80&55, then it AND's the bits together, right?

0101'0000
0011'0111
--------------
0001'0000

So the result would be 16? Why use it with your code?

Thanks, TheComet


Make the paths of your enemies easier with WaypointPro!
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 4th Nov 2009 13:27
@Comet
since left mouse click is 1 Latch's code will only return 1 if the left mouse button is clicked. The other buttons are ignored.
You could change the 1 to 2 and then it would control the right button.

"With game, we create these elaborate worlds in our minds, and the computer is there to do the bookkeeping." - Will Wright
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 4th Nov 2009 16:32
So, is



faster than



?

TheComet


Make the paths of your enemies easier with WaypointPro!
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 4th Nov 2009 19:32
Quote: "0101'0000
0011'0111
--------------
0001'0000
"


With this is mind.

Mouseclick() can either be 0 or 1. in other words:

00000000
or
10000000

and 1 is:

10000000

it all depends on which is faster & or =. and since with = db has to figure out if it's a boolean test or a assignment operator & should be faster. so here is what db does with =

first it figures out what is (bool test or assignment)
next it tests for your condition.

and with &

gets the & and value
checks if it's greater then 0

just from that it should be faster to use the &

New Site! Check it out \/
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 4th Nov 2009 21:10
Quote: "and 1 is:

10000000"


Actually, 10000000 in binary is 128 - not 1!

TDK

Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 4th Nov 2009 21:20 Edited at: 4th Nov 2009 21:50
Quote: "Actually, 10000000 in binary is 128 - not 1!
"


really? how so? i thought it went like this:

1 = 10000000
2 = 01000000
3 = 11000000
4 = 00100000
5 = 10100000
6 = 01100000
7 = 11100000
8 = 00010000

and so on? am i wrong?

Wait! I just realized I have it backwords

1 = 00000001
2 = 00000010
3 = 00000011
4 = 00000100
5 = 00000101
6 = 00000110
7 = 00000111
8 = 00001000

hahaha ok got it

New Site! Check it out \/
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 4th Nov 2009 21:38
In binary, you read from right to left.

0 = 0000'0000
1 = 0000'0001
2 = 0000'0010
3 = 0000'0011
4 = 0000'0100
5 = 0000'0101
6 = 0000'0110
7 = 0000'0111
8 = 0000'1000

TheComet


Make the paths of your enemies easier with WaypointPro!
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 4th Nov 2009 21:51
I just edited that but i just hadn't refreshed in 20 minutes sorry didn't see your post comet thanks anyway lol

New Site! Check it out \/
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Nov 2009 01:22
@TheComet
Quote: "So, is

if mouseclick()&1

faster than

if mouseclick()

?"


They are different. If mouseclick()&1 is only testing for a click value of 1 (left click). If mousclick() is testing for any mouse click value. In terms of speed, because you aren't doing the additional & operation, If mouseclick() should be faster.

Quote: "Why use it with your code?"

Like Obese87 was saying, you use & in this case to filter out only the results you want bit wise. I wasn't interested in any mouse value except 1. So instead of

if mouseclick()=1 then nmc=1

I can just

nmc=mouseclick() & 1

to filter the values of mouseclick() to just 1.

Enjoy your day.

Login to post a reply

Server time is: 2024-05-03 23:38:39
Your offset time is: 2024-05-03 23:38:39