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

Unified Diff: samples/third_party/pop-pop-win/web/game.dart

Issue 200723008: samples/poppopwin: upgrade to first-class sample (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fixed pkgbuild.status for rename Created 6 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samples/third_party/pop-pop-win/web/favicon.ico ('k') | samples/third_party/pop-pop-win/web/game_web.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/third_party/pop-pop-win/web/game.dart
diff --git a/samples/third_party/pop-pop-win/web/game.dart b/samples/third_party/pop-pop-win/web/game.dart
deleted file mode 100644
index 3cb58f1654ce70f855b4646c79f10e19a4ec8c65..0000000000000000000000000000000000000000
--- a/samples/third_party/pop-pop-win/web/game.dart
+++ /dev/null
@@ -1,122 +0,0 @@
-library game;
-
-import 'dart:html';
-import 'dart:web_audio';
-import 'package:bot/bot.dart';
-import 'package:bot_web/bot_html.dart';
-import 'package:bot_web/bot_texture.dart';
-import 'package:poppopwin/canvas.dart';
-import 'package:poppopwin/platform_target.dart';
-import 'package:poppopwin/html.dart';
-
-import 'texture_data.dart';
-
-part '_audio.dart';
-
-const String _TRANSPARENT_TEXTURE = 'images/transparent_animated.png';
-const String _OPAQUE_TEXTURE = 'images/dart_opaque_01.jpg';
-const String _TRANSPARENT_STATIC_TEXTURE = 'images/transparent_static.png';
-
-const int _LOADING_BAR_PX_WIDTH = 398;
-
-DivElement _loadingBar;
-ImageLoader _imageLoader;
-
-_Audio _audio;
-
-void startGame(PlatformTarget platform) {
- initPlatform(platform);
-
- _loadingBar = querySelector('.sprite.loading_bar');
- _loadingBar.style.display = 'block';
- _loadingBar.style.width = '0';
-
- _imageLoader = new ImageLoader([_TRANSPARENT_TEXTURE,
- _OPAQUE_TEXTURE]);
- _imageLoader.loaded.listen(_onLoaded);
- _imageLoader.progress.listen(_onProgress);
- _imageLoader.load();
-
- _audio = new _Audio();
-}
-
-void _onProgress(args) {
- int completedBytes = _imageLoader.completedBytes;
- int totalBytes = _imageLoader.totalBytes;
-
- completedBytes += _audio.completedBytes;
- totalBytes += _audio.totalBytes;
-
- final percent = completedBytes / totalBytes;
- final percentClean = (percent * 1000).floor() / 10;
-
- final barWidth = percent * _LOADING_BAR_PX_WIDTH;
- _loadingBar.style.width = '${barWidth.toInt()}px';
-}
-
-void _onLoaded(args) {
- if(_imageLoader.state == ResourceLoader.StateLoaded && _audio.done) {
-
- //
- // load textures
- //
- final opaqueImage = _imageLoader.getResource(_OPAQUE_TEXTURE);
- final transparentImage = _imageLoader.getResource(_TRANSPARENT_TEXTURE);
-
- // already loaded. Used in CSS.
- final staticTransparentImage = new ImageElement(src: _TRANSPARENT_STATIC_TEXTURE);
-
- final textures = getTextures(transparentImage, opaqueImage, staticTransparentImage);
-
- final textureData = new TextureData(textures);
-
- // run the app
- querySelector('#loading').style.display = 'none';
- _runPPW(textureData);
- }
-}
-
-void _runPPW(TextureData textureData) {
- _updateAbout();
-
- targetPlatform.aboutChanged.listen((_) => _updateAbout());
-
- final size = targetPlatform.renderBig ? 16 : 7;
- final int m = (size * size * 0.15625).toInt();
-
- final CanvasElement gameCanvas = querySelector('#gameCanvas');
- gameCanvas.style.userSelect = 'none';
-
- final gameRoot = new GameRoot(size, size, m, gameCanvas, textureData);
-
- // disable touch events
- window.onTouchMove.listen((args) => args.preventDefault());
-
- window.onKeyDown.listen(_onKeyDown);
-
- querySelector('#popup').onClick.listen(_onPopupClick);
-
- titleClickedEvent.listen((args) => targetPlatform.toggleAbout(true));
-}
-
-void _onPopupClick(MouseEvent args) {
- if(!(args.toElement is AnchorElement)) {
- targetPlatform.toggleAbout(false);
- }
-}
-
-void _onKeyDown(KeyboardEvent args) {
- switch(args.keyCode) {
- case 27: // esc
- targetPlatform.toggleAbout(false);
- break;
- case 72: // h
- targetPlatform.toggleAbout();
- break;
- }
-}
-
-void _updateAbout() {
- var popDisplay = targetPlatform.showAbout ? 'inline-block' : 'none';
- querySelector('#popup').style.display = popDisplay;
-}
« no previous file with comments | « samples/third_party/pop-pop-win/web/favicon.ico ('k') | samples/third_party/pop-pop-win/web/game_web.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698