Snapshots in QB64?
#4
(02-15-2023, 02:48 PM)40wattstudio Wrote:
Quote:In my opinion a game would need to be designed from the onset with saved game states in mind.


Totally agree! That's why I'm asking about this way ahead of time.  Smile I couldn't imagine trying to integrate a save system into a game after the fact. That would be a nightmare for sure.

Using a global User Defined Type would definitely work and would even be efficient if there were no more than a couple hundred variables . . . but a future project I have in mind is a "persistent world" game with potentially hundreds of NPC's, each with possibly dozens of variables being tracked. Not to mention location information, quest information, etc, etc. I would expect the variable count to be easily in the thousands.

So far my only experience with saving data in QB64 is with using commands like OPEN, CLOSE, WRITE, FOR BINARY, etc.

That still would be fairly manageable. Your NPCs could be held in an array with a common UDT:

TYPE NPC
    variable...
    variable...
   etc..
END TYPE

REDIM NPC(0) as NPC ' increase size as needed when adding NPCs

If would then be a simple matter of saving the state of each NPC:

Handle = 0
DO
    SaveNPCStates NPC(Handle) ' save the state of NPC to drive
    Handle = Handle + 1
LOOP UNTIL Handle > UBOUND(NPC)
SavePlayerState Player ' save the state of the player
SaveGameState GameState ' save the game's global variables

Just an idea off the top of my head.
Software and cathedrals are much the same — first we build them, then we pray.
QB64 Tutorial
Reply


Messages In This Thread
Snapshots in QB64? - by 40wattstudio - 02-15-2023, 03:03 AM
RE: Snapshots in QB64? - by TerryRitchie - 02-15-2023, 03:51 AM
RE: Snapshots in QB64? - by 40wattstudio - 02-15-2023, 02:48 PM
RE: Snapshots in QB64? - by TerryRitchie - 02-15-2023, 06:35 PM
RE: Snapshots in QB64? - by bplus - 02-16-2023, 01:50 AM
RE: Snapshots in QB64? - by 40wattstudio - 02-16-2023, 02:24 AM
RE: Snapshots in QB64? - by TerryRitchie - 02-16-2023, 03:24 AM
RE: Snapshots in QB64? - by SMcNeill - 02-16-2023, 04:17 AM
RE: Snapshots in QB64? - by 40wattstudio - 02-16-2023, 10:57 AM
RE: Snapshots in QB64? - by mnrvovrfc - 02-16-2023, 01:38 PM
RE: Snapshots in QB64? - by SpriggsySpriggs - 02-17-2023, 05:38 PM
RE: Snapshots in QB64? - by TempodiBasic - 02-19-2023, 10:38 PM



Users browsing this thread: 2 Guest(s)