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 / Help with mouse controled camera

Author
Message
JABBER
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Indiana, USA
Posted: 17th Mar 2005 05:28
This is how new I am, Trying to get the camera to rotate with the mouse, I'll worry about moveing in the direction the mouse pionted later, would like the x movement of the mouse rotate the camera along the y axis. feel free to laugh at this noob code, Thanks for ya help

I left it with the media cause I bet you guys can look at this one and see what's wrong right away

[/code]Rem Project: Shooting_range
Rem Created: 3/15/2005 11:15:09 PM

Rem ***** Main Source File *****

load object "shooting_range.3ds",1
scale object 1,200,200,200

set ambient light 55

cmx#=1
cmz#=-5
a#=0
b#=0

do

cmx#=cmx#+a#
cmz#=cmz#+b#
cay#=mousemovex()

position camera 0,cmx#,1,cmz#
yrotate camera 0,cay#*0.5
a#=0
b#=0

rem Control player movement
if upkey()=1 then b#=.02
if downkey()=1 then b#=-.02
if leftkey()=1 then a#=-.02
if rightkey()=1 then a#=.02

sync
loop[code]
Underworld 1020
20
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 17th Mar 2005 05:42 Edited at: 17th Mar 2005 05:43
Take a look here: http://forum.thegamecreators.com/?m=forum_view&t=50467&b=10

Also, to make a Code Snippet on this fourm you have to have the "code" command before the "/code" command.

So, it will show up like this:


Hope that helps .

Spaceman Spiff
20
Years of Service
User Offline
Joined: 27th Jan 2004
Location: Smacking my head on your keyboard.
Posted: 17th Mar 2005 16:42
Here is my highly butchered version of the controls from the 3d Mhunt tut.



You may need to play with it a wee bit before it works right for you.

Smile, it confuses people.
Los
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Location:
Posted: 17th Mar 2005 18:05
well one line I saw something wrong.. two if you include no wrapvalue() in there.

cay#=mousemovex()

from what I can bring up from my memory, mousemovex() will give you how FAST you move the mouse on the X axis. This means that the camera will jitter left or right, then return to the center.

from what I can advise? you need to ADD that mouse value, to cay..

cay#= cay# + mousemovex()
yrotate camera cay#

or something like that. I have not tested.

**Officialy has a mental illness.
" Ahh to finish something! My boy, have you ever accomplished anything? "
Los
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Location:
Posted: 17th Mar 2005 18:09


oops. IT only rotates 180. good for target ranges huh?
now you fiddle with code. like divide the cay# value, so it completes the 360 cycle. Or use spiffs code

**Officialy has a mental illness.
" Ahh to finish something! My boy, have you ever accomplished anything? "
Los
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Location:
Posted: 17th Mar 2005 18:11 Edited at: 17th Mar 2005 18:13
more work on the code... it rotates all the way around now for some strange reason. IT is this you need to understand.



I'm guessing that before, when it reached the mouse pointer reached the edge of the screen, it would not be able to move right or left anymore.. so mousemovex() would equal zero.. because it cannot move that way anymore (edge of screen!)

when I added the *2? ..erm.. thats to be understood. see what I mean?

**Officialy has a mental illness.
" Ahh to finish something! My boy, have you ever accomplished anything? "
Los
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Location:
Posted: 17th Mar 2005 18:15 Edited at: 17th Mar 2005 18:16
ok ok.. I'm a moron. No not because I don't edit my posts. I did that for a reason.

The first code DOES work. It does rotate... sorry about that. How did I figure this out?! well I used

text 240,0,str$(mousemovex())

and it told me what was being added to cay#!! simple.

**Officialy has a mental illness.
" Ahh to finish something! My boy, have you ever accomplished anything? "
JABBER
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Indiana, USA
Posted: 18th Mar 2005 03:00
Very nice Thanks for the help guys, I used your code as a guide line, cause if I just copy/paste I'll never grasp it, That mousemovex was it, that camera jumping left or right and then returning to center. Day 5 now and I'm completely hooked! Thanks again

now for poly collision, LOL

Login to post a reply

Server time is: 2024-11-13 20:00:01
Your offset time is: 2024-11-13 20:00:01