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.

Dark GDK / Mouse Smoothing?

Author
Message
blargmob
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location:
Posted: 9th Feb 2008 00:34
Howdy,

I just got started with Dark GDK and have a question about the mouse. Currently, my game uses an FPS style camera. However looking around with the mouse isn't very smooth like a genuine FPS game. It's sort of choppy and doesn't move pixel per pixel. I'm multiplying the change in position by 0.4f, so what's wrong here?

Thanks.

"I used to have a handle on life, but it broke."
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 9th Feb 2008 02:52
Well Sir,

It sounds like you are doing things very mechanically. And from PC to PC (different speeds of PC) your results will vary.

I'd start with learning how to implement timer based movement, and then apply similiar techniques to your mouse.

blargmob
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location:
Posted: 9th Feb 2008 03:03
And can you recommend me a tut for this 'timer based movement'?

"I used to have a handle on life, but it broke."
blargmob
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location:
Posted: 9th Feb 2008 03:42
Well, this might help, here is the code for what I'm doing to rotate the camera:



"I used to have a handle on life, but it broke."
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 9th Feb 2008 15:24
Quote: "And can you recommend me a tut for this 'timer based movement'?"
Not off the top of my head but I know there are backdated newsletters with references to it and I'm sure some focused googling would get you started.

I'll post some timer code I have handy and see if that sparks your imagination a bit It's one of those thing where at first its like "this stinks" until you start using it and see how much it can "smooth" things.

Well... basically timer code works by tracking the amount of time elapsed per game loop, or "since last time you checked" and using this "Time Elapsed" value in such a way you're not thinking "move this much: 0.4 " your thinking "Move this much per milli second: 0.004" or something. Same kinda principle can be used for both MOVING OBJECTS via move statements or controlling turn speeds. Once you get the hang of it - it wouldn't surprise me if you have timing code all over the place! LOL

A Header File *.h


The *.cpp file


Pseudo Code Sample


That is just Pseudo - not tested - values you'll have to play with to get YOUR timing right - but I'm hoping it gets the basic idea across!

Let me know how you make out!
Jason

Login to post a reply

Server time is: 2024-11-20 01:43:59
Your offset time is: 2024-11-20 01:43:59