Exemplo n.º 1
0
 public override void OnInit()
 {
     ShowFps = true;
     AddObject(ImageObject.FromFile("back.png", 0, 0));
     Height = 500;
     Width  = 400;
     _bird  = ImageObject.FromFile("an.png", 20, 300);
     _score = new TextObject(ColorResource.Black,
                             "Click to jump.", 16, 10, 20);
     ResetGravity();
     _lambda = () =>
     {
         _bird.Y = 200;
         _bird.ClearAnims();
         ResetGravity();
         MessageBox.Show(@"GG!");
         _score.Text = "Restart!";
         _s          = 0;
     };
     foreach (var o in _lo)
     {
         _bird.TargetList.Add(new Pair <PhysicalObject, Action>(o, _lambda));
     }
     foreach (var o in _lou)
     {
         _bird.TargetList.Add(new Pair <PhysicalObject, Action>(o, _lambda));
     }
     AddObject(_bird, _score);
     _timer = new FTimeListener(1700, () =>
     {
         _score.Text = "Score: " + _s++;
         _lou[_louLast].ClearAnims();
         _lo[_loLast].ClearAnims();
         _lou[_louLast].Y  = H2;
         _lo[_loLast].Y    = H1;
         _loLast           = Random.Next(_lo.Length);
         _louLast          = Random.Next(_lou.Length);
         var delta         = Random.Next(50) - 50;
         _lou[_louLast].X  = 550;
         _lo[_loLast].X    = 550;
         _lou[_louLast].Y += delta;
         _lo[_loLast].Y   += delta;
         _lou[_louLast].AddAnims(new SimpleMove(-400, 0));
         _lo[_loLast].AddAnims(new SimpleMove(-400, 0));
         AddObject(_lo[_loLast], _lou[_louLast]);
     }, true);
     AddTimeListener(_timer);
     base.OnInit();
 }
Exemplo n.º 2
0
 public override void OnClick(double x, double y, int button)
 {
     _bird.ClearAnims();
     ResetGravity();
     base.OnClick(x, y, button);
 }