Skip to content

Commit

Permalink
* Play music on starting racing
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkOates committed Oct 1, 2022
1 parent c872822 commit 6c43bb0
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 15 deletions.
12 changes: 9 additions & 3 deletions documentation/dependents.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
],
"AllegroFlare/SampleBin": [
"AllegroFlare/AudioController",
"AllegroFlare/AudioController"
"AllegroFlare/AudioController",
"AllegroFlare/Prototypes/MindDive/MindDive"
],
"AllegroFlare/AudioRepositoryElement": [
"AllegroFlare/AudioController"
Expand All @@ -17,13 +18,15 @@
],
"AllegroFlare/Sound": [
"AllegroFlare/AudioController",
"AllegroFlare/AudioController"
"AllegroFlare/AudioController",
"AllegroFlare/Prototypes/MindDive/MindDive"
],
"al_is_audio_initialized": [
"AllegroFlare/AudioController"
],
"al_is_acodec_addon_initialized": [
"AllegroFlare/AudioController"
"AllegroFlare/AudioController",
"AllegroFlare/Prototypes/MindDive/MindDive"
],
"AllegroFlare/BitmapBin": [
"AllegroFlare/BackgroundFactory",
Expand Down Expand Up @@ -1353,6 +1356,9 @@
"AllegroFlare/Camera2D": [
"AllegroFlare/Prototypes/MindDive/Hud/Hud"
],
"al_is_audio_installed": [
"AllegroFlare/Prototypes/MindDive/MindDive"
],
"AllegroFlare/Prototypes/MindDive/TunnelMesh": [
"AllegroFlare/Prototypes/MindDive/MindDive",
"AllegroFlare/Prototypes/MindDive/TunnelMeshFactory",
Expand Down
42 changes: 37 additions & 5 deletions documentation/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -7528,10 +7528,18 @@ <h3 id="quintessence/AllegroFlare/Prototypes/MindDive/MindDive.q.yml">quintessen
<td class="property">font_bin</td>
<td class="property">AllegroFlare::FontBin*</td>
</tr>
<tr>
<td class="property">sample_bin</td>
<td class="property">AllegroFlare::SampleBin*</td>
</tr>
<tr>
<td class="property">current_tunnel_mesh</td>
<td class="property">AllegroFlare::Prototypes::MindDive::TunnelMesh*</td>
</tr>
<tr>
<td class="property">current_music_track</td>
<td class="property">AllegroFlare::Sound*</td>
</tr>
<tr>
<td class="property">surfer_position</td>
<td class="property">AllegroFlare::Vec3D</td>
Expand Down Expand Up @@ -7581,9 +7589,15 @@ <h3 id="quintessence/AllegroFlare/Prototypes/MindDive/MindDive.q.yml">quintessen
<tr>
<td class="method">set_bitmap_bin(1)</td>
</tr>
<tr>
<td class="method">set_sample_bin(1)</td>
</tr>
<tr>
<td class="method">set_font_bin(1)</td>
</tr>
<tr>
<td class="method">infer_playhead_position_sec()</td>
</tr>
<tr>
<td class="method">initialize()</td>
</tr>
Expand Down Expand Up @@ -7646,17 +7660,23 @@ <h3 id="quintessence/AllegroFlare/Prototypes/MindDive/MindDive.q.yml">quintessen
</tr>
</table>
<table>
<tr>
<td class="dependency">{&quot;symbol&quot;=&gt;&quot;al_is_audio_installed&quot;, &quot;headers&quot;=&gt;[&quot;allegro5/allegro_audio.h&quot;]}</td>
</tr>
<tr>
<td class="dependency">{&quot;symbol&quot;=&gt;&quot;al_is_acodec_addon_initialized&quot;, &quot;headers&quot;=&gt;[&quot;allegro5/allegro_acodec.h&quot;]}</td>
</tr>
<tr>
<td class="dependency">{&quot;symbol&quot;=&gt;&quot;AllegroFlare::Prototypes::MindDive::TunnelMesh&quot;, &quot;headers&quot;=&gt;[&quot;AllegroFlare/Prototypes/MindDive/TunnelMesh.hpp&quot;]}</td>
</tr>
<tr>
<td class="dependency">{&quot;symbol&quot;=&gt;&quot;AllegroFlare::Vec3D&quot;, &quot;headers&quot;=&gt;[&quot;AllegroFlare/Vec3D.hpp&quot;]}</td>
</tr>
<tr>
<td class="dependency">{&quot;symbol&quot;=&gt;&quot;AllegroFlare::BitmapBin&quot;}</td>
<td class="dependency">{&quot;symbol&quot;=&gt;&quot;AllegroFlare::Placement3D&quot;, &quot;headers&quot;=&gt;[&quot;AllegroFlare/Placement3D.hpp&quot;]}</td>
</tr>
<tr>
<td class="dependency">{&quot;symbol&quot;=&gt;&quot;AllegroFlare::Placement3D&quot;, &quot;headers&quot;=&gt;[&quot;AllegroFlare/BitmapBin.hpp&quot;]}</td>
<td class="dependency">{&quot;symbol&quot;=&gt;&quot;AllegroFlare::BitmapBin&quot;, &quot;headers&quot;=&gt;[&quot;AllegroFlare/BitmapBin.hpp&quot;]}</td>
</tr>
<tr>
<td class="dependency">{&quot;symbol&quot;=&gt;&quot;AllegroFlare::Useful&quot;, &quot;headers&quot;=&gt;[&quot;AllegroFlare/Useful.hpp&quot;]}</td>
Expand Down Expand Up @@ -7696,6 +7716,12 @@ <h3 id="quintessence/AllegroFlare/Prototypes/MindDive/MindDive.q.yml">quintessen
</tr>
<tr>
<td class="dependency">{&quot;symbol&quot;=&gt;&quot;AllegroFlare::EventEmitter&quot;, &quot;headers&quot;=&gt;[&quot;AllegroFlare/EventEmitter.hpp&quot;]}</td>
</tr>
<tr>
<td class="dependency">{&quot;symbol&quot;=&gt;&quot;AllegroFlare::Sound&quot;, &quot;headers&quot;=&gt;[&quot;AllegroFlare/Sound.hpp&quot;]}</td>
</tr>
<tr>
<td class="dependency">{&quot;symbol&quot;=&gt;&quot;AllegroFlare::SampleBin&quot;, &quot;headers&quot;=&gt;[&quot;AllegroFlare/SampleBin.hpp&quot;]}</td>
</tr>
</table>
</div>
Expand Down Expand Up @@ -12630,7 +12656,8 @@ <h1>Dependents</h1>
],
"AllegroFlare/SampleBin": [
"AllegroFlare/AudioController",
"AllegroFlare/AudioController"
"AllegroFlare/AudioController",
"AllegroFlare/Prototypes/MindDive/MindDive"
],
"AllegroFlare/AudioRepositoryElement": [
"AllegroFlare/AudioController"
Expand All @@ -12643,13 +12670,15 @@ <h1>Dependents</h1>
],
"AllegroFlare/Sound": [
"AllegroFlare/AudioController",
"AllegroFlare/AudioController"
"AllegroFlare/AudioController",
"AllegroFlare/Prototypes/MindDive/MindDive"
],
"al_is_audio_initialized": [
"AllegroFlare/AudioController"
],
"al_is_acodec_addon_initialized": [
"AllegroFlare/AudioController"
"AllegroFlare/AudioController",
"AllegroFlare/Prototypes/MindDive/MindDive"
],
"AllegroFlare/BitmapBin": [
"AllegroFlare/BackgroundFactory",
Expand Down Expand Up @@ -13979,6 +14008,9 @@ <h1>Dependents</h1>
"AllegroFlare/Camera2D": [
"AllegroFlare/Prototypes/MindDive/Hud/Hud"
],
"al_is_audio_installed": [
"AllegroFlare/Prototypes/MindDive/MindDive"
],
"AllegroFlare/Prototypes/MindDive/TunnelMesh": [
"AllegroFlare/Prototypes/MindDive/MindDive",
"AllegroFlare/Prototypes/MindDive/TunnelMeshFactory",
Expand Down
10 changes: 9 additions & 1 deletion include/AllegroFlare/Prototypes/MindDive/MindDive.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#pragma once


#include <AllegroFlare/BitmapBin.hpp>
#include <AllegroFlare/Camera3D.hpp>
#include <AllegroFlare/EventEmitter.hpp>
#include <AllegroFlare/FontBin.hpp>
#include <AllegroFlare/Physics/TileMapCollisionStepperStepResult.hpp>
#include <AllegroFlare/Prototypes/MindDive/Hud/Hud.hpp>
#include <AllegroFlare/Prototypes/MindDive/TunnelMesh.hpp>
#include <AllegroFlare/SampleBin.hpp>
#include <AllegroFlare/Sound.hpp>
#include <AllegroFlare/Timer.hpp>
#include <AllegroFlare/Vec3D.hpp>

Expand All @@ -29,7 +32,9 @@ namespace AllegroFlare
AllegroFlare::EventEmitter* event_emitter;
AllegroFlare::BitmapBin* bitmap_bin;
AllegroFlare::FontBin* font_bin;
AllegroFlare::SampleBin* sample_bin;
AllegroFlare::Prototypes::MindDive::TunnelMesh* current_tunnel_mesh;
AllegroFlare::Sound* current_music_track;
AllegroFlare::Vec3D surfer_position;
AllegroFlare::Vec3D surfer_velocity;
AllegroFlare::Timer timer;
Expand All @@ -45,16 +50,19 @@ namespace AllegroFlare


public:
MindDive(AllegroFlare::EventEmitter* event_emitter=nullptr, AllegroFlare::BitmapBin* bitmap_bin=nullptr, AllegroFlare::FontBin* font_bin=nullptr);
MindDive(AllegroFlare::EventEmitter* event_emitter=nullptr, AllegroFlare::BitmapBin* bitmap_bin=nullptr, AllegroFlare::FontBin* font_bin=nullptr, AllegroFlare::SampleBin* sample_bin=nullptr);
~MindDive();

void set_event_emitter(AllegroFlare::EventEmitter* event_emitter);
AllegroFlare::EventEmitter* get_event_emitter() const;
AllegroFlare::BitmapBin* get_bitmap_bin() const;
AllegroFlare::FontBin* get_font_bin() const;
AllegroFlare::SampleBin* get_sample_bin() const;
AllegroFlare::Prototypes::MindDive::TunnelMesh* &get_current_tunnel_mesh_ref();
void set_bitmap_bin(AllegroFlare::BitmapBin* bitmap_bin=nullptr);
void set_sample_bin(AllegroFlare::SampleBin* sample_bin=nullptr);
void set_font_bin(AllegroFlare::FontBin* font_bin=nullptr);
float infer_playhead_position_sec();
void initialize();
void pause_timer();
void reset();
Expand Down
56 changes: 53 additions & 3 deletions quintessence/AllegroFlare/Prototypes/MindDive/MindDive.q.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,22 @@ properties:
getter: true
setter: false

- name: sample_bin
type: AllegroFlare::SampleBin*
constructor_arg: true
init_with: nullptr
getter: true
setter: false

- name: current_tunnel_mesh
type: AllegroFlare::Prototypes::MindDive::TunnelMesh*
init_with: ''
getter_ref: true

- name: current_music_track
type: AllegroFlare::Sound*
init_with: nullptr

- name: surfer_position
type: AllegroFlare::Vec3D
init_with: '{0, 0, 0}'
Expand Down Expand Up @@ -94,6 +105,17 @@ functions:
return;
- name: set_sample_bin
parameters:
- name: sample_bin
type: AllegroFlare::SampleBin*
default_argument: nullptr
guards: [ (!initialized) ]
body: |
this->sample_bin = sample_bin;
return;
- name: set_font_bin
parameters:
- name: font_bin
Expand All @@ -105,12 +127,27 @@ functions:
return;
- name: infer_playhead_position_sec
type: float
body: |
if (!current_music_track) return 0;
return current_music_track->position();
- name: initialize
guards: [ (!initialized), bitmap_bin, font_bin ]
guards:
- (!initialized)
- al_is_audio_installed()
- al_is_acodec_addon_initialized()
- event_emitter
- bitmap_bin
- font_bin
- sample_bin
body: |
AllegroFlare::Prototypes::MindDive::TunnelMeshFactory factory(bitmap_bin);
//current_tunnel_mesh = factory.create_classic_random();
current_tunnel_mesh = factory.create_random_with_walls();
current_music_track = new AllegroFlare::Sound(sample_bin->auto_get("music_tracks/some-jamzz-04.ogg"));
hud.set_font_bin(font_bin);
hud.set_timer(&timer);
Expand All @@ -119,6 +156,8 @@ functions:
initialized = true;
return;
body_dependency_symbols:
- al_is_audio_installed
- al_is_acodec_addon_initialized
- AllegroFlare::Prototypes::MindDive::TunnelMeshFactory


Expand All @@ -143,6 +182,7 @@ functions:
- name: reset
guards: [ initialized ]
body: |
surfer_position.x = current_tunnel_mesh->infer_real_width() * 0.5
- current_tunnel_mesh->obtain_tile_width() * 0.5;
Expand All @@ -159,7 +199,8 @@ functions:
//camera.zoom = 2.1;
//camera.spin += 0.01f;
//AllegroFlare::EventEmitter emit_play_music_track_event("[unset-music-track-identifier]");
event_emitter->emit_play_music_track_event("[unset-music-track-identifier]");
if (current_music_track) current_music_track->stop();
reset_timer();
return;
Expand All @@ -168,6 +209,7 @@ functions:
body: |
if (state != STATE_WAITING_START) return;
state = STATE_RACING;
if (current_music_track) current_music_track->play();
start_timer();
hud.clear_slate();
return;
Expand Down Expand Up @@ -350,13 +392,17 @@ functions:
dependencies:


- symbol: al_is_audio_installed
headers: [ allegro5/allegro_audio.h ]
- symbol: al_is_acodec_addon_initialized
headers: [ allegro5/allegro_acodec.h ]
- symbol: AllegroFlare::Prototypes::MindDive::TunnelMesh
headers: [ AllegroFlare/Prototypes/MindDive/TunnelMesh.hpp ]
- symbol: AllegroFlare::Vec3D
headers: [ AllegroFlare/Vec3D.hpp ]
- symbol: AllegroFlare::BitmapBin
- symbol: AllegroFlare::Placement3D
headers: [ AllegroFlare/Placement3D.hpp ]
- symbol: AllegroFlare::BitmapBin
headers: [ AllegroFlare/BitmapBin.hpp ]
- symbol: AllegroFlare::Useful
headers: [ AllegroFlare/Useful.hpp ]
Expand Down Expand Up @@ -384,5 +430,9 @@ dependencies:
headers: [ AllegroFlare/Physics/TileMapCollisionStepperStepResult.hpp ]
- symbol: AllegroFlare::EventEmitter
headers: [ AllegroFlare/EventEmitter.hpp ]
- symbol: AllegroFlare::Sound
headers: [ AllegroFlare/Sound.hpp ]
- symbol: AllegroFlare::SampleBin
headers: [ AllegroFlare/SampleBin.hpp ]


Loading

0 comments on commit 6c43bb0

Please sign in to comment.