Pygame Tutorial - Save/Load System

Поделиться
HTML-код
  • Опубликовано: 13 дек 2024

Комментарии • 32

  • @vinnn8694
    @vinnn8694 Год назад +6

    Very nice tutorial, thank you for making this!
    Especially appreciating: Cut right to the point, no rambling and good code style to understand for a beginner like me.

  • @harigopaladamus9481
    @harigopaladamus9481 2 года назад +3

    Dude you are amazing! your way of explaining beats an adult any day!

  • @black_tea_enjoyer
    @black_tea_enjoyer 3 месяца назад

    This is a great tutorial! Thank you so much! I am so inspired to continue learning python and pygame after this video. Wish you success in your future.

  • @discotrain173
    @discotrain173 2 года назад +3

    Wow what a great tutorial. Great job explaining everything!

  • @JamieBliss
    @JamieBliss 3 года назад +1

    That's a pretty solid tutorial! I wouldn't consider this suitable for a shipping game, but as a first save system this is a great starting point.

    • @discotrain173
      @discotrain173 2 года назад

      What do you think would be more suitable save system for a game you're shipping in pygame?

    • @JamieBliss
      @JamieBliss 2 года назад

      @@discotrain173 two big things: pickle and schema. Pickle is easy to get started with, but has big caveats (that other people have discussed at length). The other problem is schema: as you ship new versions of your game, the exact data you save may change, and you want to make sure that old saves continue to load in new versions. (I don't mean sequels, I just mean patches.)
      However, these are only really concerns if you actually ship a game. If you're just looking to quickly add saving to a demo, prototype, experiment, academic exercise, etc, in my opinion this is plenty fine.

    • @discotrain173
      @discotrain173 2 года назад

      @@JamieBliss what other big caveats are there besides if you want to make patches? (I'm a pickle noob)

    • @JamieBliss
      @JamieBliss 2 года назад +1

      @@discotrain173 Ok, so Pickle has two major problems: security and schema.
      First: security. Unpickling is basically code execution. A crafted pickle can do anything your program is allowed to do: read files, write files, talk to servers, download and run programs, mess with your game internals, anything.
      Second: schema. I've used this term a few times; it's basically the shape of your data. Pickling rely on the shape of your classes to define their schema. Worst, schema mismatches won't happen when you load the game, they'll happen somewhere else when whatever actually tries to use that data. So if you fix a bheavior by adding an extra flag to an NPC, and that flag isn't in an old save, when a player loads it, the game will crash when the NPC AI goes and looks for the flag.
      None of this really matters when the expected playerbase is youself--you trust yourself, and you know if it goes funky, just delete your save. But if you ship and patch a game, these caveats will make your players Have A Bad Time.

    • @discotrain173
      @discotrain173 2 года назад

      @@JamieBliss ok I see. But what would you use instead of pickle?

  • @vinnn8694
    @vinnn8694 Год назад

    Looking forward to study your Shader tutorial.
    Kind of a shame you only have 5 tutorial videos for pygame. Please make more!
    I am currently trying to learn python and OOP by coding the basics for an imaginary pygame project.
    So far I have learned and implemented a state stack manager, menu system, delta time, screen size config and now your save load manager.
    Next steps will be a little more specific to my game idea: Isometric hexagon grid and lighting system with blending and masks.
    I am really enjoying the journey so far, good luck on yours!

  • @Mikendlela27
    @Mikendlela27 2 года назад

    Actually more useful than I thaught

  • @imraptorr1066
    @imraptorr1066 2 года назад

    insane code. Its so usefull. you can really use it anywhere. Thanks for this video

  • @elliotkovanda3124
    @elliotkovanda3124 2 года назад

    Excellent tutorial, thanks a lot!

  • @SWE-from-Sweden
    @SWE-from-Sweden Год назад

    absolutely love the video! thank you

  • @Civi_ts
    @Civi_ts 3 года назад

    Thx! Def gonna use it a lot.

  • @tbinaryg
    @tbinaryg Месяц назад

    thanks! but could you also use f-strings next time because the text+variable+text+variable is killing me

  • @knownrobloxian3381
    @knownrobloxian3381 3 года назад

    When I try to make an account on Pygame it says disabled, does anyone know how to fix this?

  • @SophiaWoessner
    @SophiaWoessner 2 года назад

    That VS Code theme is giving me an aneurysm

  • @euluan92
    @euluan92 3 года назад

    12:27

  • @Blinkers2007GameDev
    @Blinkers2007GameDev 2 года назад

    wow thanks

  • @Mikendlela27
    @Mikendlela27 2 года назад

    Thanks kid

  • @carlpilongo539
    @carlpilongo539 2 года назад

    Is it just me or the person explaining this is a child?
    A child better than me in coding now i see myself more useless now

  • @AhmadBakdash07
    @AhmadBakdash07 2 года назад

    How old are you 🤔

  • @arielmorandy8189
    @arielmorandy8189 Год назад

    this is a great but totally useless in a real pygame development, because you cant serialize pygame.surface, and most of our implementation are done using sprite and surface. It means, that you need to "de-serialize" each object and use a constructor to rebuild the graphics. This can work, but this is a deep change, and if you do so,many others python modules wont work with pygame any more. I believe the best is to rewrite the save and open, from your classes, instead of using Pickle

  • @euluan92
    @euluan92 3 года назад

    12:

  • @alexdemeter1558
    @alexdemeter1558 7 месяцев назад

    Hi this is amazing vido and also for anyone wantinga pit more simpler version
    import turtle
    from turtle import *
    import tkinter as tk
    score=0
    clicks=0
    a=turtle.Turtle()
    a.ht()
    a.penup()
    a.goto(-350, 300)
    a.write(f"Score: {score}", font=("Arial", 21, "normal"))
    b=turtle.Turtle()
    b.ht()
    b.penup()
    b.goto(-360, 220)
    b.write(f"Clicks: {clicks}", font=("Arial", 21, "normal"))
    def tapping(x, y):
    global score, clicks
    score+=10
    clicks+=1
    a.clear()
    a.write(f"Score: {score}", font=("Arial", 21, "normal"))
    b.clear()
    b.write(f"Clicks: {clicks}", font=("Arial", 21, "normal"))
    turtle.listen()
    turtle.onscreenclick(tapping)
    def save():
    global score, clicks
    file=open("save.txt", "w")
    file.write(f"score: {score}
    ")
    file.write(f"taps: {clicks}
    ")
    button=tk.Button(text="Save", command=save)
    button.pack()
    def load():
    global score, clicks
    a.clear()
    b.clear()
    file=open("save.txt", "r")
    ht()
    penup()
    goto(-350, 300)
    write(file.read(), font=("Arial", 21, "normal"))
    button2=tk.Button(text="Load", command=load)
    button2.pack()
    turtle.mainloop()
    You can ofcorrse remove the turtle and add whstever python modlua u want i just made it and there isnt any errors as i see i hope it helps and if you hsve any questions feel free to ask :)