Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > C++ Builder
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

 
 
Herramientas Buscar en Tema Desplegado
  #12  
Antiguo 28-10-2016
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 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 de nuevo.

La idea anterior, encapsulada y un poco mas organizada :

Ship.h
Código PHP:
#ifndef ShipH
#define ShipH

#include <ExtCtrls.hpp>
#include <jpeg.hpp>

const int MAX_X 1366;

class 
Ship {
private:
  
TImage*      _image;
  
TTimer*      _timer;
  
TWinControl_parent;
  
TPoint       _route[MAX_X];
  
TPoint       _start;
  
TPoint       _stop;
  
int          _inx;
  
int          _toproute;
  
int calcRoute();
  const 
TPoint &getPt( const int &ix );
  
void setParentTWinControlparent );
  
void __fastcall _timerTimer(TObject *Sender);
public:
  
ShipTWinControlparent, const TPointstart, const TPointstop);
  ~
Ship();
  
__property TWinControlParent = { read _parentwrite setParent };
  
__property TImageImage = { read _imagewrite _image };
  
__property TTimerTimer = { read _timerwrite _timer };
  
__property int TopRoute = { read _toproute };
  
__property TPoint Route[int] = { read getPt };
};
 
#endif 
Ship.cpp
Código PHP:
#pragma hdrstop
#include "Ship.h"  
#pragma package(smart_init)

Ship::ShipTWinControlparent, const TPointstart, const TPointstop ) {
  
_start     start;
  
_stop      stop;
  
_inx       0;
  
_toproute  calcRoute();
  
_image = new TImage(NULL);
  
_image->Visible  false;
  
_image->Parent   parent;
  
_image->Left     start.x;
  
_image->Top      start.y;
  
_timer = new TTimer(NULL);
  
_timer->Interval 20
  
_timer->Enabled  false;
  
_timer->OnTimer  _timerTimer;
}

Ship::~Ship()
{
  
delete _timer;
  
delete _image;
}

/* private */
int Ship::calcRoute()
{
  
int dx _stop._start.x;
  
int dy _stop._start.y;
  
int cx;

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

const 
TPointShip::getPt( const int &ix )
{
  return 
_route[ix];
}

void Ship::setParentTWinControlparent )
{
  
_image->Parent parent;
}

void __fastcall Ship::_timerTimer(TObject *Sender)
{
  
_image->Visible _inx _toproute;
  
_timer->Enabled _image->Visible;
  if (
_image->Visible) {
    
_image->Left _route[_inx].x;
    
_image->Top  _route[_inx].y;
  }
  else {
    
_inx 0;
  }
  ++
_inx;

Ejemplo del uso:
Código PHP:
#pragma hdrstop
#include "Unit1.h"
#include "Ship.h"
#pragma package(smart_init)
#pragma resource "*.dfm"


TForm1 *Form1;

__fastcall TForm1::TForm1(TComponentOwner)
  : 
TForm(Owner)
{
}
Ships1;
Ships2;
Ships3;

void __fastcall TForm1::FormCreate(TObject *Sender)
{
 
s1 = new ShipthisPoint(10,100), Point240,200) );
 
s2 = new ShipthisPoint(  50,  50 ), Point150300 ) );
 
s3 = new ShipthisPoint(  8090 ), Point(  220100 ) );

 
s1->Image->Picture->LoadFromFile("face-smile.jpg");
 
s2->Image->Picture->LoadFromFile("face-sad.jpg");
 
s3->Image->Picture->LoadFromFile("face-monkey.jpg");

 
s1->Timer->Interval 10;
 
s2->Timer->Interval 10;
 
s3->Timer->Interval 10;
}

void __fastcall TForm1::btnStartClick(TObject *Sender)
{
  
s1->Timer->Enabled true;
  
s2->Timer->Enabled true;
  
s3->Timer->Enabled true;
}

void __fastcall TForm1::FormDestroy(TObject *Sender)
{
  
delete s1;
  
delete s2;
  
delete s3;

Saludos
__________________
Daniel Didriksen

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


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Copiar TLabel.Canvas sobre TBitmap.Canvas @CSE1970 Gráficos 2 23-10-2013 12:46:53
Impresion linea por linea en tiquete de caja Livey Impresión 2 21-12-2010 00:21:05
uso de DLL creada con VB6 lichi OOP 0 12-09-2005 16:55:46
Como imprimir por canvas un caracter de salto de linea buitrago Impresión 3 30-08-2004 11:10:05
¿Cómo borrar un grid sin tener que ir línea a línea? Isaac Varios 2 18-02-2004 16:13:14


La franja horaria es GMT +2. Ahora son las 18:19:33.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi