Attempting a tile based game...

Get help using Construct 2

Post » Wed Oct 08, 2014 9:55 am

I'm doing a top down RPG sandbox game, and wanted a little direction before getting too deep.

I would like each part of the ground (a solid color) to be able to be set to other things. Would Tilemap be the best bet for this method? As in making one tilemap with all the possibilities that it could change into. For example, when hoeing, change it to the sprite of the a dug out hole or the start of a garden. Would this be the best method?
B
25
S
6
G
6
Posts: 262
Reputation: 3,690

Post » Wed Oct 08, 2014 10:46 am

In short yes I would think so :D

However when using tilemaps you have to take into account if things you want to add are bigger than the tile size, then it can start to become a bit difficult, as you would have to split the objects up in several tiles and make sure that they are loaded correctly. Meaning that they doesn't suddenly overlap other objects that they shouldn't. However if you plan on making a big game, then I would go for it anyway. If you plan on the player not being able to do a lot of things at the same time, for instant dig 1000 holes in the ground, then a mixture might be easier. So the background is a tilemap, but holes etc are just sprites added on top.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Wed Oct 08, 2014 10:56 am

Yeah, I just want to make sure everything lines up properly. I was thinking I should find a way to determine which 32x32 square my character is standing in, that way I can specify where to place the "changed" block. I might find myself with 32x32 background tiles, and change them as the player uses said tile.

I'm open to other options, too. I'm not wanting to get too complicated, as I like clean code. :)
B
25
S
6
G
6
Posts: 262
Reputation: 3,690

Post » Wed Oct 08, 2014 12:12 pm

roracle wrote:Yeah, I just want to make sure everything lines up properly. I was thinking I should find a way to determine which 32x32 square my character is standing in, that way I can specify where to place the "changed" block. I might find myself with 32x32 background tiles, and change them as the player uses said tile.

I'm open to other options, too. I'm not wanting to get too complicated, as I like clean code.


Lucky its fairly easy to work with tilemap, here are some tips to get you started :)

Image

First thing is to keep track of tiles, since C2 doesn't show the tiles for you, adding a functionality that will always show this based on the mouse position is very helpful (The purple square is the mouse position). And in a lot of cases when working with tilemaps I personally find it a lot easier to work with the tile index rather than X,Y coordinates as it can be difficult to see what tile you are working with. So storing the converted mouse X,Y position in a variable can be useful, I would normally store these in a Game_controller sprite rather than as global variables, but either way will work. Storing these values can make it easier if you need to select tiles, as in the second event I use these variable to set the target tile for the green sprite or if you imagine that you want to check if there is a certain thing on a given tile.

In the last event I store the units position in two variables.
Tile_X and Tile_Y and you just have to make sure that these are always kept up to date and then you can use these whenever you need to check if a unit might be overlapping something on a tile etc.

And I would add such conversion to all objects in your game, so you can just do a Object1.Tile_X = Object2.Tile_X and so on.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Wed Oct 08, 2014 2:13 pm

Hey the one for tracking works great for what I'm doing! Thank you! Good thing I have only a few things going right now, it will be easy to implement. BTW: you're saying each object I make, I should have a variable defining its location? This makes sense, because I'm using UO as my base idea, and each item in the game has TONS of properties. I don't intend on making it as complicated but I'm trying at least for detail. So this method makes sense in that aspect.

EDIT! I need to know something! If I'm comparing a tile, how do I compare it to "empty"? I read in one thread the tilemap is considered empty, so comparing it to "0" will assume the first tile in the tilemap, but not as an empty space.

Edit 2: I just used "-1" as my variable and it worked! :)
B
25
S
6
G
6
Posts: 262
Reputation: 3,690

Post » Fri Oct 10, 2014 12:23 am

nimos100 wrote:
roracle wrote:Yeah, I just want to make sure everything lines up properly. I was thinking I should find a way to determine which 32x32 square my character is standing in, that way I can specify where to place the "changed" block. I might find myself with 32x32 background tiles, and change them as the player uses said tile.

I'm open to other options, too. I'm not wanting to get too complicated, as I like clean code.


Lucky its fairly easy to work with tilemap, here are some tips to get you started :)

Image

First thing is to keep track of tiles, since C2 doesn't show the tiles for you, adding a functionality that will always show this based on the mouse position is very helpful (The purple square is the mouse position). And in a lot of cases when working with tilemaps I personally find it a lot easier to work with the tile index rather than X,Y coordinates as it can be difficult to see what tile you are working with. So storing the converted mouse X,Y position in a variable can be useful, I would normally store these in a Game_controller sprite rather than as global variables, but either way will work. Storing these values can make it easier if you need to select tiles, as in the second event I use these variable to set the target tile for the green sprite or if you imagine that you want to check if there is a certain thing on a given tile.

In the last event I store the units position in two variables.
Tile_X and Tile_Y and you just have to make sure that these are always kept up to date and then you can use these whenever you need to check if a unit might be overlapping something on a tile etc.

And I would add such conversion to all objects in your game, so you can just do a Object1.Tile_X = Object2.Tile_X and so on.


@nimos100 Thanks for the help. I keep looking for My Little Golden Book of Tilemaps and this fills in one page. Yay!
B
6
Posts: 5
Reputation: 270


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest