Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7585047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:04:41+00:00 2026-05-30T19:04:41+00:00

So I’m designing a 2D game in C++ with tons of data– basically, it

  • 0

So I’m designing a 2D game in C++ with tons of data– basically, it features randomly generated, blocky terrain (in the form of a very large byte array), much in the style of Terraria, and will also need to save state for monsters (among other various game objects). As the player runs around, sections of the game world will be loaded/saved to the disk, making for an infinitely expanding game world (similar to Minecraft).

What’s my best option for saving everything to the disk? I’m mostly concerned with efficiency (so the user never has to wait on content to load), but ease of use and maintainability are a close second. I’m very familiar with Minecraft’s method of saving, which has a separate file for each “Chunk”, but I was wondering– should I designate my own files like Minecraft, or go with a database? What other possibilities are out there? If I use a file, would I get a significant performance boost by asking the OS for raw access and handling that myself (much like a database does)?

Also, I’d like to be able to port the project from PC to Mac and console– alternatives for individual platforms are fine, I’ll just have to swap methods depending on the platform.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:04:42+00:00Added an answer on May 30, 2026 at 7:04 pm

    A single file would be much cleaner and could take less physical disk space than relying on the filesystem for organization. Just maintain a table of offsets at the beginning of the file to link to each of the chunks.

    As far as compression, applying a run length encoding would definitely deflate the file size, and if it is like Minecraft, you’ll have a lot of identical blocks in sequence. As a bonus, it will load faster on computers using platter drives, as a couple of bytes can equate to thousands of blocks, instead of having to read a byte for each of those blocks. Here’s a quick tip for an effective run length encoding: use a command byte, say 0x00. All other bytes are associated with a block, but the command byte would signify a non-block bit of info. The traditional run length encoding looks like this:

    Source: AAAABBBBBBBCDDDEFA
    Destination: 0x0441074201430344014501460161
    Plaintext: .A.B.C.D.E.F.A
    

    Using a command byte, omitting sequences that would increase size:

    Source: AAAABBBBBBBCDDDEFA
    Destination: 0x00044100074243444444454641.
    Plaintext: ..A..BCDDDEFA
    

    This has a distinct advantage in “marbled” sections of data.

    One other thing, I recommend that you use a system for storing numbers similar to the midi format, although in little endian format. To save you the googling, all it really means is that you sacrifice a bit for each byte you use to store the number. If the 8th bit is set, it means there’s another byte in the number, and it cascades. Example:

    Storing: 65
    Stored as: 0x41 (01000001) //The eighth bit is not set, so this number only occupies 7 bits.
    
    Storing: 192
    Stored as: 0xC081 (11000000 10000001) //The eighth bit of the first byte is set, so the following byte is part of the number. The second byte doesn't have the eighth bit set, so the number ends there.
    
    Storing: 612453
    Stored as: 0x72D825 (11100101 1011000 00100101) //The eighth bit of the first two bytes are set, and the third is not, so this number occupies 3 bytes.
    

    I hope that I helped provide some insight.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want to construct a data frame in an Rcpp function, but when I
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.