Acessing array from a function C++

53 Views Asked by At

I've double-checked to see if this specific question has been asked before, and I was unable to find anything of use, soooo.....

I've managed to use my PNRG to store ten numbers in an array, but I don't know how to use them to 'persist' my dungeon floors. I've tried to figure out out to use pointers, but it's too confusing for my poor brain!

If this is already asked, just point me (heh, geddit? Point? Pointers? Well, I thought it was funny....) in the right direction!

Thanks in advance!

1

There are 1 best solutions below

0
On

If you want your dungeon to persist after the player saves and closes the program, you'll have to take your map data, player state, and everything and save it to a file. And then load it from the file rather than generating it randomly at startup.

If you want your dungeon to persist, say, between floors that the player can travel up and down, it's still a valid idea to save the individual floors off to file and load them as needed. A side bonus that Nethack uses is that if the whole thing crashes, it can attempt to reconstruct the save from the last time you moved between floors.

Alternatively, you can simply have your dungeon consist of an ever growing vector, or a 3D array, complete with x,y, and z coordinates.

It's not so much a question about pointers as much as how to store data and where. New to programming or new to roguelike? Just use one big global array for a map and call it done.

(Also, PRNG not PNRG, pseudo-random number generator)