Tsardall's Forum Posts

  • So I already made something similar but with sprites but couldn't figure out how to do it with tiles.

    In the image below when the button is active, the player can only paint the "tiles" that are directly adjacent to the blue "tiles".

    Is it possible to do the same with only a tilemap or will I also need other objects like an array?

    Thank you,

    Tagged:

  • I got this to work:

    It just change the tiles colour if the value of the array=0 at same tile position in the array using positiontotileX(mouse.x)&positiontotiley(mouse.y) And its bugged when condition on "every tick" it just colours a big square in the tilemap.

    But now I would need to do the contrary, set an array value when tile=0 (colour)

    And do I have to always rely on a specific position in this case (mouse.x,y) to change an array value? I would like to do like:at (tile.x,y) which i can’t figure out how.

    Also any tutorials online on how to use tilemaps with arrays? please

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I can<t do all tiles manually, I would need to do something like this: Everywhere where there's a white tile, set the value of the array to 1. (at the same coodinate in the array for each)

    Is there a way to simply do: whatever the position if tile white set value of the array to 1 at the same position in the array?

    I tried to loop each tile to check if they are white but this just takes too much power, so I have to use specific coordinate like (mouse.x;mous.y) and convert it to tileposition which I won't be able to rely on later in my project.

  • Thanks a lot for the help, I understand It better now. 🙏

  • I tried doing something that would pick up the position of each tiles at start of the layout.(doing it manually would be way too long) but it doesnt work, only the "set size of the array" event works. I think there's something wrong with my loops too.

    I have never worked with arrays before and tilemaps so I am completly lost.

  • My tilemap is iregular its not a 100x100 (like the picture above), Also are there tutorial about using arrays with tilemaps, i haven<t found any and it owuld really help.

    Ok thank you a lot, I will try something again.

  • There are several ways to do this.

    How many values do you need to store for each tile? Will the set of values be the same for all tiles, or different? For example, water tiles will have "depth" value, ground tiles will have "walk_speed" and "solid" values etc.

    Will there be many tiles without any values? You can think of a Tilemap as a 2D array, which stores tile type (ground, sand, water, rock). So you don't have to store this info in the array.

    Do you need to store the array with all these values in the project, or will it be randomly generated in runtime?

    1. I would need to store about 4 variables For each tiles that would change independently during the game on certain condition

    2.The values won’t be random

    I want to do something line this for the tiles variable:

    (Ownership: unowned or country1 or country2)

    (State: Incorporated or non-incorporated)

    (And finally a variable that update if for exemple a blue tile is near an other tile mark as Unowned)

    🙏

    Also if I set an array the same size if the tilemap and sub-divide it by each tiles will it store these values as if they where « in »the tiles?

  • I've had trouble using arrays before and found a lot of information on how to use it with a Tilemap and what it can do.

    I think it can store information relating to a position? But that's about it.

    Could a array make each tile act as a unique object when it comes to information? For example, can each tiles store separate variables?

    If yes, how can I set an array with my tilemap if the tiles are not place uniformly:

    Thank you,

  • I have tried too and the CPU usage go hight when the camera is moving (in my test the fps where still very good despite the CPU struggling for some reasons)

    Also in debug mod without deleting/diseabling anything, its says that the draw calls take up 25% of the CPU but when removing literally everything else but the sprites, the draw calls are now taking 95% and the CPU is still used too 100%. So I am not sure whats the issue.

  • They have line of sight behaviour but I dont think its checking every thicks unless I made a mistake. Also I don t think a tilemap would work because its 1 object. I need all the sprite or tiles of the map to old informations like variables.

    Also I am using a 3d camera that moves could it change anything about the sprites updating?

  • I thought it was the line of sight behaviour that was causing the lag thats why I wanted an alternative to it,but now it’s probably that there’s to much sprite.

    I dont know I could change that since I want to be able to paint the map and larger sprite wouldn t look good.

    EXEMPLE:

    *Every cells are 5x5 pixels of resolution

  • It lags all the time and i think its only checking around the sprites having the “france” variable.

    So the issue really is the massive amount of sprite? Setting them to be non-visible outside the screen doesn’t change anything (it takes even more CPU) and changing the sprites for SVG image doesnt fix anything about lag.

    Also I can’t really reduce the amount of sprite because together they form the a map that change colour depending on the variable and each hold information so a tile map wont work since its only 1 object.

    Doesn’t it mean that a project like this one can t be done efficiently in Construct3?

  • Its only an event to activate what's below when the button is clicked.

    It's in a group. But i think the lag is caused because I have too much objectes (40'000 sprites)

  • The line of sight can see up to 8 pixel, so by checking if there's any sprite in its reach I can also insure that they are all within 8 pixel. Thats how I calculate the distance.

  • They are all the same sprite (but copied over) and they already change colour and variable when owned by any country via the eventsheets.

    Here's how it look:

    *Its only a small part of the map