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 Temas de Hoy

 
 
Herramientas Buscar en Tema Desplegado
  #3  
Antiguo 30-12-2008
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 19.442
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Una posible rtuina de colisiones podría ser algo así:

Código Delphi [-]
// Calcular colisión entre dos objetos
function TForm1._CalculateColision(sh1, sh2:TShape): boolean;
var
  r1, r2, b1, b2:Integer;
begin

  Result := False;

  r1 := (sh1.Left + sh1.Width);
  r2 := (sh2.Left + sh2.Width);
  b1 := (sh1.Top + sh1.Height);
  b2 := (sh2.Top + sh2.Height);

  // COLISION?
  if (((sh1.Left < sh2.Left) and (r1 > sh2.Left)) and
      ((sh1.Top < sh2.Top) and (b1 > sh2.Top))) or

     (((sh2.Left < sh1.Left) and (r2 > sh1.Left)) and
      ((sh2.Top < sh1.Top) and (b2 > sh1.Top))) or

     (((sh1.Left < sh2.Left) and (r1 > sh2.Left)) and
      ((sh2.Top < sh1.Top) and (b2 > sh1.Top))) or

     (((sh2.Left < sh1.Left) and (r2 > sh1.Left)) and
      ((sh1.Top < sh2.Top) and (b1 > sh2.Top))) then begin


    Result := True;
  end;

end;

Está en Delphi y usa TShapes, pero es fácil de entender y creo que puedes pasarla a Builder y cambiar los TShape por TButton sin grandes problemas.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.

Última edición por Neftali [Germán.Estévez] fecha: 30-12-2008 a las 10:32:34.
Responder Con Cita
 



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
Detectar llamadas pollo_c Varios 4 05-02-2007 11:14:21
Colision registros Bluechip Conexión con bases de datos 3 27-11-2006 07:54:03
Detectar IP Carliviris Varios 3 17-04-2006 19:18:26
Detectar procesador Mic82 Varios 1 12-11-2004 09:45:35
Detectar Hora AM-PM AGAG4 Varios 4 22-10-2004 20:34:18


La franja horaria es GMT +2. Ahora son las 22:14:57.


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