Hi again guys
I have been hard at work reading about tile map based games. I have managed to make a program that runs a movable sprite, around a tilemap created from a text file. This map is also set with collision detection on all tiles and the players sprite. My new project is to make this program have an RPG overhead view with X/Y scrolling as the player moves around. After many days of reading, I have found this is done by making a "camera" class that is used as a location reference for what tiles need to be drawn on screen. Now my problem is that I have not found a tutorial that has been able to explain this is a way I understand. I now this is a lot to ask on a forum, but if anyone has the time, I could really use a dumbed down version of this, or even if it is possible with my current code.
Hope someone can help Thanks.
//The Tile maker class that reads the text file map and eventually places the Chars in an array list.
//This is the game class
//This is the hero sprite class
//this is the class of one of the tiles
Sorry for all the code, Im not sure what people might want to see to be able to help me. If any one has any ideas ect please let me know
I am afraid that code is far too long for anybody to read. You will have to shorten it.
Why are you catching an ArrayOutOfBoundsException? That makes me wonder whether you know how to iterate an array.
When you add the blocks, you are going up to width - 1. How do you know that is the correct figure? How you you know the sizes of the boxes will ever add up to 1 less than the width of the display? You need to check that arithmetic very carefully.
I shall move this discussion to our games forum because that is far too large for “beginning”.
Its really simple, create a class called Camera with an x and y coordinate.
Draw your tiles at whatever coordinate, plus the x and y from the Camera class.
Then, intstead of changing the coordinates of the player sprite, set them to the center of the screen, and change the Camera coordinates instead. This will keep the player in the center, and the tiles will move instead.