Ver Mensaje Individual
  #11  
Antiguo 28-10-2016
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 38
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola Snaked.

A ver... fijate si esta idea te puede servir aunque sea como puntapié inicial.
Código PHP:
//...
const int MAX_X = 1366;

class 
Ship {
private:
  
TPoint _route[MAX_X];
  
TPoint _start;
  
TPoint _stop;
  
int _toproute;
  
int calcRoute();
  const 
TPoint &getPt(const int &ix) { return _route[ix]; }
public:
  
Ship( const TPoint& start, const TPoint& stop);
  
__property int topRoute = { read = _toproute };
  
__property TPoint route[int] = { read = getPt };
};

Ship::Ship( const TPoint& start, const TPoint& stop) {
  
_start = start;
  
_stop  = stop;
  
_toproute  = calcRoute();
}

int Ship::calcRoute()
{
  
int dx = _stop.x - _start.x;
  
int dy = _stop.y - _start.y;
  
int c, x;

  for(
c=0, x = _start.x; x < _stop.x; c++, x++ ) {
    
int y = _start.y + dy * ( x - _start.x ) / dx;
    
_route[c].x = _start.x + x;
    
_route[c].y = y;
  }
  return 
c;
}

Ship ship1 = Ship(Point(  10, 100 ), Point( 240, 200 ));
Ship ship2 = Ship(Point(  50,  50 ), Point( 150, 300 ));
Ship ship3 = Ship(Point(  80, 90 ), Point(  220, 100 ));
int c1, c2, c3;

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  
Image1->Visible  = false;
  
Image2->Visible  = false;
  
Image3->Visible  = false;
  
Timer1->Interval = 15;
  
Timer2->Interval = 15;
  
Timer3->Interval = 15;
  
Timer1->Enabled  = false;
  
Timer2->Enabled  = false;
  
Timer3->Enabled  = false;
}

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
  
Image1->Visible = c1 < ship1.topRoute;
  
Timer1->Enabled = Image1->Visible;
  if (
Image1->Visible) {
    
Image1->Left = ship1.route[c1].x;
    
Image1->Top  = ship1.route[c1].y;
  }
  ++
c1;
}

void __fastcall TForm1::Timer2Timer(TObject *Sender)
{
  
Image2->Visible = c2 < ship2.topRoute;
  
Timer2->Enabled = Image2->Visible;
  if (
Image2->Visible) {
    
Image2->Left = ship2.route[c2].x;
    
Image2->Top  = ship2.route[c2].y;
  }
  ++
c2;
}

void __fastcall TForm1::Timer3Timer(TObject *Sender)
{
  
Image3->Visible = c3 < ship3.topRoute;
  
Timer3->Enabled = Image3->Visible;
  if (
Image3->Visible) {
    
Image3->Left = ship3.route[c3].x;
    
Image3->Top  = ship3.route[c3].y;
  }
  ++
c3;
}

void __fastcall TForm1::btnStartClick(TObject *Sender)
{
  
c1 = c2 = c3 = 0;
  
Timer1->Enabled = true;
  
Timer2->Enabled = true;
  
Timer3->Enabled = true;
}

//... 
Efecto:



Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita