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 / Move object with mouse ?

Author
Message
jojoofu
17
Years of Service
User Offline
Joined: 23rd Feb 2009
Location: Where ever Carmen Sandiego is
Posted: 28th Mar 2012 19:29
I'm trying to move an object using the mouse pointer. Basically I want to have the selected object follow mouse pointer on the screen then move to the point where the mouse pointer intersects with the closet object on the screen. Basically this would be like placing a building in a RTS game such as Red Alert , except for using the mouse not the arrow keys.

Love Chris,
http://www.firstdaygaming.com/

" The best slaves are the ones who think they are free. "
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 28th Mar 2012 22:18
how 'bout a little searhing, that questions has been asked and answered numerous times before

http://forum.thegamecreators.com/?m=forum_view&t=88953&b=6

thecartm
14
Years of Service
User Offline
Joined: 30th Mar 2012
Location: In your closet, hiding....
Posted: 31st Mar 2012 00:01
When it clicks test if the object itself was clicked. Test the movement of the mouse and mimic it.

Hah, my signature is meaningless.
Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 31st Mar 2012 13:15 Edited at: 31st Mar 2012 13:17
I've put together a quick example for you here. Use W, A, S + D to move the camera and use the mouse to place objects. Hopefully this will give you a good starting point. Let me know if you need any more info.



[Edit]Changed my double slash comments to rem comments for syntax highlighting.[/Edit]

jojoofu
17
Years of Service
User Offline
Joined: 23rd Feb 2009
Location: Where ever Carmen Sandiego is
Posted: 7th Apr 2012 17:12
The project doesn't run andrew throws 2 errors. One on shadowing and the other on exclude object.

" The best slaves are the ones who think they are free. "
jojoofu
17
Years of Service
User Offline
Joined: 23rd Feb 2009
Location: Where ever Carmen Sandiego is
Posted: 7th Apr 2012 18:35
Ok , I figured and it's insanely simple.

Just call the mouse pick method.

Then position the object to the cameras position + the picks position.

done

" The best slaves are the ones who think they are free. "
Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 8th Apr 2012 12:06
Sorry, I can't think why it wouldn't run...definitely runs fine here or I wouldn't have posted it! Maybe it is different version of DarkBASIC Pro? Either way, you obviously managed to grab the key point of the example so I'm glad you're sorted.


Previously TEH_CODERER.

Login to post a reply

Server time is: 2026-07-10 13:45:22
Your offset time is: 2026-07-10 13:45:22