Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Achievements Viewer, which has a standalone achievement browser and its own toasts. #5

Open
wants to merge 23 commits into
base: dev
Choose a base branch
from

Conversation

jonsimantov
Copy link

This PR adds a standalone viewer for achievements that is easy to launch from your game by calling achievementsViewer.launch(). It blocks your game's update from executing (similar to the pause screen), then resumes updating your game after the user exits. (It does this by overriding the game's playdate.update function to its own, then restoring the previous value afterwards). The browser lets you sort by default order, recently unlocked, and progress (the achievements with progressMax set that you are closest to reaching at the top of the list).

This library also includes a toast that matches the look of the cards, available by running achievementsViewer.toast(achievementId). This overrides your playdate.update function as well, but executes the previous one every frame before it draws the toast. It should be possible to add other update methods to the toasts, such as using a sprite update or timer, as an alternative.

The goal of this library is to make it very easy to add to your app so that there can be an achievements browser in each app that looks unified in appearance, maybe even like it's part of the system. Just add the lua script, and all the assets, into your project, then call achievementsViewer.launch() to show it.

This PR includes several fonts from the Playdate SDK, though it would also be possible to remove them and simply add instructions on which fonts are needed and where to put them so the developer can do that themselves. All code and artwork was made by me and is added to whatever license the achievements library is released under. The audio files included are licensed under CC0 which is essentially a freeware / public domain type license that does not require any attribution.

Some examples of how this looks in my own game, Cranky Cove:

Achievements Viewer

achievements_viewer

Toasts

achievement_toasts

@jonsimantov
Copy link
Author

BTW, this could actually be used to power a pretty decent cross-game achievement viewer, since you can pass in a different game's gameData using the crossgame library.

@jonsimantov jonsimantov force-pushed the dev branch 2 times, most recently from e661a30 to f03341f Compare February 6, 2025 06:53
@gurtt
Copy link

gurtt commented Feb 7, 2025

It blocks your game's update from executing (similar to the pause screen), then resumes updating your game after the user exits. (It does this by overriding the game's playdate.update function to its own, then restoring the previous value afterwards).

Underrated technique tbh

@DimitriBarronmore
Copy link
Collaborator

A couple points of concern which I don't have the time necessary to address myself:

  • The fonts included in the Playdate SDK resources are provided under CC BY 4.0, according to the SDK's readme file. I believe if clear attribution is included there's no reason they can't be distributed with the rest of the library.

  • This doesn't currently account for the possibility that a game hasn't set default icons. defaultIcon, defaultIconLocked, and secretIcon are all optional fields. If one or more of these fields aren't present in the configured gamedata the viewer should fall back to the embedded icons processed in achievements/graphics.lua.

    • Related: With a necessary dependency on both achievements/achievements.lua and achievements/graphics.lua there should ideally be a more explicit error if the viewer is initialized without them present.
  • achievements/graphics.lua includes existing (less easily used) code for displaying toast animations as well as for setting a default toast to be automatically displayed every time an achievement is granted. With these new toasts looking sharp and snazzy I'd suggest either overhauling that code so the two work together or clearly ripping it out. Otherwise we're left with multiple redundant systems, one of which is much nicer than the other.

  • It would definitely be nice to have clearer documentation about exactly what all of the user-facing functions in the final module do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants