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.

Newcomers DBPro Corner / mousewheel

Author
Message
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 27th Dec 2004 04:38
how would i use the mouse wheel to increase or decrease the variable "tog"? i.e. if you move the mousewheel up then tog increases and if you move it down tog decreases. I'm using DBC.

Thanks

Am I the only one here who's really confused?
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 27th Dec 2004 05:38
quick example

tog=0
do
cls
print tog
if mousez()>oldmouse
tog=tog+1
endif
if mousez()<oldmouse
tog=tog-1
endif
oldmouse=mousez()
loop

hope that explains things, cheers.

Mentor.

PC1: P4 3ghz, 1gig mem, 3x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 27th Dec 2004 17:33
It can be easier than that:



Here's an example program:

demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 27th Dec 2004 17:41 Edited at: 27th Dec 2004 18:05
cool
thanks both of you - didn't know the mousez command was mousewheel.

[edit]
I still can't get my code to work right! [img] [/img] I'm using:



It seemed to be easier to understand than the other method, and I'm lazy so I thought I'd give it a go...

max# is 2 and min# is 1 at the moment (will increase later). I can't see what I'm doing wrong - can someone please help?

Thanks
[/edit]

[edit2]
I tried the other method:



It still doesn't work!
[/edit2]

[edit3]

I changed the code and it's because I was dividing by 500 that it wasn't working, at 100 it works better (but still not perfect - I can fix that though)

Here's my code at the moment:



Thanks for your help. Mentor and Chris K
[/edit3]

Am I the only one here who's really confused?
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 27th Dec 2004 18:22 Edited at: 27th Dec 2004 18:22
cant you position the mouse's z position? because I am using that code but the mouse position is a number which increases or decreases by 120, but it isnt limited at all(so it has no effect in my game for ages because sometimes it starts off as a number in the thousands and you have to scroll down for ages to get the right numbers for it to be affected)

[edit] here's the code

[/edit]

Am I the only one here who's really confused?
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 28th Dec 2004 05:16 Edited at: 28th Dec 2004 05:25
either just use my system which ignores what mousez actualy is and just changes with the direction of the wheel, or get mousez before you start and then subtract that value to make it start at zero, eg:

Calibrate=mousez()
at the beginning, then

value-(mousez()-Calibrate)/100
in the main loop

the value will start off at zero and change up or down according to whatever you do with the wheel (the result will always be an integer), heres my original code modified to have maximums and minimums.

tog=0
max=2
min=-2
do
cls
print tog
if (mousez()>oldmouse) and (tog<max)
tog=tog+1
endif
if (mousez()<oldmouse) and (tog>min)
tog=tog-1
endif
oldmouse=mousez()
loop

that limits the scrollwheel to a max and min value, hope thats some help.

Mentor.

ps:one other thing, don`t use floats (numbers ending #) where integers will do, although they take the same amount of time to calculate try to leave the fpu free for 3d positioning calculations and use integers for simple counting.

PC1: P4 3ghz, 1gig mem, 3x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.

Login to post a reply

Server time is: 2024-09-23 08:32:48
Your offset time is: 2024-09-23 08:32:48