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 clicking TOO MANY TIMES!

Author
Message
Soroki
20
Years of Service
User Offline
Joined: 26th Jan 2006
Location: United States
Posted: 21st Dec 2007 21:59
I am sorry I don't access to the code to post right now, but I made a zooming function for a small FPS. When you right click, it is supposed to zoom(I just set FOV I think...180? :/) but it sort of freaks out, as though I clicked the button too many times. I have to gently tap the mouse button for it to work, and zooming out is justa s annoying. Anyone have a small snippet for making the mouse click ONLY ONCE?


Thanks


Soroki

If you whine about graphics, you are not a true gamer, you are just an imposter to a title you can't understand.
demons breath
22
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 21st Dec 2007 22:03
at the end of your mouseclick code add:


That's assuming you have sync on in your program.

The problem is that it keeps running through the loop and seeing that you have the mouse down so it toggles the function. This code is a simple repeat...until loop which repeats until you let go of the mouse button, thus eradicating the problem. The sync command's just in the middle so that the mouse doesn't stay in the same place if you hold the mouse button down and then jump, because that just looks rubbish.

"A West Texas girl, just like me"
-Bush
jason p sage
18
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 21st Dec 2007 22:17
I did something different for zoom. Mouse Wheel! Change FOV Between a MIN and MAX - use Mouse Scroll wheel to do it - then you can just move it slow or fast manually - no "wait until" and Toggle logic

Bluestar4
20
Years of Service
User Offline
Joined: 19th Dec 2005
Location: USA
Posted: 22nd Dec 2007 00:18
I aggree with jason - except that I suggest instead of changing the FOV that you simply adjust closeness of the camera {this acts like a zoom effect without messing up FOV . if this seems like a good solution to you and you need some sample code then let me know.

jason p sage
18
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 22nd Dec 2007 00:34 Edited at: 22nd Dec 2007 00:36
BlueStar - I'd be personally interested in seeing a little example. I could probably whip one up - but while you're on the subject you think you could just give us a 10 liner - just to scope it out? (Not just me evidently would benefit )

Thank You in Advance

(BTW) That could be the BEST Way! It sounds like a GREAT Idea!

[edit]Now I'm wondering what they used in Delta Force, Far Cry etc... FOV or Cam Range... Hmmm[/edit]

Libervurto
19
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 22nd Dec 2007 00:46 Edited at: 22nd Dec 2007 00:56
If you want the computer to respond to the mouseclick once then do this:

That would respond to any mouse click. To make it only respond to a right click you'd do this:

This might look a little confusing but it's basically saying "if the right mouse button is down (newclick=2) and it wasn't before (oldclick=2) then do whatever".
If newclick = 2 then (newclick=2) = 1
Am I making sense?
If statements ask DB if the statement is true, i.e.
IF a > b then print "A is larger"
This is asking DB whether the statement that a>b is true, this will return 1 if true (a>b), or 0 if false (a<=b). You can do some clever things by using these numbers

You are right to use FOV for zooming, although bluestar's method is ok it has a drawback: objects that are in front of the player will "disappear" when the camera moves through them to "zoom in". From a realism point of view, changing the FOV is the better option

[edit]
@Bluestar
Not sure if I understood your idea, do you mean moving the camera?

jason p sage
18
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 22nd Dec 2007 01:14 Edited at: 22nd Dec 2007 01:15
Awesome Point - I remember now - duh - I did that first then I went to FOV and I liked the fact that stuff in front of me could fill the whole screen - like a pair of binoculars would act.... Ok - FOV WINS! (For me)

[edit] Obese after reading your post more carefully - "Do you mean moving the camera" questin - I think that's what I did before - FOV - Sorry - Verdict out until we know about the changing cam range. (I suspect FOV might win though) [/edit]

Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 22nd Dec 2007 02:00
i use the timer() for limiting a click or keypress to once only:

if mouseclick()=1 and timer()-waitbtn>250
waitbtn=timer()
do whatever here
endif

also works well for things which require a cool down... say different weapons with different reload times etc as you can just adjust the >value by weapon/skill/whatever

Bluestar4
20
Years of Service
User Offline
Joined: 19th Dec 2005
Location: USA
Posted: 22nd Dec 2007 09:20
@ jason - in the example I have provided the camera is set to a top down viewpoint and is focused on object 1, and the mouse wheel will zoom in and out on the object - you are ofcourse free to change the snippet I have provided to your hearts desire as with a little extra code and work you can use it to change the camera from other viewpoints



Libervurto
19
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 22nd Dec 2007 10:40 Edited at: 22nd Dec 2007 10:57
Here's my case for FOV zooming
It uses Ortu's click method, which I like a lot It works well for something like this.


And here's Bluestar's version in my world


Bluestar4
20
Years of Service
User Offline
Joined: 19th Dec 2005
Location: USA
Posted: 22nd Dec 2007 11:53
as I said, that was top view now here is the code you would use for the default view . I have modified your code so that it works correctly however, to actually get a decent zoom effect you should modify your code to increase the size of your objects to a decent size (say around 75 or so ) and after doing that you can also add code to point the camera toward the object you wish to zoom in on and so forth. In general , The larger the objects are and the smaller amount that you move the camera , the bigger the zoom effect will be!



Libervurto
19
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 22nd Dec 2007 14:35
Thanks for that bluestar, I was finding it hard to put your code into my program.
I still think the FOV method is best as the camera doesn't move past the objects.

Soroki
20
Years of Service
User Offline
Joined: 26th Jan 2006
Location: United States
Posted: 22nd Dec 2007 16:15 Edited at: 22nd Dec 2007 16:18
Sorry for not responding with my gratitude, I was unable to access the Internet yesterday Thanks to everyone here that posted. Mouseclick issues have been bugging me ever since I started programming lol. Thanks a lot to all of you!


EDIT: I do notice, or maybe it appears so, that objects in motion SLOW DOWN when FOV is changed to zoom in. Interesting...

If you whine about graphics, you are not a true gamer, you are just an imposter to a title you can't understand.
Libervurto
19
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 22nd Dec 2007 17:05
@Soroki
They would appear to slow down because the screen is effectively being stretched, so it takes longer to get from one side to the other.
I'm not sure if this happens in real life

Jmahmood
19
Years of Service
User Offline
Joined: 3rd Apr 2007
Location: not sure
Posted: 22nd Dec 2007 18:37
i had that same problem with my RTS.



this wait command will stop your rapid mouse clicks

Visit http://eternity.freeweb7.com for product demonstration,Downloads,Screenshots and Public forum
jason p sage
18
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 22nd Dec 2007 18:59
I don't recommend that method. Adding a wait command - in a game - well... in the main loop anyway - where the screen is full of moving this and that - well.. a wait command will make everything wait... Timer is your best bet.

(Pseudo code - Don't expect this to compile - I'm demonstraing how you might consider going about this... So just look at it or paste it into code replacing the "mock up" I did with real DB syntax)


Jmahmood
19
Years of Service
User Offline
Joined: 3rd Apr 2007
Location: not sure
Posted: 22nd Dec 2007 19:04
it worked for my RTS!!!

jason p sage
18
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Bluestar4
20
Years of Service
User Offline
Joined: 19th Dec 2005
Location: USA
Posted: 22nd Dec 2007 20:20 Edited at: 22nd Dec 2007 20:59
@OBese87

Quote: "Thanks for that bluestar, I was finding it hard to put your code into my program."

your welcome.

Quote: "I still think the FOV method is best as the camera doesn't move past the objects."

- both methods can get the job done if coded correctly so basically its just a matter of which way you like the best.

@everyone else
ok, we all know that when you click on something that there is usually a bump or beep sound associated with the button you just pressed. so to solve your little problem find any short wav file and load it , then check to see if the sound is playing when clicked
This will ensure that the program continues to run at peek performance and not stall the entire program.


Login to post a reply

Server time is: 2026-06-09 19:40:42
Your offset time is: 2026-06-09 19:40:42