nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
jukebox.h
Go to the documentation of this file.
1#ifndef NANOMMO_CLIENT_JUKEBOX_H_
2#define NANOMMO_CLIENT_JUKEBOX_H_
3
4namespace nanommo {
5
6/// When the music plays, and how loud, kept apart from raylib so that it can
7/// be tested without a sound card. The music fades in as the player enters the
8/// world, plays the track through, rests for a while in silence and plays it
9/// again, and it fades out as they leave.
10class Jukebox {
11 public:
12 /// In seconds.
13 static constexpr float kFadeIn = 3.0f;
14 static constexpr float kFadeOut = 1.5f;
15 static constexpr float kRest = 45.0f;
16
17 /// What the track should do this frame.
18 enum class Cue { kNothing, kStart, kStop };
19
20 /// Moves on by the frame's time, from whether the player is in the world,
21 /// and whether the track is playing.
22 Cue Update(float seconds, bool in_world, bool playing);
23
24 /// From nothing to the track's full volume.
25 float volume() const { return volume_; }
26
27 private:
28 float volume_ = 0.0f;
29 float rest_ = 0.0f;
30 bool started_ = false;
31};
32
33} // namespace nanommo
34
35#endif // NANOMMO_CLIENT_JUKEBOX_H_
Cue Update(float seconds, bool in_world, bool playing)
Definition jukebox.cc:7
Cue
What the track should do this frame.
Definition jukebox.h:18
static constexpr float kFadeIn
In seconds.
Definition jukebox.h:13
float volume() const
From nothing to the track's full volume.
Definition jukebox.h:25
static constexpr float kFadeOut
Definition jukebox.h:14
static constexpr float kRest
Definition jukebox.h:15
Definition chat.cc:9