OLD | NEW |
1 part of game; | 1 part of game; |
2 | 2 |
3 const double _steeringThreshold = 0.0; | 3 const double _steeringThreshold = 0.0; |
4 const double _steeringMax = 150.0; | 4 const double _steeringMax = 150.0; |
5 | 5 |
6 // Random generator | 6 // Random generator |
7 Math.Random _rand = new Math.Random(); | 7 Math.Random _rand = new Math.Random(); |
8 | 8 |
9 const double _gameSizeWidth = 1024.0; | 9 const double _gameSizeWidth = 1024.0; |
10 const double _gameSizeHeight = 1024.0; | 10 const double _gameSizeHeight = 1024.0; |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 _starScales = []; | 380 _starScales = []; |
381 _opacity = []; | 381 _opacity = []; |
382 | 382 |
383 for (int i = 0; i < _numStars; i++) { | 383 for (int i = 0; i < _numStars; i++) { |
384 _starPositions.add(new Point(_rand.nextDouble() * _gameSizeWidth, _rand.ne
xtDouble() * _gameSizeHeight)); | 384 _starPositions.add(new Point(_rand.nextDouble() * _gameSizeWidth, _rand.ne
xtDouble() * _gameSizeHeight)); |
385 _starScales.add(_rand.nextDouble()); | 385 _starScales.add(_rand.nextDouble()); |
386 _opacity.add(_rand.nextDouble() * 0.5 + 0.5); | 386 _opacity.add(_rand.nextDouble() * 0.5 + 0.5); |
387 } | 387 } |
388 } | 388 } |
389 | 389 |
390 void paint(PictureRecorder canvas) { | 390 void paint(RenderCanvas canvas) { |
391 // Setup paint object for opacity and transfer mode | 391 // Setup paint object for opacity and transfer mode |
392 Paint paint = new Paint(); | 392 Paint paint = new Paint(); |
393 paint.setTransferMode(TransferMode.plus); | 393 paint.setTransferMode(TransferMode.plus); |
394 | 394 |
395 double baseScaleX = 32.0/_img.width; | 395 double baseScaleX = 32.0/_img.width; |
396 double baseScaleY = 32.0/_img.height; | 396 double baseScaleY = 32.0/_img.height; |
397 | 397 |
398 // Draw each star | 398 // Draw each star |
399 for (int i = 0; i < _numStars; i++) { | 399 for (int i = 0; i < _numStars; i++) { |
400 Point pos = _starPositions[i]; | 400 Point pos = _starPositions[i]; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 double dy = a.y - b.y; | 469 double dy = a.y - b.y; |
470 if (dx < 0.0) dx = -dx; | 470 if (dx < 0.0) dx = -dx; |
471 if (dy < 0.0) dy = -dy; | 471 if (dy < 0.0) dy = -dy; |
472 if (dx > dy) { | 472 if (dx > dy) { |
473 return dx + dy/2.0; | 473 return dx + dy/2.0; |
474 } | 474 } |
475 else { | 475 else { |
476 return dy + dx/2.0; | 476 return dy + dx/2.0; |
477 } | 477 } |
478 } | 478 } |
OLD | NEW |