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

Side by Side Diff: sky/examples/game/lib/game_world.dart

Issue 1164633004: Adds support for transfer mode in Paint and SpriteNode classes (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Fixes indentations and whitespaces Created 5 years, 6 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
« no previous file with comments | « sky/engine/core/painting/Paint.idl ('k') | sky/examples/game/lib/sprite_node.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 part of game; 1 part of game;
2 2
3 class GameWorld extends TransformNode { 3 class GameWorld extends TransformNode {
4 4
5 World world; 5 World world;
6 List<Body> bodies = []; 6 List<Body> bodies = [];
7 Image _image; 7 Image _image;
8 8
9 GameWorld(ImageMap images) { 9 GameWorld(ImageMap images) {
10 this.width = 1024.0; 10 this.width = 1024.0;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 Math.Random rand = new Math.Random(); 59 Math.Random rand = new Math.Random();
60 body.setTransform(new Vector2(rand.nextDouble() * this.width, rand.nextDoubl e() * this.height), 0.0); 60 body.setTransform(new Vector2(rand.nextDouble() * this.width, rand.nextDoubl e() * this.height), 0.0);
61 body.applyLinearImpulse(new Vector2(rand.nextDouble()*10000.0-5000.0, rand.n extDouble()*10000.0-5000.0), new Vector2(0.0, 0.0), true); 61 body.applyLinearImpulse(new Vector2(rand.nextDouble()*10000.0-5000.0, rand.n extDouble()*10000.0-5000.0), new Vector2(0.0, 0.0), true);
62 62
63 // Add to list 63 // Add to list
64 bodies.add(body); 64 bodies.add(body);
65 65
66 SpriteNode sprt = new SpriteNode.withImage(_image); 66 SpriteNode sprt = new SpriteNode.withImage(_image);
67 sprt.width = radius*2; 67 sprt.width = radius*2;
68 sprt.height = radius*2; 68 sprt.height = radius*2;
69 sprt.colorOverlay = new Color(0x33ff0000);
70 sprt.transferMode = TransferMode.plusMode;
69 body.userData = sprt; 71 body.userData = sprt;
70 this.children.add(sprt); 72 this.children.add(sprt);
71 } 73 }
72 74
73 void update(double dt) { 75 void update(double dt) {
74 world.stepDt(1.0/60.0, 10, 10); // Pass in dt 76 world.stepDt(1.0/60.0, 10, 10); // Pass in dt
75 77
76 bodies.forEach(updateBody); 78 bodies.forEach(updateBody);
77 } 79 }
78 80
(...skipping 13 matching lines...) Expand all
92 } 94 }
93 if (body.position[1] > this.height + sprt.height/2) { 95 if (body.position[1] > this.height + sprt.height/2) {
94 body.setTransform(new Vector2(body.position[0], body.position[1] - (this.h eight + sprt.height)), rot); 96 body.setTransform(new Vector2(body.position[0], body.position[1] - (this.h eight + sprt.height)), rot);
95 } 97 }
96 98
97 // Update sprite 99 // Update sprite
98 sprt.position = body.position; 100 sprt.position = body.position;
99 sprt.rotation = body.getAngle(); 101 sprt.rotation = body.getAngle();
100 } 102 }
101 } 103 }
OLDNEW
« no previous file with comments | « sky/engine/core/painting/Paint.idl ('k') | sky/examples/game/lib/sprite_node.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698