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 / My mouse looking code is messing up! Halp!

Author
Message
Yart
20
Years of Service
User Offline
Joined: 23rd Jun 2004
Location: Turkey Sandwich
Posted: 12th Aug 2004 15:28
Ok I was working on some code to make it so that when you move the mouse, so does the rotation of the camera. Kinda like a FPS. But seems like somehow when I push and and down on the mouse, the camera turns left and right. And when I push left and right, the camera goes up and down... and I tried reversing but everything starts flickering right after! HALP!

(Screen resolution at 800x600 | Ignore the extra code for that's for other objects that I included)



Pie!
Physics coder
20
Years of Service
User Offline
Joined: 25th May 2004
Location: United States
Posted: 12th Aug 2004 15:49 Edited at: 12th Aug 2004 16:18
you were rotating the x axis by the mousex and y axis by mouse y. try changing the x axis by mousemovey() and y axis by mousemovex(), like this snippet:



if you change a few things, you can also have mouse sensitivity and the mouse invert like in most fps games:


here is the code you posted, but fixed, if you want to see what needed to be changed. I recommend you don't have commands that are screen res specific, in case you ever want to have different screen resolutions(the two snippets above should work at every resolution your computer can support). Note: I added 5 lines of code to your snippet to set the screen res, sync stuff, and a matrix to judge the rotation to.



-----------------------------------
To delete the bug, delete the code.
Specs: Sony VAIO Laptop, Windows XP, P4 2.8Ghz, 512MB RAM, ATI Radeon 64MB video memory, DBP Upgrade 5.3.
Yart
20
Years of Service
User Offline
Joined: 23rd Jun 2004
Location: Turkey Sandwich
Posted: 12th Aug 2004 16:09 Edited at: 12th Aug 2004 16:22
I tried reversing already and i get flickering of the screen... but I'll try once more

*tries*

hmm... still does the flickering...
I'm gonna try rewriting my code

EDIT: I tried your code, copying and pasting, just this one line...
...and it works like a charm! Thanks!
I'll try to remember how to do it so next time I can do it on my own.
EDIT AGAIN: The sensitivity part is really nice as well!

Pie!

Login to post a reply

Server time is: 2024-11-27 06:46:28
Your offset time is: 2024-11-27 06:46:28