Large Arrays in NWJS

0 favourites
  • 3 posts
  • Hello! I'm trying to develop a game in which I need to create a destructible terrain... I started using an array (3500x2500) as a way to control each and every single pixel at the screen to check if the terrain was or wasn't available for collision. While previewing it on my browser (Waterfox), everything was working fine. My problem is that after exporting to NWJS, the game closes everytime I try to load the layout. After running a few tests, I found out that it is crashing when trying to resize the array. I'm not sure why it is happening...

    Do you have any other idea on how can I store 3500x2500 values, without crashing the NWJS?

    Thank you so much!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Wait, are you using actual pixel sized sprites or a tilemap with pixel sized tiles? Did you test how fast the collisions work with it? It sounds like it would run rather slow.

    At any rate I have bad news, there is an upper limit on how much total array size the engine can handle. I once reached it when experimenting with inifinite world generation.

    The workaround in nwjs I found was to offload avery part of the array that is not used by the visible area into as a json string to custom text files files using nwjs file saving to disk function. I would load them back into a smaller visible area array when needed. That however required setting up a filenaming system so the game knew what to load at what coordinates.

  • I'm using a Canvas to draw the background... The collisions are working fast enough.. I can keep 60 fps for most of the time.

    Saving the info into a file sounds like a great idea... I'm gonna try it!

    The only solution I had found so far was to reduce the resolution of the screen... I was able to get it to work with a 2300x1500 layout.

    Thank you!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)