Creating a TileMap Engine with Construct 2...

Get help using Construct 2

Post » Sat Feb 11, 2012 7:42 pm

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:



.... 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?CrispyYoshi2012-02-11 19:56:03
B
5
G
1
Posts: 17
Reputation: 541

Post » Sat Feb 11, 2012 7:55 pm

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.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Sat Feb 11, 2012 9:38 pm

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.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Feb 12, 2012 9:57 am

[QUOTE=Yann] 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.[/QUOTE]
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.. :(
B
5
G
1
Posts: 17
Reputation: 541

Post » Sun Feb 12, 2012 10:04 am

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.
B
11
S
3
G
2
Posts: 110
Reputation: 2,410

Post » Sun Feb 12, 2012 7:11 pm

[QUOTE=Khaz]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. [/QUOTE]
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.CrispyYoshi2012-02-12 19:26:12
B
5
G
1
Posts: 17
Reputation: 541

Post » Sun Feb 12, 2012 7:23 pm

The Canvas Plug can also act as an array.
rgbaAt(x,y)
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Mon Feb 13, 2012 12:21 am

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?
B
5
G
1
Posts: 17
Reputation: 541

Post » Mon Feb 13, 2012 12:53 am

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)Yann2012-02-13 00:55:45
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Mon Feb 13, 2012 1:02 am

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.
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Next

Return to How do I....?

Who is online

Users browsing this forum: farfetchd83, makkancs and 25 guests