Qbasicnews.com
April 03, 2020, 08:11:43 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: moving toward closer object  (Read 1355 times)
whitetiger0990
__/--\__
*****
Posts: 2964



WWW
« on: March 31, 2004, 07:27:42 PM »

how can i have the X move towards the closer * and not the other?

Code:
__________
_*       _
_        _
_        _
_        _
_        _
_X       _
_        _
_*       _
__________
Logged


[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #1 on: March 31, 2004, 07:31:23 PM »

What I would do is add up the x-distance and y-distance of each * from the X. Then whichever ones' sum is smaller, have it go after.
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
whitetiger0990
__/--\__
*****
Posts: 2964



WWW
« Reply #2 on: March 31, 2004, 07:41:26 PM »

thanks. i was talking with z!re and he helped too.
Logged


[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
Jofers
Been there, done that
*****
Posts: 1040



WWW
« Reply #3 on: March 31, 2004, 08:02:39 PM »

Code:
if (x - x1)^2 + (y- y1)^2 < (x - x2)^2 + (y - y2)^2 then go_to_n1 else go_to_n2


That is, if you needed it in a single line code Cheesy.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!