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 Professional Discussion / Mouse looking deadzone

Author
Message
Flamertor
14
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 20th Feb 2014 13:29
I'm trying to make a combat system which has a deadzone in the center to allow the player to aim with more accuracy. This is used in Rust if any of you have played it.

thanks
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 20th Feb 2014 16:56 Edited at: 20th Feb 2014 16:57
Th center of your screen can be found with screen width()/2 and screen height()/2.
Just paste your sprite there, or whatever you're using for your gun sight.

(I assume you wanted help although you didn't actually ask anything.)

Flamertor
14
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 20th Feb 2014 17:14
hi, I'm trying to have a part of the screen move the hand of the character and if you move it over a certain amount or speed the camera moves and not the hand. Sorry I didn't explain it very well
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 20th Feb 2014 18:04 Edited at: 20th Feb 2014 20:27
I see...
For starters, this code should help you determine how fast the mouse is moving:



Others may have completely different approaches than mine, of course.

As far as a deadzone, you can just use a percentage of your screen.
For example:



(Example only covers X not Y)

Flamertor
14
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 21st Feb 2014 15:04
Ah cool thank you very much, this seems to be exactly what I needed!

Thank you!
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 21st Feb 2014 19:44 Edited at: 21st Feb 2014 19:52
Quote: "Ah cool thank you very much, this seems to be exactly what I needed!

Thank you!"


Awesome... and thanks for thanking me.
Most people around here don't even bother to respond after getting help so we can know if it worked for them.

Also, I can't guarantee that the mouse speeds in that code will register the same on all computers. I think an optical mouse will pick up more movement than an old trackball style mouse.

Flamertor
14
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 21st Feb 2014 21:23
Ah okay, no problem most people nowadays use a optical anyway. I will keep it in mind though.

Login to post a reply

Server time is: 2026-07-07 00:10:10
Your offset time is: 2026-07-07 00:10:10