getify / cloud-sweeper

A casual game built for the web.
94 stars 17 forks source link

save best score in localstorage #17

Closed getify closed 8 years ago

getify commented 8 years ago

probably have it store the game version with the score, and if the game version has a minor or major change (not just patch), have it reset the best scores to 0

ntwcklng commented 8 years ago

I created a pull request, see #24 I don't know if its the best solution to store the whole data as a string in a single localstorage item. What do you think?

ntwcklng commented 8 years ago

My next approach: https://github.com/ntwcklng/cloud-sweeper/commit/699c33c54cd7e375afcdcb5c71676edc5e0e1189

I think this is far more better then the previous version.

getify commented 8 years ago

this looks much better. i'll try to take a closer look soon. :)

getify commented 8 years ago

The other thing I'd suggest is that there may be other things we want to store/persist than just the score, so maybe there should just be a single data structure that we fill in... like:

settings = {
   "build_version": "...",
   "best_scores": [ 3, 5, 8 ],
   "...": ...
};

In this way, it'll be easier to just add new data to be stored in the future.

ntwcklng commented 8 years ago

Okay, here we go: https://github.com/getify/cloud-sweeper/compare/master...ntwcklng:master It gets better and better, thank you!

getify commented 8 years ago

Much improved, thanks! There's a few more tweaks I'd like to make to the organization/logic. Would you like to PR this as-is and I can then iterate on it after landing it?

ntwcklng commented 8 years ago

Sure, it's an awesome way to learn! #29

getify commented 8 years ago

it's an awesome way to learn!

That was exactly my goal. Thanks so much for contributing! :)