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.

DarkBASIC Professional Discussion / Letting an object ex.cube to move on an axis while the mouse move on the specific axis

Author
Message
crazy kitty
16
Years of Service
User Offline
Joined: 1st Nov 2009
Location: MARS , eos
Posted: 12th Jul 2011 22:27 Edited at: 12th Jul 2011 22:29
Hi,

I wan't to let an object move on the x,z,y axis when the mouse is moving ,for example when the mouse moves over the x-axis the object will move also over the x axis.

And the same for the y and z axis.


position object 1,100,0,100

if mousemovex() = 1

move object 1,1
endif


And will someone tell me how to make a codesnippet
thanks !

I inhabit a nice forum
[href]uh what ?[/href]
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 12th Jul 2011 22:32
Replace

if mousemovex() = 1

with

if mousemovex() > 1

You use [code ] [ /code] brackets without the spaces.

crazy kitty
16
Years of Service
User Offline
Joined: 1st Nov 2009
Location: MARS , eos
Posted: 12th Jul 2011 22:47
now i have a problem

the cube goes to his first position after the cube moved x speed

I inhabit a nice forum
[href]uh what ?[/href]
29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 13th Jul 2011 01:28
Hi crazy kitty

I think the problem you are having is that the line "position object 1,100,0,100" is inside the main loop so the object will always just move back to this position when the mouse is not moving.

The mousemovex() and mousemovey() can be a little flaky as well which can be confusing.

I've knocked up a little demo to give you a basic idea.



If want to rotate the object the object so you can drive it around like a car have a look at the rotate, turn, pitch and roll object commands. If you want to have the camera follow the cube round, then either link the camera's position and facing to the cube or have a look at the set camera to follow command.
crazy kitty
16
Years of Service
User Offline
Joined: 1st Nov 2009
Location: MARS , eos
Posted: 13th Jul 2011 14:45
Thanks for the help !

i didn't noticed the object position command in the main loop !

And the thanks for the basic demo code it helped me also with other stuff !

I inhabit a nice forum
[href]uh what ?[/href]

Login to post a reply

Server time is: 2026-07-10 21:54:45
Your offset time is: 2026-07-10 21:54:45