java - Need Help Moving An Object -


I need ideas about moving an object (a circle that represents robots in my application) .

The surface going forward will include the tile of the labyrinthine image of 3 rows and 3 columns (shown in the array). All tiles are the same in sizes (160 x 160). The third row and the third column are the track rail on which the object should move forward. This means that the object (robot) can move horizontally (front and back) and vertical (top and bottom) in this situation tile [2] [2] (Please count on the top so that the top line is 1 and its The later version will be 1.) A crossing that will use the robot to change the vertical track rail or for the horizontal track rail.

My problem now is how to move the object to a specific tile after crossing. For example, in the robot tile the situation will be at [2] [1] and after the crossing is started, [1] [2] you want to go to the tile and then proceed further. Or it may be at [1] [2] and after crossing, want to move [2] [1] and then want to move forward.

How do I robot another tile from a tile? How can I reference a particular tile in BufferedImage that I can move the object. Everything I want is giving me the idea of ​​how I can do it.

Please take the time to do my first project, so please forgive me if my question is very preliminary. With your explanation and support, I will learn more about it.

Thank you very much.

To display your image, you need to understand the extent of the grid in which you want to Image I usually create two supporting methods, one to translate the grid coordinates into coordinates and other direction in the other direction. Private Point Convert GridTodish Plug (int x, int y) x * 160, y * 160); } Private Point Convert DisplayGrid (Int x, int y) Return {New Point (X / 160, Y / 160); }

Convert GridTodishPlay () will give you the upper left hand coordinates where you should draw your image.

For example:

  point point = convert grid todpleplay (2, 1); Graphics.drawImage (img, null, point.x, point.y)  

Drag your image to the grid (2, 1).

convertDoplayToGrid () will come in handy when you want to find out which mouse was clicked in the grid.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -