The Game Creators
The Game Creators Home Online Shop Click to Login
  Hot: Christmas CompetitionNovember NewsletterModel Pack 36DB Pro Pack 2009DGS BonanzaCharacter PackFPS Creator Bonanza;
The Game Creators
DarkBASIC / Mouse Click "Buffer" Clear Help needed

Go to the first page of this board Return to the Forum Menu Post Message
12 Messages - Page   of 1   
Bookmark and Share Search the Forum

Author Message
DemonHill

User


Joined: Thu Mar 20th 2008
Location: Cyberspace
Posted: 3rd Nov 2009 16:29           | link | toggle

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 ?




+ Code Snippet
If mousex()>=u+839 and mousex()<=u+899 and mousey()>=v and mousey()<=v+60 and sessionstart=0

               if mouseclick()=1 and timer()-waitbtn>250
                  waitbtn=timer()
                  button13=72
                  CarSetup=0
                  sessionstart=1
                  paste image button13,u+839,v

                  If Session=3:gosub Qualify:Endif
                  If Session=4:gosub Qualify2:Endif
                  If Session=5:gosub Qualify3:Endif
               endif
         Endif
Back to top
Report this message as abusive
DemonHill

User


Joined: Thu Mar 20th 2008
Location: Cyberspace
Posted: 3rd Nov 2009 17:06           | link | toggle

Thought I'd share what I managed to do to solve this

+ Code Snippet
if mouseclick=1 then oldmouse=1
if mouseclick()=1 and oldmouse=0:mouseclick=mouseclick():print "pressed":else:mouseclick=0:endif
if mouseclick()=0 then oldmouse=0
Back to top
Report this message as abusive
Latch

User


Joined: Sun Jul 23rd 2006
Location: Cyberspace
Posted: 3rd Nov 2009 18:28           | link | toggle

A variation of your code:

+ Code Snippet
do
   omc=nmc
   nmc=mouseclick() & 1
   if nmc > omc
      print "Left Click"
   endif
loop


Enjoy your day.
Back to top
Report this message as abusive
TheComet

User


Joined: Thu Oct 18th 2007
Location: Conker rulz!
Posted: 4th Nov 2009 05:55     Edited: 4th Nov 2009 05:56     | link | toggle

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!
Back to top
http://www.the-comet.blogspot.com
Report this message as abusive
OBese87

User


Joined: Fri Jun 30th 2006
Location: On Toast
Posted: 4th Nov 2009 06:27           | link | toggle

@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
Back to top
Report this message as abusive
TheComet

User


Joined: Thu Oct 18th 2007
Location: Conker rulz!
Posted: 4th Nov 2009 09:32           | link | toggle

So, is

+ Code Snippet
if mouseclick()&1


faster than

+ Code Snippet
if mouseclick()


?

TheComet


Make the paths of your enemies easier with WaypointPro!
Back to top
http://www.the-comet.blogspot.com
Report this message as abusive
Google Ad
Back to top
 
Caleb1994

User


Joined: Fri Oct 10th 2008
Location: The Internet you idiot!
Posted: 4th Nov 2009 12:32           | link | toggle

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 \/
Back to top
MyDarkPrograms
Report this message as abusive
TDK

Moderator


Joined: Tue Nov 19th 2002
Location: Tenerife, Spain
Posted: 4th Nov 2009 14:10           | link | toggle

Quote: "and 1 is:

10000000"

Actually, 10000000 in binary is 128 - not 1!

TDK

Back to top
TDK\'s Web Site
Report this message as abusive
Caleb1994

User


Joined: Fri Oct 10th 2008
Location: The Internet you idiot!
Posted: 4th Nov 2009 14:20     Edited: 4th Nov 2009 14:50     | link | toggle

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 \/
Back to top
MyDarkPrograms
Report this message as abusive
TheComet

User


Joined: Thu Oct 18th 2007
Location: Conker rulz!
Posted: 4th Nov 2009 14:38           | link | toggle

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!
Back to top
http://www.the-comet.blogspot.com
Report this message as abusive
Caleb1994

User


Joined: Fri Oct 10th 2008
Location: The Internet you idiot!
Posted: 4th Nov 2009 14:51           | link | toggle

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 \/
Back to top
MyDarkPrograms
Report this message as abusive
Latch

User


Joined: Sun Jul 23rd 2006
Location: Cyberspace
Posted: 4th Nov 2009 18:22           | link | toggle

@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.
Back to top
Report this message as abusive

Go to the first page of this board Return to the Forum Menu Post Message
12 Messages - Page   of 1   
Search the Forum

You must be logged-in to post messages to this forum. You can register an account for free. Or click here to login.
Forum Search

Enter a word or phrase to search our Forum for:

Thread Subject Search
Search Phrase:
Search Scope: Entire forum
Just this board
 
Google Forum Search
Search Phrase:
 
Apollo v2.02


Game Creator Store
Privacy Policy AUP Top of Page