$self->{id}, ' missed pit lane entry', "\n";
$self->enter_pit_lane;
}
+ if ($val == $prev - 1 && $val <= 2 && !$self->{in_pit_lane}) {
+ $self->track->{sound}->box($self->{id});
+ }
+ }
+ if (defined $val && defined $prev && $val == 8 && $prev == 7
+ && $self->{in_pit_lane}) {
+ $self->track->{sound}->filled($self->{id});
}
$self->gui->set_fuel($self->{order}, $val);
--- /dev/null
+#!/usr/bin/perl -w
+
+package SCX::Sound;
+
+use strict;
+
+sub new {
+ my ($class, $args) = @_;
+
+ my $self = {
+ data_dir => $args->{data_dir} || './sounds/',
+ };
+
+ bless $self, $class;
+
+ return $self;
+}
+
+sub _play {
+ my ($self, @names) = @_;
+
+ @names = map { $self->{data_dir} . '/' . $_ . '.wav' } @names;
+ system (join(' ', 'aplay', @names). ' &');
+}
+
+sub start { shift->_play('start'); }
+sub filled { shift->_play('filled'); }
+
+sub winner {
+ my ($self, $car_id) = @_;
+
+ $self->_play('winner', $car_id, 'winner');
+}
+
+sub box {
+ my ($self, $car_id) = @_;
+
+ $self->_play('box', $car_id, 'box');
+}
+
+sub best_lap {
+ my ($self, $car_id) = @_;
+
+ $self->_play('bestlap', $car_id);
+}
+
+1;
use Glib qw(TRUE FALSE);
use SCX::Car;
+use SCX::Sound;
our $SEMAPHORE_STEP = 1000;
$self->{gui}->time(undef);
$self->{gui}->best_lap(undef, undef);
+ $self->{sound} = new SCX::Sound;
+
return $self;
}
} else {
$self->{gui}->show_semaphore(undef);
$self->{semaphore} = undef;
+ $self->{sound}->start();
}
return FALSE;
}
$self->car($car)->set_global_best($car == $id);
$self->car($car)->print_best_lap;
}
+
+ if (!$self->{race_running} || $self->{round} > 1) {
+ # skip the first round in the race
+ $self->{sound}->best_lap($id);
+ }
return 1;
}
return 0;
if ($self->{round} && $self->{race_rounds}
&& $self->{round} > $self->{race_rounds}) {
+ if (!$self->{race_finishing}) {
+ $self->{sound}->winner($new_order[0]);
+ }
$self->{race_finishing} = 1;
}