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

Side by Side Diff: samples/clock/balls.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/chat/dart_client/chat.dart ('k') | samples/clock/clock.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of clock; 5 part of clock;
6 6
7 int get clientWidth => window.innerWidth; 7 int get clientWidth => window.innerWidth;
8 8
9 int get clientHeight => window.innerHeight; 9 int get clientHeight => window.innerHeight;
10 10
(...skipping 28 matching lines...) Expand all
39 setElementSize(root, 0.0, 0.0, 0.0, 0.0); 39 setElementSize(root, 0.0, 0.0, 0.0, 0.0);
40 } 40 }
41 41
42 void tick(num now) { 42 void tick(num now) {
43 showFps(1000.0 / (now - lastTime + 0.01)); 43 showFps(1000.0 / (now - lastTime + 0.01));
44 44
45 double delta = min((now - lastTime) / 1000.0, 0.1); 45 double delta = min((now - lastTime) / 1000.0, 0.1);
46 lastTime = now; 46 lastTime = now;
47 47
48 // incrementally move each ball, removing balls that are offscreen 48 // incrementally move each ball, removing balls that are offscreen
49 balls = balls.filter((ball) => ball.tick(delta)); 49 balls = balls.where((ball) => ball.tick(delta)).toList();
50 collideBalls(delta); 50 collideBalls(delta);
51 } 51 }
52 52
53 void collideBalls(double delta) { 53 void collideBalls(double delta) {
54 balls.forEach((b0) { 54 balls.forEach((b0) {
55 balls.forEach((b1) { 55 balls.forEach((b1) {
56 // See if the two balls are intersecting. 56 // See if the two balls are intersecting.
57 double dx = (b0.x - b1.x).abs(); 57 double dx = (b0.x - b1.x).abs();
58 double dy = (b0.y - b1.y).abs(); 58 double dy = (b0.y - b1.y).abs();
59 double d2 = dx * dx + dy * dy; 59 double d2 = dx * dx + dy * dy;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 y = clientHeight.toDouble(); 167 y = clientHeight.toDouble();
168 vy *= -RESTITUTION; 168 vy *= -RESTITUTION;
169 } 169 }
170 170
171 // Position the element. 171 // Position the element.
172 setElementPosition(elem, x - RADIUS, y - RADIUS); 172 setElementPosition(elem, x - RADIUS, y - RADIUS);
173 173
174 return true; 174 return true;
175 } 175 }
176 } 176 }
OLDNEW
« no previous file with comments | « samples/chat/dart_client/chat.dart ('k') | samples/clock/clock.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698