1

So I'm trying to implement a system with accounts where a user can log in. I want to assign each user a sprite that has attributes like level and EXP so that they can return to the game and still have this information saved. This is what I have so far for the post:

        post = {
            'username': username,
            'password': password,
            'exp': 0,
            'level': 1, 
            'character': Hero()
        }

However, the 'character' line crashes because I can't assign a sprite. Is there any other way to do this? It's a pretty simple game so I would just like it to work at the most basic level (like security doesn't matter at all basically)

sy89
  • 195
  • 2
  • 14
  • 2
    get all values from user instance (ie. position, energy, image_name, class name, etc) and create dictionary which you can convert to JSON string. When user returns you can convert JSON to dictionary and recreate instance `if class ="hero": Hero(position, energy, ....)`. Or you can try to "serialize" object using modules like `pickle`, `shelf` – furas Dec 01 '17 at 19:36
  • What does `Hero()` object represent ? is it just pointing to a sprite ? Can one sprite be refer to many users ? – Wan B. Dec 07 '17 at 22:54

0 Answers0