I'm not 100% sure what you mean but if you're talking about changing the Map/Tile co-ordinates into normal screen co-ordinates then I'm pretty sure this works nicely:
mapx=8 --Map Tile 8 Across mapy=8 --And 8 Down scrnx=mapx*8 --Each Tile Is 8x8 Pixels scrny=mapy*8 --So We Multiply By 8
In this example the screen co-ordinates would be (64,64).
Oh okay, well there is a few ways of doing this i'm sure but this is the simplest way I've found:
You create some variables to store the X and Y co-ord of the room you're currently drawing. This will be the top left corner tile of the room, e.g. if your room is in the top left corner on the Map then the co-ords will be (0, 0).
- When your players X co-ordinate goes over 128, set it back to 8 to make it look like they're walking into another room (You'll need to do this for the four different directions you can walk off of the screen). We also need to increment or decrease the map co-ordinates we created at the start depending on which direction we walked off of the screen. Here's a snippet of code as an example:
IF PLAYERX>120 THEN PLAYERX=8 MAPX+=1 END --RIGHT SIDE OF SCREEN IF PLAYERX<0 THEN PLAYERX=120 MAPX-=1 END --LEFT SIDE OF SCREEN IF PLAYERY>120 THEN PLAYERY=8 MAPY+=1 END --BOTTOM OF SCREEN IF PLAYERY<0 THEN PLAYERY=120 MAPY-=1 END --TOP OF SCREEN
- We then use the MAPX and MAPY variables at the top of the _DRAW() statement using MAP() to draw the correct part of the map to the screen:
MAP(MAPX*16,MAPY*16,0,0,16,16) --WE MULTIPLY BY 16 BECAUSE EACH ROOM IS 16X16 TILES
Make sure that you draw your rooms in the map editor to be able to use this.
Just ask if you're still confused, it took me a long time to wrap my head around this the first time. You can also check out my 'Space Game' and look at how I handle room changing in that.
No problemo! Also just as a side note, when you get stuck and need to post something to the BBS to get support, you can post it under the 'Support' tab and then the thread is able to be marked as 'Resolved' when you find the solution to your problem. That way others can see if you still need help with it or not. :)
[Please log in to post a comment]