nimos100's Forum Posts

  • What i mean is how to set a tile from another tile set..

    As littlestain says, each tile map are an its own object you can't copy a single tile (Graphic) from one to another, if that is what you are trying to do? What you can do is load another tile map when you need to, but it would be a bad approach I think compared to just adding the needed tiles to the map or simply let tiles from Ore map overwrite those on the main tile map.

  • Its a bit difficult to see what you are trying to do, but assume you want to use one tile map to spawn/change something on the other?

    You have to set up some condition for the Ore tile map and then change it for the Main tile. Here is a simple example:

    It uses two tile maps, one with orange boxes and one with green boxes. Based on where the orange boxes are placed I want to place green boxes on the right side of them.

    So the code:

    Using two loops to go through tile map 1, dividing the width and height with 50, because that's the size of the tiles will give me the tile index coordinate of the tile maps.

    Then checking whether the giving tile on tile map 1 = 0 and if that's the case I set the tile right of the selected tile on tile map 2 to a green square.

    You only really need to use positionToTile when you try to place a none tile map object, like a sprite on a tile map or if you want to track mouse position etc.

    If what you are trying is to get a random tile from your Ore map and use it for your main tile map.

    You just have to get the tile index using the same method I used above.

    Tilemap.width / Tile.width

    Tilemap.height / Tile.height

    And if you need to randomize it

    Random(Tilemap.width / Tile.width) etc.

  • Sorry this is a long post, but I felt like it may come in handy for some.

    Not a bad post, never thought about it like that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah you can do it with a loop. And just comparing what type of tile is influence and then based on that change them. There are no difference really whether its in a function or not. Except functions makes it easier to work with your project in general so a function whenever its possible

    Since you already know the starting point of which tiles to check meaning the impact tile X,Y and if you want the 8 tiles surrounding that you just have to start at that position (X,Y) - 1 so (X-1, Y-1). So you can do it like this:

    Since a tilemap will return -1 if there are no tile you can use that.

  • I think it will be easier for you to get help, if you add some explanation to your code. Tried downloading it and its pretty difficult to read and hard to know what problem you are referring to in the first place as Im not really sure what to look for. Maybe add some pictures to your post showing exactly what the problem is as I don't think a lot of people want to read code that have no explanation as it takes a long time.

  • Thanks nimos100,

    Is tile 12 a red one that replaces 9 tiles?

    Yes this example only use one tilemap.

    Without the Capx it im not 100% certain.

    But think the wait 3 seconds might be causing the problem as you destroy the bullet, but want to pass it to the function 3 seconds later, im not certain if that is working well or how it works, as i tend to avoid waits. But you have to remember that the rest of your program doesn't pause while this wait is going on. If i remember correct objects that are destroyed will be removed from the game at the next tick. Meaning that the bullet you are trying to pass to the function doesn't exist anymore when you actually need the tile position, and since you are waiting 3 seconds which is 180 ticks a lot of things can go on in the meantime. But anyway im not 100% certain, but regardless of that, i think such situations are best to be avoided because you lack overview of whats going on with waits in your programs.

    So i would use the bomb you create to spawn at the correct Tile (Where the bullet hit) and then add a timer behaviour to that and set it to 3 second, store the Tile position in the bomb or you can generate it later when the timer is up, then use the bomb tile position with the function. Meaning you pass the bomb coordinates to the function rather than the bullet. Think that will solve the problem.

    Otherwise try to add the capx.

  • Believe there is a plugin that might make you able to do this...(Not 100% sure though) might be for family related things.

    Otherwise you can add a variable to your object and instead of using UID you can just test vs this:

    Object.Name = <Something>

  • Think your problem is with the "Move" variable and the use of waits. My advice is to not use waits inside your code for something like this, because you can risk running into problems that are really difficult to debug, since its near impossible to figure out where in your code problems occur when you cant really track when thing triggers, you can run into some really annoying problems when you expand your games and they start to get more complicated. Personally I try to avoid any waits whenever possible, and only use them when a workaround for C2 requires it, or if the game actually need it for something, which is rarely the case.

    Anyway here is a modified version, which uses different speeds. I have added a Timer behaviour to the enemies instead of using waits, the benefit of that is that you can easy track where things go wrong as they trigger when the time is up. And the code inside them wont execute before that happens.

    CapX: https://dl.dropboxusercontent.com/u/109921357/Enemy_AI_help.capx

  • nimos100

    I am wondering how do we erase/change a range of tiles on a collision with a bullet. For instance, a bullet hits a tile, and then it should trigger a change of 8 tiles around the one that was hit. Let's say we erase those 9 tiles of tilemap 1 and replace them with tiles of tilemap 2 (the red one).

    I only managed to erase and set a tile that was hit , but no luck with erasing and setting neighboring tiles.

    Since you know which tile the hit takes place you can use this to change the surrounding tiles, simply by passing these coordinates to a function that will replace the correct tiles with the new ones, like this.

  • Sorry not quite what I was looking for, but I didnt explain myself very well. I mean could I go, say, +600 to Y axis and make it go there instantly, rather than a set coordinate with an X and Y value.

    Sorry not really sure what you mean? As Deathangel says you can just set the position and it will instantly go there as he have shown.

  • Depends how you want to make it.

    1. But you can either you is overlapping which will make you able to teleport the object as soon as they are overlapping each other.

    2. Use a distance check to see if the objects are within a certain range. Distance(Obj1.X, Obj1.Y, Obj2.X, Obj2_Y) will give you the distance between two object, you can then check if this is lower than a certain value and act on that.

    If you want to make it so it based on mouse you just switch one object with Mouse.X and Mouse.Y

  • Has anyone else noticed this / does anyone care / have any suggestions? My thoughts are that Chrome should be capable of simply demanding more CPU access when running a demanding game, so games like mine can run all of their data processing unimpeded. Perhaps a game maker could raise a flag to permit this to happen. Am I being naive - is Chrome's access to processor time controlled by Windows or can it demand more if it needs it.

    You have to be very careful how you test you game when it comes to CPU and FPS and what conclusions you draw from them.

    Using the debugger to validate CPU and FPS are extremely unreliable and depending on how you measure it you get different results, that you cant really use to a lot I think.

    Here is an example:

    All tests are made from the same place in the game.

    1. The first image shows the stats that I get using the Debugger in NW.js when the system tab is selected.

    2. Second image show how much this information changes simply by changing tab from system to a another tab.

    3. Is without debugger tracking the data in game and fits well with the second test when using debugger.

    So when testing performance you have to take into account which tab you have selected in the debugger. And at least in my opinion, doing any testing in the system tab is completely useless, because you cant use of any of the data you get there to anything, it doesn't reflect your game performance, but the game and the debugger performance combined.

  • An easy way to do it is to make an invisible "tracker" sprite so when your enemy have chosen a location to go to. You use the tracker to see if the location is free. Can do that by doing a "Tracker is overlapping enemy" and if that is true you make your newly created enemy find a new location etc.

    Or you can use the tracker to find a valid location and when it does you throw that to the newly created enemy.

  • It should work at least I don't experience problems with it

  • Or you can add additional keys to your code without having to change anything. Just add "On key press" separately of the ones you are already using as these will only trigger once automatically.