Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #2  
Antiguo 07-06-2012
Avatar de duilioisola
[duilioisola] duilioisola is offline
Miembro Premium
 
Registrado: ago 2007
Ubicación: Barcelona, España
Posts: 1.806
Poder: 22
duilioisola Es un diamante en brutoduilioisola Es un diamante en brutoduilioisola Es un diamante en bruto
Creo que te falta tener un campo que te diga la dirección en que se está moviendo la pelota.
En tal caso, el incrementeo/decremento de tu posición dependerá de la dirección:
Algo así:

Código Delphi [-]
// valor de direcciones
// 1 2 3
// 4 * 8
// 5 6 7

// inicializo al centro de la pantalla, direccion 5 (derecha, abajo)
col := 40;
lin := 12;
direccion := 5
k := 0;
repeat
   case direccion of
      1 :
      begin
         dec(col);
         dec(lin);
      end
      2 :
      begin
         dec(lin);
      end
      3 :
      begin
         inc(col);
         dec(lin);
      end
      4 :
      begin
         dec(col);
      end
      5 :
      begin
         dec(col);
         inc(lin);
      end
      6 :
      begin
         inc(lin);
      end
      7 :
      begin
         inc(col);
         inc(lin);
      end
      8 :
      begin
         dec(col);
      end
   end // case

   // Ahora me toca ver si me pase de los limites y cambiar la direccion segun corresponda
   // Si voy hacia arriba
   if (direccion >= 1) and (direccion <= 3)
      // y me paso del limite
      if (lin = 0) then
      begin
         direccion := direccion + 4; // 1 --> 5, 2 --> 6, 3 --> 7
         line := 1;
      end;

   // Si voy hacia abajo
   if (direccion >= 5) and (direccion <= 7)
      // y me paso del limite
      if (lin > 25) then
      begin
         direccion := direccion - 4; // 5 --> 1, 6 --> 2, 7 --> 3
         lin := 24;
      end;

   // Si voy a izquierda
   if (direccion = 1) or (direccion = 4) or (direccion = 5)
      // y me paso del limite
      if (col = 0) then
      begin
         case direccion of
            1 : direccion := 3;
            4 : direccion := 8;
            5 : direccion := 7;
         end;
         col := 0;
      end;

   // Si voy a derecha
   if (direccion = 3) or (direccion = 8) or (direccion = 7)
      // y me paso del limite
      if (col = 81) then
      begin
         case direccion of
            3 : direccion := 1;
            8 : direccion := 4;
            7 : direccion := 5;
         end;
         col := 80;
      end;

   clrscr;
   GotoXY(col,lin);
   write('O')
until k = 300;
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
Problema con animacion dfv Gráficos 4 19-10-2006 15:49:32
animación Delphi anto1178 Varios 1 31-08-2006 23:17:24
Animacion por frames Drake C++ Builder 5 26-06-2006 12:52:04
Animacion por frames Drake C++ Builder 2 28-12-2005 19:30:44
Animacion Troyano Varios 2 16-06-2004 15:29:02


La franja horaria es GMT +2. Ahora son las 14:08:52.


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