Skip to content

A simple WIP library allowing you to create achievements for the Ursina game engine !

License

Notifications You must be signed in to change notification settings

megat69/UrsinaAchievements

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 

Repository files navigation

More information

A simple library for creating achievements for the Ursina game engine.

Note : This library is used in the Rally game created by Mandaw2014. The library usage is shown in the game's fourth devlog.

How to use the library

To use this library, first download this repository, and add the UrsinaAchievements folder to your game's main folder.

Then, in your main file, import the create_achievement function.

from UrsinaAchievements import create_achievement

This function takes several parameters into account.

  • name (str) : Name of the achievement.
  • condition : Callback function representing the condition under which the achievement must be unlocked.
    • Unlocks the achievement if the returned value is True and passes if the returned value is either False or None.
  • icon (str, None by default) : The path to the image of your choice that will represent your achievement. (optional)
  • sound (str, "sudden" by default) : Name of the sound used to signal the achievement get.
    • This could be "ringing", "rising", "sign", "sudden" or the path to a WAV format file.
  • duration (float, 1 by default) : Time during which the achievement will be displayed on screen.

For example :

from ursina import *
from UrsinaAchievements import create_achievement

app = Ursina(borderless = False, fullscreen = True, development_mode = False)

do = False

def cond():
    global do
    return do

create_achievement(name = 'Welcome!', condition = cond, icon = 'confetti', sound = 'sudden', duration = 1.5)

def setdo():
    global do
    do = True
invoke(setdo, delay = 3)

Sky()

app.run()

Customisation

You can customise the appearance of the achievement by importing the Achievement class and modifying the following variables associated with it:

  • Achievement.achievement_color
  • Achievement.text_color
  • Achievement.icon_color

They correspond to a tuple of three integer values.

Features & Todos

  • Popups at the bottom-right corner of the screen
    • Contains an achievement name
    • An icon
  • Every frame, each function given for the argument check is tested ; achievement is given if the function tests true
  • All gotten achievements are stored in a JSON file
  • An HTML file is generated with every achievement you got
  • The function used for creating the achievements can be used as a decorator

About

A simple WIP library allowing you to create achievements for the Ursina game engine !

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages