Pascal/Turbo Pascal - Como hago para que no se me logge cuando cambio de posicion el cuadrito!..

 
Vista:
sin imagen de perfil

Como hago para que no se me logge cuando cambio de posicion el cuadrito!..

Publicado por Esteban (12 intervenciones) el 05/11/2013 16:50:48
Lo que pasa es que cuando entra al if move='M', y incrementa el X. Cuando cambia la posicion tarda. Y se ve muy feo.. ayuda...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
program linea;
uses
wincrt, graph;
var
drive, modo : integer;
x,y:word;
move:char;
begin
drive := detect;
initgraph(drive, modo,'c:\fpc'); {ponlo a tu direccion}
x:=500;
y:=510;
 
 
repeat
rectangle(x,500,y,510);
move:=readkey;
 
if move='M' then
if (x<1010) and (y<1020) then
	begin
	x:=x+10;
	y:=y+10;
	rectangle(x,500,y,510);
	cleardevice;
	end;
if move='K' then
if (x>10) and (y>20) then
	begin
	x:=x-10;
	y:=y-10;
	rectangle(x,500,y,510);
	cleardevice;
	end;
until move='S';
 
end.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Como hago para que no se me logge cuando cambio de posicion el cuadrito!..

Publicado por ramon (2158 intervenciones) el 05/11/2013 23:13:28
Disculpa pero con cleardevice estas retardando mucho prueba a borrar solo el rectángulo o usa
getimagen y putimagen.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Como hago para que no se me logge cuando cambio de posicion el cuadrito!..

Publicado por ramon (2158 intervenciones) el 08/11/2013 21:11:29
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{Mira esto te puede ayudar }
 
program muevepaleta;
 uses
    wincrt, graph;
 type
    paleta = array[0..2040] of byte;
  var
    pale : paleta;
    x, y, xp, yp : integer;
    drive, modo : integer;
    pulsada : word;
 
  function tecla : word;
  var
    tec : char;
  begin
     tec := readkey;
     if tec = #0 then
     tecla := word(ord(readkey)) shl 8
   else
     tecla := ord(tec);
  end;
 
  procedure tomapaleta(x,y,xx,yy : integer; tm : char);
  var
    dig, t1, t2 : integer;
  begin
      if upcase(tm) = 'C' then
      begin
      dig := 0;
      for t1 := x to xx do
        for t2 := y to yy do
        begin
           pale[dig] := getpixel(t1,t2);
           dig := dig + 1;
        end;
      end;
      if upcase(tm) = 'D' then
      begin
         dig := 0;
          for t1 := x to xx do
           for t2 := y to yy do
           begin
              putpixel(t1,t2,pale[dig]);
              dig := dig + 1;
           end;
       end;
  end;
 
  procedure iniciografico;
  begin
      drive := detect;
      initgraph(drive,modo,'c:\tp\bgi');
      if graphresult <> 0 then
      halt(1)
    else
       begin
          clearviewport;
       end;
  end;
 
  begin
     iniciografico;
     x := 1;
     y := getmaxy - 10;
     outtextxy(80,8,'Pulsando [ESC]=Termina, Flechas=[Derecha] y ' +
                                              '[Izquierda]=Mueven');
     line(1,y + 4,getmaxx - 5,y + 4);
   repeat
     tomapaleta(x,y,x + 20,y + 8,'c');
     rectangle(x,y,x + 20,y + 8);
     pulsada := tecla;
     tomapaleta(x,y,x + 20,y + 8,'d');
     if pulsada = 19712 then
     begin
     x := x + 25;
     if x > getmaxx - 25 then
     x := getmaxx - 25;
     end;
     if pulsada = 19200 then
     begin
     x := x - 25;
     if x < 1 then
     x := 1;
     end;
   until pulsada = 27;
     closegraph;
  end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar