Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

6 years ago by Seeders

Hey everyone,
I'm running into a bit of an issue. I have a procedurally generated open world game in Impact, where i have a tile grid anywhere from 300x300 to 600x600. If I try to create a map much bigger, the browser starts throwing errors about an unresponsive script. If you click Wait, it might eventually finish, but this is not acceptable behavior. If I try to do 1000x1000, the browser will just crash completely (probably more of a memory issue though).

I'd like to do a lot of processing to set up the world. After generating the terrain, I want to spawn the monsters, towns, roads, destructibles, etc. Ideally I would use something like a webworker so that the browser doesn't lock up. However, I'm not sure if that is possible with Impact. It seems webworkers have no access to the DOM or the ig object.

I've been playing with spawning a few monsters each frame, but that leads to a longer set up time, and the world is completely empty for awhile.

Does anyone else have any other ideas?

6 years ago by Seeders

Another idea I've been kicking around is just storing a 3D array of symbols. For a 3x3 map, i could store an array at [0][0] to hold symbols representing the object that should spawn on that tile when it's chunk is loaded.

However, I fear this is going to lead to a constant spawning of objects which will slow the game down. Then again, object pooling could help a bit with that... Hard to say without trying, and I don't have pooling working at the moment because I'm on an older version of Impact.

6 years ago by drhayes

::clippy:: It looks like you're making Terraria. ::clippy::

Is server-side generation out of the picture?

You're going to end up sharding, so maybe pre-render a vaguely static "seed" shard that the player starts in? Maybe from some kind of easy probabilistic template that isn't as resource intensive as the "real" generation. You could then generate other stuff as they walk around.

Totally do generation in a web worker, but you'll have to sendMessage the results back to a listener that could spawn this stuff for you since workers don't have access to the browser. In Chrome, at least, they run in their own VM... if you're going to do that, might as well do server-side render of a new map maybe? Maybe stirring in some Drop tricks with swapping the map?

Are we talking overland, Zelda-style? You could pull some kind of zoning trick with your enemies so they don't follow the player around, makes transitioning from zone to zone easier since you can just throw the enemies away when they're not onscreen/in current zone?

If it's not being displayed on the screen or near to being displayed on the screen, don't use ig.Entity to store it; they're too heavy and eat cycles in update.

6 years ago by Seeders

The game is top down, and the map is divided into prerendered chunks.

Perhaps if i only spawn monsters in a chunk when it is nearby and hasnt been loaded before. i dont want never ending monsters where the player can run in circles and keep spawning monsters.

And yep, i am not storing the tiles or monsters in ig.game.entities. instead i use an AABB query to only update things nearby. Tiles dont need an update, they simply give info when requested.

I havent measured the time to generate map vs time to spawn the tiles. a webworker would only be useful for generating the terrain values, but ill have to test if its worth it.

6 years ago by Seeders

Here's a video for reference; https://www.youtube.com/watch?v=jkezDB90oqE

screenshot of map: https://pbs.twimg.com/media/B02PoJxCAAAFd_A.png

6 years ago by Joncom

the map is divided into prerendered chunks.
Something to be aware of when pre-rendering. Very large pre-rendered maps can consume very large amounts of memory. This is amplified if you increase the scale of your game.

6 years ago by drhayes

Wow, that chain lightning looks great!

6 years ago by Seeders

thanks :)

jancom - yep, i generate them as you walk and erase them, so i guess prerendered isnt the right description. its more like cached chunks.
Page 1 of 1
« first « previous next › last »