Skip to content
This repository has been archived by the owner on May 7, 2022. It is now read-only.

Example of spawning off-screen chunks #109

Open
ndarilek opened this issue Jan 20, 2021 · 1 comment
Open

Example of spawning off-screen chunks #109

ndarilek opened this issue Jan 20, 2021 · 1 comment

Comments

@ndarilek
Copy link

I'm prototyping a concept where the overmap is much larger than the visible map, and is made up of chunk types. Some distance from the map edge, I want to generate adjacent chunks off-screen, add them to the map, and potentially spawn in enemies/items/etc. I'd like to spawn chunks a bit away from the character, to allow for things like enemy troops to spawn a chunk or two away and advance on the player's position if they are detected. So it wouldn't be just-in-time, but maybe a screen or two of tiles.

Is there an example of this? I'm not thinking it has to be complex--just take the random world example and spawn in adjacent off-screen chunks.

In the meantime, I'm curious about how this currently works. Does autospawn just handle creating the chunks for me from a group of tiles, or does it detect when the camera is about to move off-screen and create a new chunk? I'm not sure whether the current chunk events are meant to tell me that I should run my map generators and create/add a chunk myself, or if it's up to me to detect when a new chunk is needed and do that myself.

Thanks.

@joshuajbouw
Copy link
Owner

joshuajbouw commented Jan 21, 2021

There is a sort of example of this with the redo of random_dungeon. I also just opened up the API on tilemap so that you can access to .events() which will allow you to see when chunks are created / despawned, allowing for stuff to be spawned in upon chunk creation if it needs to be. Otherwise, if the chunk already exists, then it will already have the data from before.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants