Guest User

Untitled

a guest
Oct 15th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package ;
  2. import com.eclecticdesignstudio.motion.Actuate;
  3. import flash.display.Bitmap;
  4. import gm2d.blit.Layer;
  5. import gm2d.blit.Tile;
  6. import gm2d.blit.Tilesheet;
  7. import gm2d.blit.Viewport;
  8. import gm2d.Screen;
  9. import gm2d.Game;
  10. import haxe.FastList;
  11. import haxe.Timer;
  12.  
  13. import flash.Lib;
  14.  
  15. class Rana
  16. {
  17.     public var img : Tile;
  18.     public var x : Float;
  19.     public var y : Float;
  20.     public function new( img : Tile, x : Float, y : Float )
  21.     {
  22.         this.img = img;
  23.         this.x = x;
  24.         this.y = y;
  25.     }
  26. }
  27.  
  28. class Gm2dtest extends Screen
  29. {
  30.    
  31.     var mViewport:gm2d.blit.Viewport;
  32.     var tile : Tile;
  33.     var totora : Tile;
  34.     var ranas : FastList<Rana>;
  35.     var layer : Layer;
  36.    
  37.     public function new()
  38.     {
  39.         super();
  40.         mViewport = gm2d.blit.Viewport.create(800, 480, Viewport.BG_DONT_CARE, 0x000000);
  41.        
  42.         var tilesheet : Tilesheet = new Tilesheet(ApplicationMain.getAsset("assets/background.png"));
  43.         tile = tilesheet.partition(800, 480)[0];
  44.        
  45.         ranas = new FastList<Rana>();
  46.         tilesheet = new Tilesheet(ApplicationMain.getAsset("assets/good_idle_03.png"));
  47.         for ( i in 1...20 )
  48.         {
  49.             var rana : Rana = new Rana(tilesheet.partition(61, 44)[0], Math.random() * 800, Math.random() * 480);
  50.             rana.img.alignCenter();
  51.             ranas.add(rana);
  52.         }
  53.        
  54.         layer = mViewport.createLayer();
  55.         makeCurrent();
  56.         addChild(mViewport);
  57.         actuar();
  58.     }
  59.    
  60.     public function actuar() : Void
  61.     {
  62.         var rndTime : Float = Math.random() * 2 + 1;
  63.         for ( rana in ranas )
  64.             Actuate.tween(rana, rndTime, { x:Math.random() * 800, y:Math.random() * 480 }, false);
  65.         Timer.delay(actuar, Std.int(rndTime*1000));
  66.     }
  67.    
  68.     override public function updateDelta(inDT:Float):Void
  69.     {
  70.         super.updateDelta(inDT);
  71.         layer.clear();
  72.         layer.addTile(tile, 0, 0);
  73.         for ( rana in ranas )
  74.             layer.addTile(rana.img, rana.x, rana.y);
  75.     }
  76.    
  77. }
  78.  
  79. class Main
  80. {
  81.    
  82.     public static function main()
  83.     {
  84.         Game.showFPS = true;
  85.         Game.fpsColor = 0x200000;
  86.         Game.backgroundColor = 0x202040;
  87.         new Gm2dtest();
  88.     }
  89.    
  90. }
Add Comment
Please, Sign In to add comment