Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: samples/pop_pop_win/lib/src/audio.dart

Issue 786443002: Delete pop-pop-win from the repo (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/pop_pop_win/lib/pop_pop_win.dart ('k') | samples/pop_pop_win/lib/src/game.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4 library pop_pop_win.audio;
5
6 import 'dart:math';
7
8 import 'package:stagexl/stagexl.dart';
9
10 class GameAudio {
11 static final Random _rnd = new Random();
12
13 static ResourceManager _resourceManager;
14
15 static const String _WIN = 'win',
16 _CLICK = 'click',
17 _POP = 'Pop',
18 _FLAG = 'flag',
19 _UNFLAG = 'unflag',
20 _BOMB = 'Bomb',
21 _THROW_DART = 'throw';
22
23 static void initialize(ResourceManager resourceManager) {
24 if (_resourceManager != null) throw new StateError('already initialized');
25 _resourceManager = resourceManager;
26 }
27
28 static void win() => _playAudio(_WIN);
29
30 static void click() => _playAudio(_CLICK);
31
32 static void pop() => _playAudio(_POP);
33
34 static void flag() => _playAudio(_FLAG);
35
36 static void unflag() => _playAudio(_UNFLAG);
37
38 static void bomb() => _playAudio(_BOMB);
39
40 static void throwDart() => _playAudio(_THROW_DART);
41
42 static void _playAudio(String name) {
43 if (_resourceManager == null) throw new StateError('Not initialized');
44 switch (name) {
45 case GameAudio._POP:
46 var i = _rnd.nextInt(8);
47 name = '${GameAudio._POP}$i';
48 break;
49 case GameAudio._BOMB:
50 var i = _rnd.nextInt(4);
51 name = '${GameAudio._BOMB}$i';
52 break;
53 }
54 _resourceManager.getSoundSprite('audio').play(name);
55 }
56 }
OLDNEW
« no previous file with comments | « samples/pop_pop_win/lib/pop_pop_win.dart ('k') | samples/pop_pop_win/lib/src/game.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698