Medal

Medal - Tracks an unlockable medal

Constructor

new Medal(id, name, descriptionopt, iconopt, srcopt)

Create a medal object and adds it to the list of medals

Parameters:
NameTypeAttributesDefaultDescription
idNumber

The unique identifier of the medal

nameString

Name of the medal

descriptionString<optional>

Description of the medal

iconString<optional>
'🏆'

Icon for the medal

srcString<optional>

Image location for the medal

Example
// create a medal
const medal_example = new Medal(0, 'Example Medal', 'More info about the medal goes here.', '🎖️');

// initialize medals
medalsInit('Example Game');

// unlock the medal
medal_example.unlock();

Methods

render(hidePercentopt)

Render a medal

Parameters:
NameTypeAttributesDefaultDescription
hidePercentNumber<optional>
0

How much to slide the medal off screen

renderIcon(x, y, sizeopt)

Render the icon for a medal

Parameters:
NameTypeAttributesDefaultDescription
xNumber

Screen space X position

yNumber

Screen space Y position

sizeNumber<optional>
medalDisplayIconSize

Screen space size

unlock()

Unlocks a medal if not already unlocked