Log In  

How can I change map from a coordinate ? For example; There is a room with skeletons, and after killing skeletons I will go next to the door and I'll be teleported to room with spiders

P#35660 2017-01-14 08:00 ( Edited 2017-01-26 03:55)

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).

P#35685 2017-01-14 16:33 ( Edited 2017-01-14 21:33)

Sorry I was not clear enough. I mean there is a room with skeletons, and after killing skeletons I will go next to the door and I'll be teleported to room with spiders

P#35690 2017-01-14 17:25 ( Edited 2017-01-14 22:25)

Oh okay, well there is a few ways of doing this i'm sure but this is the simplest way I've found:

  1. 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).

  2. 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
  1. 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.

P#35744 2017-01-15 04:28 ( Edited 2017-01-15 09:28)

Thank you very much for your good explanation bro ! I am really appreciated :)

P#35746 2017-01-15 05:01 ( Edited 2017-01-15 10:01)

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. :)

P#35748 2017-01-15 05:37 ( Edited 2017-01-15 10:37)

I COULDNT DO IT PLEASE HELP ME GUYS !

P#36686 2017-01-25 22:55 ( Edited 2017-01-26 03:55)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 20:43:10 | 0.008s | Q:16