Lettersong roguelike devblog 2- a big world with limited physics and stupid critters

2022-08-12


This month, I’ve thought a bit about how to handle the game’s world structure (for the overworld, in particular). I debated adding a chunk system ala minecraft, dynamically loading and unloading chunks and only simulating physics (fluid dynamics, fires, etc.) in the chunks near the player, but handling cross-chunk physics interactions and so on seemed like a big source of complexity, and frankly, I’m not sure an arbitrarily big world s really required in a gameplay sense.

I’ve gone with the Casey Muratori school of ‘just do the simplest thing possible first; don’t prematurely abstract’, and I don’t think it’s led me wrong so far. Right now, the world map is just a big collection of arrays representing things like the temperature, wind speed, type of ground, type of structure etc. at each position. Here’s what the map struct looks like:

typedef struct{

    unsigned int id;

    TileStructure * structs;
    TileStructure * nextStructs;
    TileFloor * floors;
    TileFloor * nextFloors;

    float * temp;
    float * nextTemp;
    float * density;
    float * nextDensity;

    vecf * v;
    vecf * nextV;

    pos portals[MAPSIZE][MAPSIZE];
    long int * entities;
}map;

I’m not using portals for anything yet, and have yet to switch it over to heap allocation. Overall, this means the world map takes up about MAPSIZE*MAPSIZE*(8+2*2*16+4*16+2*32+2*20+3*4) bytes, or 252*MAPSIZE^2 bytes. This is about a gigabyte for a 2056x2056 map, which should be more than enough for a little game. There’s also space left over for some pocket dimensions, and the chance to load/unload to disk (with compression) if you ‘change level’.

In the future, I might bite the bullet and implement a proper chunk loading system, but it seems unnecessary right now.

On the matter of simulation, I just restricted physics to only run within a few hundred tiles of the player. On my 14-year-old laptop, this is good enough to get us about a frame every 20ms. At some point, I’ll want to profile and optimize things, but right now things seem more-or-less alright for general gameplay. The only noticeable problem right now is the case where you start a fire hot enough to consume every green thing in the world; the fire will burn to the edge of the sim-space, so that it’ll have burned your surroundings to ash but ‘still be going’ in distant environs.

I’ve also added some basic entities. Right now, they have sprites and wander around the world map at random, blocking movement.


Tags: 7drl lettersong

Add a comment

Name (optional):

Comment:


My Captcha: What's e raised to i times pi?