lively 0.16.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 914cc04280e002bc6622309ca42a5bcadced8d88265901e7ccc25157e090b799
4
- data.tar.gz: faa1aecb4b2b1b1be560d179f215b4e64d47f210d1ea8ad4fa6693f86c62a57b
3
+ metadata.gz: d27407a416fa635821337fdd4e59b5e74f5116e9d30ff3026e9e4828ae7420ad
4
+ data.tar.gz: 9fc8989d73bb25d310d4094e0c4da39d7b4d05295714571f7335ae0c09c9ea28
5
5
  SHA512:
6
- metadata.gz: 030f90ce72491935d1fbafba2849040f5e57fb5e1cd5b9f8b3d60e347a750058212e487be43ad89d752d3ab38d8689fb14da6057b0fcb8dabdc37a266eed62fb
7
- data.tar.gz: 73981a68c7e8e153a9e10e3f1cc5d25d163dda992125c1d2c775341ff96e3606d9646e1eeda2935accffd3e7d1c50ae4dc2c3dbc7ad7f21ce427cdac936f3050
6
+ metadata.gz: 1d7d6d282fb8788b8c8eb711c95e18f1a491138dbb91d6a8b26ec663c1b4e9f39b86c267580177838d5ea7e94464d2f6a847341b0beb71274f7aacc9a47be4b5
7
+ data.tar.gz: 7dd7b5fca6f49acd4fb53889793b53758613da379db8835e44120ce442eca18b55857e2829f72e98b79c57695fc1a03a2c58513f51db781a0301f73214629394
checksums.yaml.gz.sig CHANGED
Binary file
@@ -45,10 +45,12 @@ customElements.define('live-game', class GameElement extends ViewElement {
45
45
  this.#audio = Audio.start({
46
46
  window,
47
47
  onOutputCreated: (controller, output) => {
48
- console.log('Audio system ready');
49
- this.loadSounds();
48
+ // Start background audio:
49
+ this.#audio.playSound('music');
50
50
  }
51
51
  });
52
+
53
+ this.loadSounds();
52
54
  }
53
55
 
54
56
  disconnectedCallback() {
@@ -60,7 +62,7 @@ customElements.define('live-game', class GameElement extends ViewElement {
60
62
  }
61
63
 
62
64
  loadSounds() {
63
- // We'll add sounds here
65
+ // We'll add sounds here.
64
66
  }
65
67
 
66
68
  get audio() {
@@ -69,33 +71,41 @@ customElements.define('live-game', class GameElement extends ViewElement {
69
71
  });
70
72
  ```
71
73
 
74
+ Note that playing audio can generally only be done in response to a user interaction (like a click or key press) due to browser autoplay policies. The onOutputCreated callback is a good place to start background audio after the user has interacted with the page, while other sound effects can be "best effort" if played outside of user interaction.
75
+
72
76
  ### 2. Adding Synthesized Sound Effects
73
77
 
74
78
  The library includes many pre-built synthesized sounds:
75
79
 
76
80
  ```javascript
77
81
  loadSounds() {
78
- // Game action sounds
82
+ // Game action sounds:
79
83
  this.#audio.addSound('jump', new Library.JumpSound());
80
84
  this.#audio.addSound('coin', new Library.CoinSound());
81
85
  this.#audio.addSound('powerup', new Library.PowerUpSound());
82
86
  this.#audio.addSound('death', new Library.DeathSound());
83
87
 
84
- // Combat sounds
88
+ // Combat sounds:
85
89
  this.#audio.addSound('laser', new Library.LaserSound());
86
90
  this.#audio.addSound('explosion', new Library.ExplosionSound());
87
91
 
88
- // Interface sounds
92
+ // Interface sounds:
89
93
  this.#audio.addSound('beep', new Library.BeepSound());
90
94
  this.#audio.addSound('blip', new Library.BlipSound());
91
95
 
92
- // Animal sounds
96
+ // Animal sounds:
93
97
  this.#audio.addSound('meow', new Library.MeowSound());
94
98
  this.#audio.addSound('bark', new Library.BarkSound());
95
99
  this.#audio.addSound('duck', new Library.DuckSound());
96
100
  this.#audio.addSound('roar', new Library.RoarSound());
97
101
  this.#audio.addSound('howl', new Library.HowlSound());
98
102
  this.#audio.addSound('chirp', new Library.ChirpSound());
103
+
104
+ // Background music (looping) with optional loop points:
105
+ this.#audio.addSound('music', new Library.BackgroundMusicSound('/_static/music.mp3', {
106
+ loopStart: 32.0 * 60.0 / 80.0,
107
+ loopEnd: 96.0 * 60.0 / 80.0,
108
+ }));
99
109
  }
100
110
  ```
101
111
 
@@ -121,7 +131,7 @@ class GameView < Live::View
121
131
 
122
132
  def player_jump
123
133
  @player.jump
124
- play_sound('jump') # Play jump sound
134
+ play_sound('jump') # Play jump sound
125
135
  end
126
136
 
127
137
  def collect_coin
@@ -5,5 +5,5 @@
5
5
 
6
6
  # @namespace
7
7
  module Lively
8
- VERSION = "0.16.0"
8
+ VERSION = "0.16.1"
9
9
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lively
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file