Large Arrays in NWJS

Get help using Construct 2

Post » Tue Mar 07, 2017 11:40 pm

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!
B
12
S
5
G
1
Posts: 13
Reputation: 1,426

Post » Wed Mar 08, 2017 9:34 am

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.
B
15
S
6
Posts: 85
Reputation: 1,195

Post » Wed Mar 08, 2017 7:58 pm

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!
B
12
S
5
G
1
Posts: 13
Reputation: 1,426


Return to How do I....?

Who is online

Users browsing this forum: blue visionary and 4 guests