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.

Code Snippets / Move Objects With Mouse On Grid (GMS and S-GMS)

Author
Message
RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 23rd Apr 2005 09:25 Edited at: 23rd Apr 2005 09:28
GMS and S-GMS Functions for Dark Basic Pro
Move objects with the mouse, in two different ways!
Created by RUCCUS


GMS (Grid Movement System)

This function will move an object around the map with the mouse using a 2 line formula!

GMS Code:



S-GMS (Snap-To-Grid Movement System)

This function get's the object you click and moves it on a grid, snapping the object to different grid sections as you move your mouse.

S-GMS Code (With Media):



S-GMS Code (Without Media):



Im not sure if the functions work in Dark Basic, I dont have it so I cant test it but it should work. If someone could test it in Dark Basic and get back to me on the forums with an answer I'd greatly appretiate it.

Comments, Critisism and Questions are encouraged. If I see some good questions Ill make a small FAQ in this post for quick reference. Ill try and answer them all as soon as possible.

Goodluck with the code, no credit is required but as always a mention of my name and a link to my site; www.RUCCUS.net, is always appretiated.

<Edit> As usual the damn attachment button isn't working, so here's the pic:


Picture here: http://i3.photobucket.com/albums/y84/RUCCUS/GRID.bmp

- The Forum Ninja, RUCCUS.

RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 14th May 2005 06:22
Lol its funny I've seen like 30 requests for this and when I finally post it nobody needs it.

RiiDii
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 14th May 2005 12:33
I have seen a lot of requests for this sort of thing too. What will happen is someone will start a new thread and ask how to do this sort of thing

It's bit touchy if the mouse moves too fast. Also, does it work well if the camera angles are offset? You might want to check out this command: Pick Object

It is perfect for this kind of task. Not only will it tell you if the mouse is over an object, but it also returns vector information about the object; importantly the distance to the collision point using Get Pick Distance. Or you can get the 3D world coordinates of the collision using Get Pick Vector X/Y/Z.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 14th May 2005 13:01
Lol dont mention pick object to me, I realized there was such a function AFTER I wrote this code and got severely pissed lol. Either way it's here, if people wana' use it then perfect. Also, since pick object sint in DBC I think this works in DBC, not positive though.

RiiDii
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 14th May 2005 13:22
Quote: "I think this works in DBC, not positive though."

Good point. It probably does.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Robot
20
Years of Service
User Offline
Joined: 27th May 2004
Location:
Posted: 25th May 2005 02:06
Quote: "Quote: "I think this works in DBC, not positive though.""


afraid not.

The happenings of tommorow are behind us now

Login to post a reply

Server time is: 2025-05-16 23:32:15
Your offset time is: 2025-05-16 23:32:15