OLD | NEW |
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 13 matching lines...) Expand all Loading... |
24 "images/ball-13acfa.png", "images/ball-265897.png", | 24 "images/ball-13acfa.png", "images/ball-265897.png", |
25 "images/ball-b6b4b5.png", "images/ball-c0000b.png", | 25 "images/ball-b6b4b5.png", "images/ball-c0000b.png", |
26 "images/ball-c9c9c9.png" | 26 "images/ball-c9c9c9.png" |
27 ]; | 27 ]; |
28 | 28 |
29 DivElement root; | 29 DivElement root; |
30 num lastTime; | 30 num lastTime; |
31 List<Ball> balls; | 31 List<Ball> balls; |
32 | 32 |
33 Balls() : | 33 Balls() : |
34 lastTime = new Date.now().millisecondsSinceEpoch, | 34 lastTime = new DateTime.now().millisecondsSinceEpoch, |
35 balls = new List<Ball>() { | 35 balls = new List<Ball>() { |
36 root = new DivElement(); | 36 root = new DivElement(); |
37 document.body.nodes.add(root); | 37 document.body.nodes.add(root); |
38 makeAbsolute(root); | 38 makeAbsolute(root); |
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 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |