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 / Help with sprites detecting other sprites distance

Author
Message
Daniel wright 2311
User Banned
Posted: 3rd Jun 2012 05:02
Ok, so I am using this to time my 2d game sprites per level

if rightkey()=1 then gametime=gametime+1

if gametime=30 then show sprite 30:move sprite 30: so on and so forth

this is what I need. If sprite dectection (1,30)=1 then move sprite 1.it only moves if the first sprite is close to it. I can do this with objects easy,but with sprites? Im not to shure how.

Is there a easy way??


my signature keeps being erased by a mod So this is my new signature.
zeroSlave
17
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 3rd Jun 2012 05:38 Edited at: 3rd Jun 2012 06:22
You could find the distance using a function like this:

It won't tell if there is a collision, but it will return the distance in 2D space.

If you want a collision returned (0/1) by distance, you can use this:

Hope this helps!

Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.
Virtual Nomad
Moderator
20
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 3rd Jun 2012 05:54 Edited at: 3rd Jun 2012 05:55


oops: zero beat me to it

Virtual Nomad @ California, USA . DBPro V7.5
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
Daniel wright 2311
User Banned
Posted: 3rd Jun 2012 06:15
Thanks guys,this helped alot.

my signature keeps being erased by a mod So this is my new signature.

Login to post a reply

Server time is: 2026-07-07 22:23:31
Your offset time is: 2026-07-07 22:23:31