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 / Simple Problem - Object Y Rotation Controlled By Mouse

Author
Message
Deleted
20
Years of Service
User Offline
Joined: 26th May 2004
Location:
Posted: 10th Jul 2004 22:35
This is a very simple question (I think/hope)

I want the rotation of this box to be controlled by the mouse - when the left mouse button is held down the box moves forward. Simple.

I have succeeded in doing such a thing - BUT - if you move the mouse cursor to the far left/right side of the screen the box will stop rotating because mousex() can't get any higher/lower.

Is there any way to allow the box to continue to rotate? Perhaps by centering the mouse cursor again?

Totally
<img src="http://www.geocities.com/preview_ff/wedge.jpg">
Deleted
20
Years of Service
User Offline
Joined: 26th May 2004
Location:
Posted: 10th Jul 2004 22:39
Oh. Sorry. Forgot to mention. I'm using DBP

Totally
<img src="http://www.geocities.com/preview_ff/wedge.jpg">
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 10th Jul 2004 22:47
There ye go:


Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 10th Jul 2004 22:51 Edited at: 10th Jul 2004 22:57
Have you tried something like this?


[edit] I didn't read it correctly the first time Red_Eye's is what you need I think. Re-edited my code to make the box rotate even if the mousebutton is not clicked.

Deleted
20
Years of Service
User Offline
Joined: 26th May 2004
Location:
Posted: 10th Jul 2004 22:56
Thanks for the help but it didn't work I open DBP and whacked your source code in and ran it. But the block didn't rotate with mousex().

I guess I couldn't have made it clear what my problem was...

I have a box which rotate with mousex() and moves forward with mouseclick. However if the mouse cursor hits the side of the screen (I'll use the left side as an example) the mousex() value can no continue to get lower as it is already equal to 0 and cannot move past the edge of the screen and so the box cannot rotate any further in that direction.

That wrapvalue function looks interesting - could you perhaps explain it?

Totally
[img]"http://www.geocities.com/preview_ff/wedge.jpg"[/img]
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 10th Jul 2004 22:58 Edited at: 10th Jul 2004 23:00
Look at my snippet above. I edited it. ReD_eYe's only rotates the cube when you click the mouse button.

[edit]
Quote: "WRAPVALUE
This command will return a value that does not exceed the range of 0 to 360. Where a value is specified that exceeds this range, the command will wrap the value around to bring it back within the range. This command is best understood by using the number of a clock as a mental picture of how a number wraps. If the clock hand points to 11 and is then advanced 2 hours, the number has to wrap from 12 around to 1 to keep the cycle going. The parameter should be specified using a real number.

SYNTAX
Return Float=WRAPVALUE(Angle Value)
"


From the help files. Good luck.

Deleted
20
Years of Service
User Offline
Joined: 26th May 2004
Location:
Posted: 10th Jul 2004 23:02
Wow. Thanks that worked perfectly. Thanks.

Totally
[img]"http://www.geocities.com/preview_ff/wedge.jpg"[/img]

Login to post a reply

Server time is: 2024-11-27 00:44:47
Your offset time is: 2024-11-27 00:44:47