Skip to content

Commit

Permalink
Update default balloon class options
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonStnn committed Jul 11, 2024
1 parent 08b306e commit 9ac0590
Showing 1 changed file with 5 additions and 27 deletions.
32 changes: 5 additions & 27 deletions docs/balloons/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class Default {
+spawn_chance: number$
+<< get >>name: string
+<< get >>options: BalloonOptions
+<< get >>balloonImageUrl: string
+<< get >>popSoundUrl: string
+balloonImage: HTMLImageElement
+popSound: HTMLAudioElement
+<< get >>balloonImageUrl: string
+<< get >>popSoundUrl: string
+constructor()
#originalPath(path: string) string
+build() void
Expand All @@ -28,34 +28,12 @@ class BalloonOptions {
dir_name: string
imageUrl: string
popSoundUrl: string
size: [number, number]
riseDurationThreshold: [number, number]
swingDurationThreshold: [number, number]
swingOffset: number
waveDegrees: number
}
Default <|-- BalloonOptions
```

## Inheriting

To create a new balloon, extend the `Default` class and implement the abstract methods.

```ts
class Example extends Default {
public static readonly spawn_chance: number = 0.25;
// @ts-ignore
public get name(): 'example' {
return 'example';
}

public get options(): BalloonOptions {
return {
...super.options,
// Override options here
// e.g. the image url
imageUrl: 'example.svg',
};
}
}
```

In this example the `Example` class extends the `Default` class and overrides the `spawn_chance`, `name` and `options` properties. The options property overrides the image url to `example.svg`. Pop-a-loon will look for this `example.svg` file in the `resources/balloons/example` directory.

0 comments on commit 9ac0590

Please sign in to comment.