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 / camera zoom with scrollwheel and cam_move with mousebutton 3

Author
Message
Jasonorc
16
Years of Service
User Offline
Joined: 29th Apr 2008
Location: Turn around...
Posted: 24th May 2009 21:08
Hi, I've looked at 8 or 9 topics already covering this, and none seem to have worked with my code.

Why I'm trying to implement is when you scrool the mousewheel you zoom in or out of the map, and when you press the scroolwheelbutton (mousebutton3) you can move your mouse around and have the cemar follow, as in most third person rpgs

anyway, here is the source


So what do I have to put and where (where seems to be important when you also have a button menu)

My site: www.skyknight.co.uk
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 24th May 2009 23:07 Edited at: 24th May 2009 23:09
well, i don't really understand this code (due to Cos and Sin) but if you place this code:

move camera mousez()/5

just after the point camera bit, you can scroll with your mousewheel. what it does, it moves the camera back the distance you have scrolled divided by 5. you can try changing the number, higher for more accuracy, lower for less.

about the rotating part, i can;t really think right now, little bit too late, so if you're not helped tomorrow i'll try to look into your code. but i think by then, the porblem is already solved

hope this helps

Vathelokai
15
Years of Service
User Offline
Joined: 3rd May 2009
Location:
Posted: 25th May 2009 00:09
You mean like this...
Vathelokai
15
Years of Service
User Offline
Joined: 3rd May 2009
Location:
Posted: 25th May 2009 06:07
or something more like this...
Jasonorc
16
Years of Service
User Offline
Joined: 29th Apr 2008
Location: Turn around...
Posted: 25th May 2009 10:57
Ok, I've managed to do a zoom/scroos feature, but I'm still not sure how to habe mousebutton3+posy/posx make it a lookaround style view.

Any ideas?

My site: www.skyknight.co.uk
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 25th May 2009 15:50
ok, i've made little bit, i'm not sure if its the best way, but it works

look at this code, its your code with my rotation thing in it



what you might now is that the place were the Ang# variable is now, first was a value. that was 270. that meant that the camera was positioned directly behind the player. so by altering that value, you can rotate the camera!

and were the CamYPos# variable is now, first was a value too. that value was 130. if you change that value, the camera will go up or down.

and what i do here:



i check if the middle mouse button is being pressed, if it is, it decreases the Ang# and CamYPos# values the amount of movement the mouse makes, and that way you can Orbit the Camera!

Jasonorc
16
Years of Service
User Offline
Joined: 29th Apr 2008
Location: Turn around...
Posted: 25th May 2009 16:42
Thanks! After I deletd the new clones and cubes you created it worked great, thats brilliant bobbel, thanks!

My site: www.skyknight.co.uk
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 25th May 2009 17:12
Np. but i'm sure there is a better way, so remember this very well, and when u get better at maths and stuff you might be able to work out a better version

Jasonorc
16
Years of Service
User Offline
Joined: 29th Apr 2008
Location: Turn around...
Posted: 25th May 2009 19:38
Thanks greatly, just a small question, is there a way of limiting how far it goes, I think it's something like 100>x>1 Or something like that?

My site: www.skyknight.co.uk
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 25th May 2009 21:49
yes there is!



the minimum and maximum are variables, but you can also change them to values

Jasonorc
16
Years of Service
User Offline
Joined: 29th Apr 2008
Location: Turn around...
Posted: 26th May 2009 10:17
And the same for your full rotation one bobbel?

My site: www.skyknight.co.uk
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 26th May 2009 16:18 Edited at: 26th May 2009 16:19
you mean how high it can maximum be? or while rotating around a cube? for the height i think i now something, but i would let the rotation inlimited. actually the code is nearly the same as the zoom one, just with other variables:



what it does: first it saves the old Cam Y Position, then it moves the camera, and if it's out of its boundaries, it resets it to its old position

and about the maximum zoom code, i changed it a little bit so it won't lock up:



what it does: it increases the variable CamDist# every loop the amount of the distance scrolled divided by 5. then, if its more than 1000, its resetted to 1000. if its more than -1000, its resetted to -1000. you can play with the varables to find yours. i wasn;t sure if you already had done this, but i thought you never know

Jasonorc
16
Years of Service
User Offline
Joined: 29th Apr 2008
Location: Turn around...
Posted: 27th May 2009 11:32
Hi bobbel, thats brillaint, thankyou.

you've become an amazing contributor to the site in the tiny time that you've been here, well done.

My site: www.skyknight.co.uk
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 27th May 2009 17:46
Np. just hyperactivity, that all

Login to post a reply

Server time is: 2024-11-25 06:25:26
Your offset time is: 2024-11-25 06:25:26