My game uses a tilemap configured by a text file that is in my java project, the engine reads the text file, gets the information for the bricks, organises them by column for easy searching and then displays them.
To work out where the tiles need to be placed on the x-axis it starts with the first visible tile on the left and then places tiles until the last visible tiles on the right spacing them using this code:
1 2 3
| BufferedImage im = (BufferedImage) brickImages.get(0); imWidth = im.getWidth() -1; imHeight = im.getHeight(); |
You'll notice that I've had to offset the im.getWidth() variable by -1, without this my tiles were placed 1 pixel apart from each other on the x-axis and I cannot understand where this extra pixel is coming from?
Any takers?