Changeset 35763 for lang/haxe

Show
Ignore:
Timestamp:
10/29/09 00:52:53 (4 years ago)
Author:
hoge1e3
Message:
 
Location:
lang/haxe/Tonyu2
Files:
3 added
4 modified

Legend:

Unmodified
Added
Removed
  • lang/haxe/Tonyu2/make.bat

    r35690 r35763  
    1 C:\bin\_other\haxe-2.04-win\haxe make.hxml 
     1..\haxe make.hxml 
  • lang/haxe/Tonyu2/test/haxe/Boot.hx

    r35663 r35763  
    11 
    22class Boot {  
    3   public static var chars:Array<Test>; 
     3  public static var chars:Array<tonyu.TSprite>; 
    44  static function main() { 
    5       //var tf= new Test(); 
    65          chars = []; 
    7 //        var sh= new Shape(); 
    8 //        flash.Lib.current.addChild(tf); 
    9 //        sh.addChild(tf); 
    106          var i:Int; 
    117                for (i in 0 ... 99) { 
     
    139                   tf.x=Std.random(200); 
    1410                   tf.y=Std.random(200); 
    15                    tf.text="大";   
    16                    flash.Lib.current.addChild(tf); 
     11                    
     12                   //flash.Lib.current.addChild(tf); 
    1713                   chars.push(tf); 
    1814                } 
     
    2218                for (tf in chars) { 
    2319                        tf.move(); 
     20                        tf.draw(); 
    2421                } 
    2522          }); 
  • lang/haxe/Tonyu2/test/haxe/Test.hx

    r35663 r35763  
    1 class Test extends flash.text.TextField { 
    2    var state:Int; 
    3    var vx:Int; 
    4    var vy:Int; 
    5    //public var id:Int; 
    6    //static var idSeq:Int=0; 
    7    public function new() { 
    8       super(); 
    9       state=0; 
    10           vx=1; 
    11           vy=1; 
    12           //id=idSeq++; 
    13    } 
    14    function crashTo(t:Test):Bool{ 
    15           return Math.abs(t.x-x)+Math.abs(t.y-y)<10; 
    16    } 
    17    public function move() { 
     1class Test extends tonyu.TSprite { 
     2   public var vx:Float; 
     3   public var vy:Float; 
     4   
     5   public override function move() { 
    186       while (true) { 
    19              switch (state) { 
    20                     case 0: 
    21                            text="x"; 
    22                            state=1; 
    23                            break; 
    24                 case 1:  // while(x<100) { 
    25                        x+=vx; y+=vy; 
    26                            if (x>200) vx=-vx; 
    27                            if (x<0) vx=-vx; 
    28                            if (y>200) vy=-vy; 
    29                            if (y<0) vy=-vy; 
    30                            var t:Test; 
    31                            for (t in Boot.chars) { 
    32                                if (this!=t && crashTo(t)) { 
    33                                       vx=-Std.random(3)+1; 
    34                                           vy=-Std.random(3)+1; 
     7                         switch (state) { 
     8                                case 0: 
     9                                   vx=rnd()*3; 
     10                                   vy=rnd()*3; 
     11                                   state=1; 
     12                                   break; 
     13                                case 1:  // while(1) { 
     14                                   var sx=x,sy=y; 
     15                                   x+=vx; y+=vy; 
     16                                    
     17                                   if (x>200) {x=200;vx=-abs(vx);} 
     18                                   if (x<0) {x=0;vx=abs(vx);} 
     19                                   if (y>200) {y=200;vy=-abs(vy);} 
     20                                   if (y<0) {y=0;vy=abs(vy);} 
     21                                   var t:Test; 
     22                                   for (t in Boot.chars) { 
     23                                           if (this!=t && crashTo(t)) { 
     24                                                  x=sx; 
     25                                                  y=sy; 
     26                                                  vx=-vx*0.9; 
     27                                                  vy=-vy*0.9; 
     28                                           } 
    3529                                   } 
    36                            } 
    37                            state=2; 
    38                            return;  // update 
    39                         case 2: 
    40                            state=1; 
    41                            break;  // } 
    42                         case 3: 
    43                 } 
     30                                   vy+=0.04; 
     31                                   state=2; 
     32                                   return;         // update(); 
     33                                case 2: 
     34                                   state=1; 
     35                                   break;  // } 
     36                                case 3: 
     37                        } 
    4438                } 
    4539   }