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

Author
Message
Mikko
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: Finland
Posted: 24th Mar 2003 23:21
Here is a short function included in one example.

I used distance algorithm and basic sorting in it.

You can select any kind of objects
with it .

It works in any camera angle.

Move the camera with arrowkeys.

give it a try

http://koti.mbnet.fi/ketonen/db/functions/mouse3d.htm

Mikko
andrew11
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 25th Mar 2003 05:42
That's really cool

I was thinking of creating something like that mysef. Mind if I use it for my own game? I'll put you in the credits

"All programmers are playwrights and all computers are lousy actors." -Anon.

<--- Just.. changed.. my. avatar... Ouch, my head!
Mikko
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: Finland
Posted: 26th Mar 2003 18:25
Great, that you like it.

And yes, you can. Me in the credits sounds fine

Mikko
Juso
21
Years of Service
User Offline
Joined: 23rd Sep 2002
Location: Finland
Posted: 27th Mar 2003 00:22
Hi Mikko and andrew11, you can replace the function with this:

function obj2mous(first,last)
mx=mousex():my=mousey()
neardist#=10000
for f=first to last
ox=OBJECT SCREEN X(f): oy=OBJECT SCREEN y(f)
dist#=sqrt((mx-ox)^2+(my-oy)^2)
if dist#<neardist# then nearest=f:neardist#=dist#
next f
endfunction nearest

Then you need no array at all.
Mikko
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: Finland
Posted: 28th Mar 2003 11:17
Yes ,you are right Juso.

The array is there only for the function to
work in all cases.

I mean, that if someone uses this function in
one game, he/she doesn't have to alter the
function itself.

It's like "all purpose" function

BTW. Function works in DB too.

(I have also another function . It can be used with
the same ease to know which object is nearest to selected
object in 3d-space. Using these two functions together you can
push objects with another objects and so on. )

Mikko
Dostej
21
Years of Service
User Offline
Joined: 21st Jan 2003
Location: Switzerland
Posted: 1st May 2003 19:47
Does it also work with a viewport?

n3t3r453r
21
Years of Service
User Offline
Joined: 8th Nov 2002
Location: Russia
Posted: 2nd May 2003 18:45
You still use such algorithms???

visit www.gamedev.net.

I'd like to change the world, but God doesn't want to give me sources!
Ocean Runner
20
Years of Service
User Offline
Joined: 18th May 2003
Location: United States
Posted: 21st May 2003 05:51
doesn't work in DBC!

indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 21st May 2003 09:53
here is a better version for the Classic users.

tested on v113

see code button below

indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 21st May 2003 09:55
note pro users will have to adjust the set object flags as DBC and DBP have some reversed flag conditions compared to each other.

SET OBJECT works in DBC but its pro counterparts that isolate each set object flag into its own command are not classic syntax.

Login to post a reply

Server time is: 2024-05-06 11:33:00
Your offset time is: 2024-05-06 11:33:00