• Post Reply Bookmark Topic Watch Topic
  • New Topic

move randomly an object and to find its position  RSS feed

 
sudharshiya mohan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have to move an object not necessary in graph. then i have to find whther it has crossed some area. help with some concepts
 
karl koch
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
uuhhh ehm... i did not understand your question.

do you want to drag around an object on the screen ?
take a look at MouseListener and MouseMotionListener. You can subscribe for events and are able to find out were the mouse pointer currently is. then you could check if the current point is in one of those regions you need to check.


greets

k
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A good first step is to define your terms.
 
sudharshiya mohan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me explain . i have to create a mobile node( it is enough to be a data structure) i will first assign a location(x,y) .then randomly i have to move the mobile node to (x+dx,y+dy) in any direction. a sniffer like datastructure will detect the movement and say whether mobile node has crossed its signal range. how shall i proceed. i need some basic concept. it is not neccesary to show graphically.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should probably start with Math.random() or the Random class from the API to generate random values for dx and dy.

Layne
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!