Logo
Logo
Home
Archive
Advertise
YouTube
Login
Sign Up
  • Home
  • Posts
  • 🦥 How Does Game Saves Work?

🦥 How Does Game Saves Work?

Jun 24, 2025

Hello friends!

Welcome to this week’s Sloth Bytes. I hope you had a silly week.

How Playrix increased developer productivity and code quality with AI-powered Code Reviews

Learn how Korbit AI enabled one of the world’s top gaming companies to accelerate engineering velocity and improve code quality.

Join this panel of Software Engineers & SaaS experts to learn:

  1. The challenges that stem from using manual code review processes or the wrong AI tools

  2. Why AI-powered code review is crucial for improving code quality, reducing reviewer fatigue and maintaining company standards.

  3. How Korbit accelerates the SDLC process for hundreds of enterprises with instant, AI-powered code reviews and powerful insights into the codebase, projects and team.

Save my spot!

🦥 How Games Remember Progress

Someone asked to do a game dev topic and I don’t have much game dev experience, so if I get something wrong, let me know!

If you’ve ever played any modern game, you’ve seen the words “saving…” or “auto save” somewhere.

But how the heck does that even work?

What exactly is it saving and when does it know to save?

I was very curious about that and did some research, and it’s a pretty cool concept.

I’ll be writing these examples in python to make it easier to read 😁

What do games save?

Games usually save important state data, not specific details:

# Bad: Everything
save_data = {
    "player_x": 143.23842,
    "player_velocity_x": 0.0023,
    "current_animation_frame": 3,
    "player_y" = -0.4314324
    "time_since_last_blink": 1.34,
    # ... 500 more random fields
}

# Good: What matters
save_data = {
    "level": 5,
    "health": 80,
    "inventory": ["sword", "potion"],
}

How do game save?

Games have a lot of different methods to saving:

Method 1: JSON (Text Files)

Very easy to implement and I think it’s the most common approach.

It works great as a simple save system:

import json

def save_game():
    data = {
        "level": player.level,
        "health": player.health,
        "inventory": player.inventory
    }
    with open("save.json", "w") as f:
        json.dump(data, f)

def load_game():
    with open("save.json", "r") as f:
        data = json.load(f)
        player.level = data["level"]
        # ... restore rest

✅ Human-readable and easy to debug.
❌ Easy to cheat if you don’t encrypt and the files are larger.

Method 2: Binary Files

For performance and smaller files, you can convert your data into binary:

import struct

def save_binary():
    with open("save.dat", "wb") as f:
        f.write(struct.pack('i', player.level))    # 4 bytes
        f.write(struct.pack('f', player.x))        # 4 bytes
        f.write(struct.pack('i', len(inventory)))  # 4 bytes
        
        for item in inventory:
            f.write(struct.pack('i', item.id))

def load_binary():
    with open("save.dat", "rb") as f:
        player.level = struct.unpack('i', f.read(4))[0]
        player.x = struct.unpack('f', f.read(4))[0]
        # ... etc

Same data: 200 bytes (JSON) → 20 bytes (binary)

✅ Fast, small, harder to edit
❌ Not human-readable, harder to test, easy to corrupt

Method 3: Databases

If you have large/complex data, You can use a database to save:

import sqlite3

conn = sqlite3.connect('save.db')
c = conn.cursor()

# Save
c.execute("INSERT INTO player VALUES (?, ?, ?)",
          (player.level, player.health, player.x))

c.execute("INSERT INTO inventory VALUES (?, ?)",
          (item_id, quantity))

conn.commit()

✅ Complex queries, unlimited slots
❌ Overkill for simple games

Platform-Specific

Some game engines/platforms have their own implementation/APIs, but you can also use the other methods I mentioned.

  • Unity has a system called playerPrefs

  • Godot has a system called config files

  • Unreal Engine seems to have the most complete/complex save system.

  • If you plan on publishing your game on Steam, you can use their cloud save system

Fun fact: The original Zelda (1986) pioneered battery-backed saves on cartridges. Before that, games used password systems.

Imagine entering a 50-character password to restore your Skyrim character.

Thanks for the feedback! I’ll try to do a easy + hard challenge.

16 Billion Apple, Facebook, Google And Other Passwords Leaked

As 16 billion credentials are confirmed as having been leaked, is it time to switch from passwords to passkeys?

Midjourney: Introducing Our V1 Video Model

Hi everyone! Basically; imagine an AI system that generates imagery in real-time.

Welcoming Payload to the Figma Team

We're thrilled to announce that the team behind Payload, a leading open-source headless content management system (CMS) and application framework, has joined Figma.

Vibe coding fever: Solo entrepreneur’s Base44 acquired by Wix for $80 million

31-year-old Maor Shlomo built the viral AI app-maker as a side project that began last year during a post-reserve trip.

'Stargazers' use fake Minecraft mods to steal player passwords

A large-scale malware campaign specifically targets Minecraft players with malicious mods and cheats.

Wow a lot of submissions this week. I guess it was too easy…

Thanks to everyone who submitted!

andregarcia0412, joshymerki, Tajgero, GabrielDornelas, FouadNara, xanerin, graff012, Better-Canada, Cariburi, JamesHarryT, GaLinux, AspenTheRoyal, Fireboy086, mau-estradiote, spenpal, dganesh05, xarop-pa-toss, Franspi-lol, RelyingEarth87, Moizg, and cuisse!

Spiral Matrix

Given a matrix of m * n elements (m rows, n columns), return all elements of the matrix in spiral order.

Examples

spiralOrder([
  [ 1, 2, 3 ],
  [ 4, 5, 6 ],
  [ 7, 8, 9 ]
])
output = [1, 2, 3, 6, 9, 8, 7, 4, 5]

spiralOrder([
  [1, 2, 3, 4],
  [5, 6, 7, 8],
  [9,10,11,12]
])
output = [1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7]

How To Submit Answers

Reply with

  • A link to your solution (github, twitter, personal blog, portfolio, replit, etc)

  • or if you’re on the web version leave a comment!

  • If you want to be mentioned here, I’d prefer if you sent a GitHub link or Replit!

New video about useful GitHub Repos!

16 Cool GitHub Repos You WILL Use (no pressure)

That’s all from me!

Have a great week, be safe, make good choices, and have fun coding.

If I made a mistake or you have any questions, feel free to comment below or reply to the email!

See you all next week.

What'd you think of today's email?

  • 🦥 Amazing! Keep it up
  • 🦥 Good, not great
  • 🦥 It sucked

Login or Subscribe to participate

Want to advertise in Sloth Bytes?

If your company is interested in reaching an audience of developers and programming enthusiasts, you may want to advertise with us here.

Reply

Avatar

or to participate

Keep Reading

envelope-simple

Join 50k+ developers and become a better programmer and stay up to date in just 5 minutes.

© 2026 Sloth Bytes.
Report abusePrivacy policyTerms of use
beehiivPowered by beehiiv