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 / Scrolling using Mouse Problem

Author
Message
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 28th Jun 2006 22:00
I am trying to create a function so that when the mouse pointer hits the edge of the screen the camera moves so that you can scroll over a landscape.
I am experimenting with just one screen edge first and I have the following so far:

CameraXpos#=0
AcameraMoving=0

position camera 0,0,-10
point camera 0,0,0

mouseposx#=mousex()
If mouseposx#=0 then AcameraMoving=MoveCamera(0.1,5)
Rem ie if mouse is at 0 on x axis then move camera +5 at speed 0.1

function MoveCamera(speed#,limit#)
If CameraXpos#^2>limit#^2
exitfunction 0
else
CameraXpos#=CameraXpos#+speed#
position camera CameraXpos#,0,-10
endif
endfunction 1

However, this only makes the camera jump +0.1 in distance when mouse gets to left edge of screen and then wont move anymore, neither will it make it move again when you position mouse at edge. Not the scroll effect I was looking for!
Can anyone help or is there a function already made anywhere on here?
Twu Kai
19
Years of Service
User Offline
Joined: 2nd Oct 2005
Location:
Posted: 29th Jun 2006 01:14 Edited at: 29th Jun 2006 01:15
Well, I can't quite figure out your program, but I can give you some code to do it:



Hope it helps!

When you need to move on the z axis and the other x direction, just check for where the mouse is, and use the "camera position [insert axis here](0)+[or -]0.1"!

Felthenra-Cat. Hiss your way to freedom.
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 29th Jun 2006 20:12
Yes thanks, that would work but it is a loop and as I've found out previously a loop within the main loop stops the main loop working until the other loop finishes. (If I understand correctly!)

I need a function I think? Anyone?
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 29th Jun 2006 20:48
how about:



Then just before your sync in your main loop,
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 29th Jun 2006 21:18
Just a few little errors in that code but yes that works, Thanks!

Why didn't my original code work? I tried modifying a function you helped me with earlier DAD.

Also, I now need to set a limit that you can scroll to on each axis, otherwise it is infinite. That was what I was trying to do in my original code
LordMaud
19
Years of Service
User Offline
Joined: 30th Jun 2005
Location:
Posted: 29th Jun 2006 21:25
[quote]
Why didn't my original code work?[quote]

Assuming that what you put in your post was ALL you had, then I THINK its because there is no loop; it does it once then reaches the end of the programme. Try (Untested


However, if you did have that in your loop, then I cant help
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 29th Jun 2006 21:56
No I had it in a loop, just didnt bother putting it in my post.

To stop scrolling I have tried both the following, but neither works, I am confused!!!

1. just before sync put:
If camera position x()^2=<4 then scroll screen

2. inside function
If camera position x()^2=>4 then exitfunction
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 29th Jun 2006 22:42
Try this!

Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 30th Jun 2006 23:52
Ah yes I see, will get the hang of these functions soon I hope!
Thanks!

Login to post a reply

Server time is: 2024-11-27 15:39:57
Your offset time is: 2024-11-27 15:39:57