Roy2's Recent Forum Activity

  • Hi. I've been working on a tilemining game, and i've come across this issue. This game uses big arrays and tilemaps, but if i have understood correctly this shouldn't be a big problem unless the tile image is really big.

    When you run this capx, it generates a big tilemap choosing between two kind of tiles on a layout, save it as a json string, and loads it in the next layout. Running it on firefox is fine, but on NW.js and chrome it crashes. If you change the choose condition and just put one kind of a tile, it works fine.

    https://drive.google.com/open?id=0B5bQK ... DlXcU9fQXc

    I guess there is something wrong with using those big arrays or tilemaps, because when deleting one of those that are left on the project, it runs ok. So i guess that this is not a bug, and probably there is something that i've been doing wrong, but i can't find it. Loading it tile by tile on just one layout works fine.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If some javascript takes too long to run the browser will give you an option to stop it. As long as it wasn't an infinite loop in your code causing it you can let it continue an it will complete. AKA it wasn't a crash.

    That said, saving a tilemap of that size may be the reason it takes so long.

    Well, on nw.js it just closes, and in chrome it says the page has an error. I have to try on firefox yet. It doesn't even try or take too much to display that error or close, it seems that it doesn't even tries.

    BTW, i have looked a lot of your examples on this site, and they have been really helpful. I really appreciate your work here.

    EDIT: well, it seems that the crash does not ocurrs when it saves, but when it tries to load it. Instant crash.

  • I'm having constant crashes when i try to save the state of at tilemap wich has 2300x2800 tiles. Could it be related to this?

  • How big?

    When I'm going between layouts (main map <-> sub maps) On leaving the layout I'm saving to a Dictionary:

    - Dictionary with all my variables

    - Array with player characters infos

    - Array with Inventory state

    - Array with NPCs

    - Array with NPCs that can be respawned

    - Array with keys used in game

    - 6 tilemaps - 4 different tilemap objects, each max 1920x1920 in size on layout

    and then on loading next layout I'm loading everything back from that dictionary - that is really 1 huge dictionary. And it takes max 3 seconds to save and load on my old Samsung Galaxy S3 mobile, on PC it's instant.

    So I don't know how big stuff you must have to tak a lot of time to save/load.

    2800x2300 tiles, 16 pixels for tile... 44800 x 36800. I guess that must be the reason of the crash.

  • Hi. I have a layout , which loads a tilemap tile by tile < copy those events to the next sheet

    That's the first thing i did, and it worked. But it takes a lot of time, and i want to separate the loading layout and the gameplay mechanics. Isn't it possible to save as json a really huge array or tilemap?

  • Here's array solution

    To save

    On key S pressed -> Array: Set value at 0 to Tilemap.AsJSON

    To load

    On key L pressed -> Tilemap: Set JSON string from Array.At(0)

    and that's it.

    Well, this definitively worked, but i have a new problem. My tilemap is 2800x2300 (yes, i know that's not a good idea) so when i try to save it, nw.js just closes.

  • I was doing almost that, saving a tilemap as json to dictionary or array, and then load it when I need it - on same or different layout, without any problems whatsoever (did not test with newest stable C2 version). So probably there is a problem in your events, cause I don't think Ashley changed something in tilemap recently.

    Can you explain me the exact process of it? I've tried with different approachs but i haven't done it yet.

  • Hi. I have a layout , which loads a tilemap tile by tile, and i want to store it to load it's state in the next layout.

    I've tried using the actions download, and load in the next layout, without any sucess. I've also tried to store in a text variable the tilemap.tilesJSON, and set the tilemap from it in the next layour, and didn't work.

    What i'm doing wrong? Thanks for your time.

  • A loop will start and finish in the same tick. If you don't get another tick, you won't get an update.

    You can use a counter variable to increment your for loop to break up your loop into multiple frames

    Lets say you need For Loop from 0 to 20000.

    CounterVariable=0

    You can do For Loop from CounterVariable*1000 to (CounterVariable*1000+999)

    CounterVariable<20

    Add another event after to increment CounterVariable by 1 while CounterVariable<20 (this should NOT be in the loop).

    This will break your 20000 interations into 20 ticks - 0 to 999, 1000 to 1999, 2000 to 2999, ect.

    Change the amount of iterations you want to process per frame for different resolutions of progress.

    I didn't thought that. Thanks a lot, i can't wait to implement it!

  • Hi. I have a very long for loop, with thousands of iterations, on a loading layout. I wanted every iteration to add 0.00001 (for example) to a variable, and then set the loading bar to that variable every iteration, so you can see how it loads. But it justs takes a while, and then set the bar to the final value without any increment in the iterations.

    I've read this tutorial scirra. com/tutorials/723/using-wait-in-loops , and tried using waits with loop index, or just setting the variable at 0.00001*loopindex, but it didn't work. Any tips on this? Thanks a lot.

  • Thanks a lot, that was what i was looking for!

  • There are a few ways to do this. Any LOS check will use collisions. You can use a raycast/LOS function to see if your LOS hits a solid part of your tilemap or not, and get the layout x/y position and use that to get tile index position and ID. This will only allow you two classes of specific tiles though - solid or not solid.

    A workaround is to layer some invisible tilemaps and paint solids where you want them to collide, then you can differentiate which tilemap you are hitting to do different actions.

    A third way is to draw invisible placeholder sprites with LOS behaviors. This way is probably the simplest if you don't have very complex shapes or very large maps for collisions, as you won't need a custom LOS function.

    For your array question, if you don't want to check every cell, use a nested System "For" loop.

    Conditions

    For "x" from a to b

    --- For "y" from a to b

    Expression

    Array.At(loopindex("x"),loopindex("y"))

    Edit: As for performance impact, I'm actually not sure if there is any different between this and for each x/y with additional conditions such as x>a and y<b or something like that. It is something you can test pretty quickly - if there is a noticeable difference let us know! If you can't tell if there is a difference, don't worry about it.

    Thanks a lot for your comment. I'm interested in doing it with just one tilemap that is solid. So, that "raycast/LOS function" you talk about is not the one that is implemented in behavior? I guess i can do it by myself, but it would save me some time if it was possible with the one implemented in construct 2.

Roy2's avatar

Roy2

Member since 3 Apr, 2016

None one is following Roy2 yet!

Trophy Case

  • 8-Year Club
  • Email Verified

Progress

9/44
How to earn trophies