Creating a TileMap Engine with Construct 2...

0 favourites
  • 10 posts
From the Asset Store
75 vehicle sound effects, from real looping car engines to jet aircraft and sci-fi engines.
  • So I'm trying to create a 48x48 TileMap engine for this Zelda fangame I'm working on. I would create a large string of data like "00,01,00,05,02,03,..." to indicate what kind of tile is being generated from the relative map coordinates that my player is in, from left to right. (e.g. I am in 1,1 and I move left one screen. Now I'm in 0,1)

    I am trying to generate the rooms (up/down/left/right, or if possible all 8 screens within the room range) to my player's relative map coordinates, so the person playing won't see the levels being generated. Very similar to this:

    <img src="http://morphcat.de/blog/img/0008-1.gif" border="0" />

    .... except it generates only the rooms around the player.

    I also wanted to delete the rooms that are too far away, so that the game runs at a constant speed.

    I found out that I can manually edit the c2runtime.js so that it can load my AJAX links from the current directory "./" (by the way, is it possible to load a page named after a variable?). I can use that to load a CSV and store information as variables.

    Each room is 9x8 tiles large (48x48 tiles), and I want to define a 2-digit number to indicate what each tile is.

    Now here's the problem. I am not sure exactly how I would go about breaking each piece of the huge CSV string and store them into separate variables and continue to do so until I hit a specific amount of characters. I've tried storing the entire thing as a huge variable, but that didn't work as well as I'd hoped...

    Does anyone here happen to know how to break up the huge CSV data string and store it into separate variables?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hopefully it will be relevant to the question:

    Rexrainbow has provided a csv custom plugin that handles import/export if I'm not mistaken, it might be worth checking it out, and/or quickly scanning the custom plugin list for similar/complementary plugins.

  • word of advice: you better use the canvas plugin too, 'cause your game will cry for fps when you'll spawn a whole lot of level tiles. you should make a special object travel the layout to draw the missing part by displaying the proper image and pasting it on the canvas.

  • word of advice: you better use the canvas plugin too, 'cause your game will cry for fps when you'll spawn a whole lot of level tiles. you should make a special object travel the layout to draw the missing part by displaying the proper image and pasting it on the canvas.

    I'm not sure if I will be able to utilize that method, because the objects I'm creating are actually supposed to interact with the player. These aren't just obstacles like spikes and solid walls, either. I planned on inserting enemy objects too.

    If it helps, I originally planned to set up the first room and the 4 rooms adjacent to it within the layout itself. Anything after that would render the rooms around the one you're in, skipping the one you came from. 3 rooms total are being rendered at the same time.

    And now I'm stuck with another problem. If I move one screen vertically and then one screen horizontally, I would theoretically end up having overlaying issues. I also don't want to delete the objects until I'm at least 2 screens vertically and/or horizontally from it. I wonder if there are methods of working around this, because I think I may be at a loss with this TileMap idea.. :(

  • An array of data should work just fine.

    Perhaps an additional array

    with symbols representing an object or npcs.

    Every so often update the map, delete objects that aren't in view of the camera/player. Have the view be a little larger than what you will actually display on screen.

  • Every so often update the map, delete objects that aren't in view of the camera/player. Have the view be a little larger than what you will actually display on screen.

    That's exactly what I'm trying to do. It should take at least two rooms before it's allowed to respawn through, and having a unique variable for every single room could get horrendous. I just can't find the right time to update the screens without both making it subtle and without deleting nearby enemies so they respawn quicker than they should.

    Again, my current idea is to generate the rooms up/down/left/right from the current screen, and not create the room you came from. The problem with this method is that if you backtrack, the rooms adjacent to you will respawn anyways.

    Oh and if it helps, I'll restate it again. It's a Zelda-esque scrolling engine.

    EDIT: Ah nevermind. I just figured out I can just set a second variable that ignores the creation code for each individual room if the room you came from is equal to the room you're going to.

  • The Canvas Plug can also act as an array.

    rgbaAt(x,y)

  • I feel like I'm misunderstanding the uses of Canvas. From what I can tell, Canvas takes everything under it and changes it into a large image? If it takes all of the tiles and merges them into a large image, how is it supposed to interact with my player properly?

  • when I suggested canvas, I though you were also using your tileMap for background stuff like in niffla's knytt and knytt stories.

    So I thought you will spawn an entire grid of sprite.

    But as you said earlier, you just want to spawn some platform, ennemies and pickup. For that you shouldn't use canvas.

    Also newt was just suggesting using an image based map system... (it's one of his recurring obsession :D)

  • Well you can use the canvas object in many different ways. Not only can you paste objects into it, but you can draw, and retrieve data from it.

    If you were to treat one like a mini map, you could have an image already loaded into the object, and get positions from that. Like if rgbaAt(x,y)= black create object walltile at x,y*tile size.

    You could use this to tell where your players "quadrant" currently is, and create objects accordingly.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)