Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Delphi программирование > Паскаль, Turbo Pascal, PascalABC.NET
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 24.08.2012, 16:36   #1
InoyKe
Пользователь
 
Регистрация: 24.08.2012
Сообщений: 15
По умолчанию Где то лаг

Начал писать танчики на паскале, столкнулся с проблемой, немогу найти лаг. В общем, если моб первый запускает снаряд, а я за ним, то когда счётчик движения моего снаряда заканчивается, танк моб, стоит на месте и недвигается, хотя мой танк и двигается и стреляет. При повторном моём выстреле, танк моб опять же двигается, но пока счётчик полёта снаряда идёт. код ниже, кому не лень разберитесь с этим бредом))
InoyKe вне форума Ответить с цитированием
Старый 24.08.2012, 16:38   #2
InoyKe
Пользователь
 
Регистрация: 24.08.2012
Сообщений: 15
По умолчанию

кидаю код частями, тк ограничение((
в таких скобках {} синим, это самые подозрительные места самые подозрительные места.
Код:
uses   GraphABC,crt;
const d = 2;
di = 7;
 label m,m1,m2,m3,s1,w1,d1,a1,uq,uq1,t,uqq;
 var
 c,a4:integer;
   bot: array[1..20] of integer;
   ab   :array[1..2] of integer;
   vy,vyb :integer;
 le:char;
 cht:integer;
 e,r,chtb:integer;
   y:integer;
   e1,r1:integer;
   s:char;
   x,asq,sa:integer;
     g,g1,gg,rg:integer;
    rf,fr:integer;
    sb:integer;
    sh1,sh2,sct3,sht,shtb:integer;
    hodr,ai,ci:integer;
 procedure shag;
      begin
         setpencolor (clWhite);
 Rectangle(rf,e1, fr,r1); Rectangle(rf,e1, fr,r1-75); Circle(x, y, asq); Circle(x, y, sa);
Rectangle(g,e, g1,r) ; Rectangle(gg,e, rg,r); Rectangle(g-17,e+35, g1+37,r-15) ;
Rectangle(gg-27,e+5, rg+7,r-26); Rectangle(rf,e1-3, fr+35,r1-33); Rectangle(rf+3,e1-3, fr-40,r1-33);
case s of
's': begin
e:=e+2; r:=r+2; y:=y+2;  e1:=e1+2; r1:=r1+2;
setpencolor (clBlack); Rectangle(g,e, g1,r) ;
Rectangle(gg,e, rg,r); Circle(x, y, asq); Circle(x, y, sa); Rectangle(rf,e1, fr,r1);
end;
'd':begin x:=x+2;
  g:=g+2; g1:=g1+2; gg:=gg+2; rg:=rg+2; rf:=rf+2; fr:=fr+2;
setpencolor (clBlack); Rectangle(g-17,e+35, g1+37,r-15) ;Rectangle(gg-27,e+5, rg+7,r-26); Circle(x, y, asq);
Circle(x, y, sa); Rectangle(rf,e1-3, fr+35,r1-33);
end;
'w':begin  e:=e-2; r:=r-2; y:=y-2;  e1:=e1-2; r1:=r1-2;
setpencolor (clBlack); Rectangle(g,e, g1,r) ; Rectangle(gg,e, rg,r);
Circle(x, y ,asq); Circle(x, y, sa); Rectangle(rf,e1, fr,r1-75);
end;
 'a': begin  x:=x-2;
  g:=g-2; g1:=g1-2;  gg:=gg-2;  rg:=rg-2;  rf:=rf-2;  fr:=fr-2;
setpencolor (clBlack);Rectangle(g-17,e+35, g1+37,r-15) ; Rectangle(gg-27,e+5, rg+7,r-26);
Circle(x, y, asq);Circle(x, y, sa);Rectangle(rf+3,e1-3, fr-40,r1-33);
end;
end;
end;
 procedure bothod;
       label w;
        begin
        if hodr=1 then begin
        ci:=ci+1;
        ai:=ci mod di;
        if ai>0 then goto w;
        end;
        c:=c+1;
         a4:=c mod d;
        if a4 > 0 then goto w;
        setpencolor (clWhite);
Rectangle(bot[1],bot[2],bot[3],bot[4]) ;Rectangle(bot[5],bot[2], bot[6],bot[4]);Rectangle(bot[9],bot[10], bot[11],bot[12]);
Rectangle(bot[9],bot[10]+36, bot[11]+35,bot[12]+3);Rectangle(bot[9]+3,bot[10]+37, bot[11]-40,bot[12]+3);Rectangle(bot[1]-17,bot[2]+35,bot[3]+37,bot[4]-15) ;
Rectangle(bot[5]-36,bot[2]+5, bot[6]+18,bot[4]-26);Rectangle(bot[9],bot[10]+40, bot[11],bot[12]+40); Circle(bot[7], bot[8], bot[14]); Circle(bot[7], bot[8], bot[13]);
if sb = 4 then begin
  bot[7]:=bot[7]-1; bot[1]:=bot[1]-1; bot[3]:=bot[3]-1; bot[5]:=bot[5]-1; bot[6]:=bot[6]-1; bot[9]:=bot[9]-1; bot[11]:=bot[11]-1;
setpencolor (clBlack); Rectangle(bot[1]-17,bot[2]+35,bot[3]+37,bot[4]-15) ; Rectangle(bot[5]-36,bot[2]+5, bot[6]+18,bot[4]-26); Circle(bot[7], bot[8], bot[14]);
Rectangle(bot[9]+3,bot[10]+37, bot[11]-40,bot[12]+3); Circle(bot[7], bot[8], bot[15]); setpencolor (clred); Circle(bot[7], bot[8], bot[13]);
end;
 if sb = 3 then begin
 bot[7]:=bot[7]+1;  bot[1]:=bot[1]+1; bot[3]:=bot[3]+1;
  bot[5]:=bot[5]+1; bot[6]:=bot[6]+1; bot[9]:=bot[9]+1; bot[11]:=bot[11]+1;
setpencolor (clBlack);Rectangle(bot[1]-17,bot[2]+35,bot[3]+37,bot[4]-15) ;Rectangle(bot[5]-36,bot[2]+5, bot[6]+18,bot[4]-26);Circle(bot[7], bot[8], bot[14]);
Rectangle(bot[9],bot[10]+36, bot[11]+35,bot[12]+3);Circle(bot[7], bot[8], bot[15]);setpencolor (clred);Circle(bot[7], bot[8], bot[13]);
end;
if sb = 1 then begin
bot[2]:=bot[2]+1;
bot[4]:=bot[4]+1;bot[8]:=bot[8]+1; bot[10]:=bot[10]+1;bot[12]:=bot[12]+1;setpencolor (clBlack);
Rectangle(bot[1],bot[2],bot[3],bot[4]) ; Rectangle(bot[5],bot[2], bot[6],bot[4]);Circle(bot[7], bot[8], bot[14]);
Rectangle(bot[9],bot[10]+40, bot[11],bot[12]+40);Circle(bot[7], bot[8], bot[15]);setpencolor (clred);Circle(bot[7], bot[8], bot[13]);
end;
if sb = 2 then begin
bot[2]:=bot[2]-1;bot[4]:=bot[4]-1; bot[8]:=bot[8]-1; bot[10]:=bot[10]-1;bot[12]:=bot[12]-1;
setpencolor (clBlack);Rectangle(bot[1],bot[2],bot[3],bot[4]) ;Rectangle(bot[5],bot[2], bot[6],bot[4]);Circle(bot[7], bot[8], bot[14]);
Rectangle(bot[9],bot[10], bot[11],bot[12]);Circle(bot[7], bot[8], bot[15]);setpencolor (clred);Circle(bot[7], bot[8], bot[13]);
end;
  w:
sleep(2);
end;

Последний раз редактировалось InoyKe; 24.08.2012 в 16:52.
InoyKe вне форума Ответить с цитированием
Старый 24.08.2012, 16:39   #3
InoyKe
Пользователь
 
Регистрация: 24.08.2012
Сообщений: 15
По умолчанию


{procedure vystrel;
label
m,w,s1,w1,d1,a1,uq;
var a:array[1..2] of integer;
sb1:integer;
cht:integer;
begin

a[2]:=y; a[1]:=x; cht:=1;
hodr:=1;

while (true) do begin
uq:
if cht=600 then goto m;
if keypressed then begin
s:=readkey;
case s of
's': begin
if s='f' then goto s1;
le:=s;
s1:
if (le='s') and (r1=396) or (r1>396) then goto uq;
if (le='s') and (r1<396) then shag;
end;
'w' : begin
if s='f' then goto w1;
le:=s;
w1: if (le='w') and (r1=87) then goto uq;
if (le='w') and (r1>87) then shag;
end;
'd' : begin
if s='f' then goto d1;
le:=s;
d1:if (le='d') and (rf=576) then goto uq;
if (le='d') and (rf<576) then shag;
end;
'a' :begin
if s='f' then goto a1;
le:=s;
a1:if (le='a') and (fr=57) then goto uq;
if (le='a') and (fr>57) then shag;
end;
end;
end;




if vy=1 then begin
setpencolor (clWhite); Circle(a[1],a[2]-2 , 1);
cht:=cht+1;
if cht=600 then goto m;
a[2]:=a[2]+1;
setpencolor (clRed);
Circle(a[1],a[2] , 1);
end;
if vy=2 then begin
setpencolor (clWhite);
Circle(a[1],a[2]+2 , 1);
cht:=cht+1;
if cht=600 then goto m;
a[2]:=a[2]-1;
setpencolor (clRed);
Circle(a[1],a[2] , 1);
end;
if vy=3 then begin
setpencolor (clWhite);
Circle(a[1]+2,a[2] , 1);
cht:=cht+1;
if cht=600 then goto m;
a[1]:=a[1]-1;
setpencolor (clRed);
Circle(a[1],a[2] , 1);
end;
if vy=4 then begin
setpencolor (clWhite);
Circle(a[1]-2,a[2], 1);
cht:=cht+1;
if cht=600 then goto m;
a[1]:=a[1]+1;
setpencolor (clRed);
Circle(a[1],a[2] , 1);
end;
if sct3=1 then begin

setpencolor (clWhite);
Circle(ab[1],ab[2]-2, 2);
chtb:=chtb+1 ;
if chtb>600 then goto w;
ab[2]:=ab[2]-1;
setpencolor (clRed);
Circle(ab[1],ab[2] , 2);
end;

if sct3=2 then begin

setpencolor (clWhite);
Circle(ab[1],ab[2]-2, 2);
chtb:=chtb+1 ;
if chtb>600 then goto w;
ab[2]:=ab[2]+1;
setpencolor (clRed);
Circle(ab[1],ab[2] , 2);
end;


if sct3=3 then begin

setpencolor (clWhite);
Circle(ab[1]+2,ab[2], 2);
chtb:=chtb+1;
if chtb>600 then goto w;
ab[1]:=ab[1]-1;
setpencolor (clRed);
Circle(ab[1],ab[2] , 2);
end;

if sct3=4 then begin

setpencolor (clWhite);
Circle(ab[1]-2,ab[2], 2);
chtb:=chtb+1;
if chtb>600 then goto w;
ab[1]:=ab[1]+1;
setpencolor (clRed);
Circle(ab[1],ab[2] , 2);
end;
w:
if (x=bot[7]) and (y<bot[8]) or (x>bot[7]+9) and (x<bot[7]-9) and (y<bot[8]) then sb:=3;
if (x=bot[7]) and (y>bot[8]) or (x>bot[7]+9) and (x<bot[7]-9) and (y>bot[8]) then sb:=4;
if (x<bot[7]) and (y=bot[8]) or (y=bot[8]+9) and (y=bot[8]-9) and (x<bot[7]) then sb:=1;
if (x>bot[7]) and (y=bot[8]) or (y=bot[8]+9) and (y=bot[8]-9) and (x>bot[7]) then sb:=2;
if shtb>1 then sb1:=0;
if sb=1 then begin
if (bot[12]=396) or (bot[12]>396) then goto uq;
if bot[12]<396 then bothod;
end;
if sb=2 then begin
if bot[12]=11 then goto uq;
if bot[12]>11 then bothod;
end;
if sb=3 then begin
if bot[9]=576 then goto uq;
if bot[9]<576 then bothod;
end;
if sb=4 then begin
le:=s;
if bot[11]=68 then goto uq;
if bot[11]>68 then bothod;
end;





end;
m:
end;}[

Последний раз редактировалось InoyKe; 24.08.2012 в 16:52.
InoyKe вне форума Ответить с цитированием
Старый 24.08.2012, 16:41   #4
InoyKe
Пользователь
 
Регистрация: 24.08.2012
Сообщений: 15
По умолчанию

Код:
procedure botvystrl;
    label  uq, s1,a1,d1,w1;
 begin
  ab[2]:=bot[8];
ab[1]:=bot[7];
chtb:=1;

      if    (x=bot[7]) and  (y<bot[8]) or (x>bot[7]+9) and (x<bot[7]-9) and (y<bot[8]) then begin vyb:=1;
       if a4 = 0 then c:=c+1; sb:=2; bothod; end;
       if    (x=bot[7]) and  (y>bot[8]) or (x>bot[7]+9) and (x<bot[7]-9) and (y>bot[8]) then begin vyb:=2;
       if a4 = 0 then c:=c+1; sb:=1; bothod; end;
        if    (x<bot[7]) and  (y=bot[8]) or (y=bot[8]+9) and (y=bot[8]-9) and (x<bot[7]) then begin vyb:=3;
        if a4 = 0 then c:=c+1; sb:=4; bothod; end;
        if    (x>bot[7]) and  (y=bot[8]) or (y=bot[8]+9) and (y=bot[8]-9) and (x>bot[7]) then begin vyb:=4;
          if a4 = 0 then c:=c+1; sb:=3; bothod; end;
          while (true) do begin
          
        if vyb = 1 then begin
        sct3:=1;
setpencolor (clWhite);
            Circle(ab[1],ab[2]+2, 2);
           chtb:=chtb+1;
           if chtb=600 then  goto uq;
      sleep(2);
   ab[2]:=ab[2]-1;
setpencolor (clRed);
  Circle(ab[1],ab[2] , 2);
    end;
    
      if vyb = 2 then begin
      sct3:=2;
setpencolor (clWhite);
            Circle(ab[1],ab[2]-2, 2);
           chtb:=chtb+1;
           if chtb=600 then  goto uq;
      sleep(2);
   ab[2]:=ab[2]+1;
setpencolor (clRed);
  Circle(ab[1],ab[2] , 2);
   end;


if vyb = 3 then begin
sct3:=3;
setpencolor (clWhite);
            Circle(ab[1]+2,ab[2], 2);
           chtb:=chtb+1;
           if chtb=600 then  goto uq;
      sleep(2);
   ab[1]:=ab[1]-1;
setpencolor (clRed);
  Circle(ab[1],ab[2] , 2);
 end;

if vyb = 4 then begin
sct3:=4;
  setpencolor (clWhite);
            Circle(ab[1]-2,ab[2], 2);
           chtb:=chtb+1;
           if chtb=600 then  goto uq;
      sleep(2);
   ab[1]:=ab[1]+1;
setpencolor (clRed);
  Circle(ab[1],ab[2] , 2);
  end;
   if keypressed then begin
   s:=readkey;
case s of
's': begin
if  s='f' then goto  s1;
le:=s;
s1:
if (le='s') and (r1=396) or (r1>396) then goto uq;
 if (le='s') and (r1<396) then shag;
 end;
'w' : begin
   if s='f' then goto  w1;
le:=s;
w1: if (le='w') and (r1=87)  then goto uq;
 if (le='w') and (r1>87) then shag;
 end;
'd' : begin
 if s='f' then goto  d1;
le:=s;
d1:if (le='d') and (rf=576) then goto uq;
 if (le='d') and (rf<576) then shag;
 end;
'a' :begin
 if s='f' then goto  a1;
le:=s;
a1:if (le='a') and (fr=57) then goto uq;
 if (le='a') and (fr>57) then  shag;
 end;
'f' :  begin
 if le='y' then vy:=1;
 if le='s' then vy:=1;
 if le='w' then vy:=2;
 if le='a' then vy:=3;
 if le='d' then vy:=4;
vystrel;
 end;
 end;
 end;
 end;
    uq:
    end;
    procedure yahod;
    label s1,w1,d1,a1,uq;
    begin
s:=readkey;
case s of
's': begin
if  s='f' then goto  s1;
le:=s;
s1:
if (le='s') and (r1=396) or (r1>396) then goto uq;
 if (le='s') and (r1<396) then shag;
 end;
'w' : begin
   if s='f' then goto  w1;
le:=s;
w1: if (le='w') and (r1=87)  then goto uq;
 if (le='w') and (r1>87) then shag;
 end;
'd' : begin
 if s='f' then goto  d1;
le:=s;
d1:if (le='d') and (rf=576) then goto uq;
 if (le='d') and (rf<576) then shag;
 end;
'a' :begin
 if s='f' then goto  a1;
le:=s;
a1:if (le='a') and (fr=57) then goto uq;
 if (le='a') and (fr>57) then  shag;
 end;
'f' :  begin
 if le='y' then vy:=1;
 if le='s' then vy:=1;
 if le='w' then vy:=2;
 if le='a' then vy:=3;
 if le='d' then vy:=4;
vystrel;
 end;
 end;
 uq:
end;
  procedure bohod;
  label uq;
  begin
  sb:=0;
  sleep(15);
hodr:=0;
chtb:=11;
if  y<bot[8] then  sh1:=bot[8]-y;
 if y>bot[8] then sh1:=y-bot[8];
   if  x<bot[7] then  sh2:=bot[7]-y;
 if x>bot[7] then sh2:=x-bot[7];
    if (sh1<sh2) and (y<bot[8]) and (x<bot[7]) then sb:=2;
    if (sh1<sh2) and (y<bot[8]) and (x>bot[7]) then sb:=2;
           if (sh1>sh2) and (y<bot[8]) and (x>bot[7]) then sb:=3;
    if (sh1>sh2) and (y<bot[8]) and (x<bot[7]) then sb:=4;
    if (sh1>sh2) and (y<bot[8]) and (x<bot[7]) then sb:=4;
     if (sh1<sh2) and (y>bot[8]) and (x>bot[7]) then sb:=1;
      if (sh1>sh2) and (y>bot[8]) and (x>bot[7]) then sb:=3;
       if (sh1<sh2) and (y<bot[8]) and (x>bot[7]) then sb:=3;
        if (sh1<sh2) and (y>bot[8]) and (x<bot[7]) then sb:=1;
        if (sh1<sh2) and (y<bot[8]) and (x>bot[7]) then sb:=4;
        if (sh1>sh2) and (y>bot[8]) and (x<bot[7]) then sb:=3;
if sb=1 then begin
if  (bot[12]=396) or (bot[12]>396) then goto uq;
 if  bot[12]<396 then bothod;
 end;
if sb=2 then begin
if  bot[12]=11  then goto uq;
 if bot[12]>11 then bothod;
 end;
if sb=3 then begin
if bot[9]=576 then goto uq;
 if   bot[9]<576 then bothod;
 end;
if sb=4 then begin
le:=s;
if  bot[11]=68 then goto uq;
 if  bot[11]>68 then  bothod;
 end;
if sb=0 then botvystrl;
 uq:
 end;

Последний раз редактировалось InoyKe; 24.08.2012 в 16:46.
InoyKe вне форума Ответить с цитированием
Старый 24.08.2012, 16:41   #5
InoyKe
Пользователь
 
Регистрация: 24.08.2012
Сообщений: 15
По умолчанию

Код:
 BEGIN
  Rectangle(626,4, 10,396);
  c:=2;
e:=45; r:=85; y:=65; rf:= 92; fr:=  97; g:=90; g1:=80; gg:= 100; rg:=110; e1:=65; r1:=100; x:=95; asq:=14; sa:=12; le:='y'; ci:=1;
    setpencolor (clBlack);
 Rectangle(g,e, g1,r) ; Rectangle(gg,e, rg,r); Circle(x, y, asq); Circle(x, y, sa); Rectangle(rf,e1, fr,r1);
bot[2]:=245; bot[4]:=285; bot[8]:=265; bot[9]:=492; bot[11]:=498; bot[1]:=490; bot[3]:=480; bot[5]:=509; bot[6]:=499; bot[10]:=225; bot[12]:=265; bot[7]:=495;
bot[13]:=12; bot[14]:=4; bot[15]:=14;
    setpencolor (clBlack); Rectangle(bot[1],bot[2],bot[3],bot[4]) ; Rectangle(bot[5],bot[2], bot[6],bot[4]);
Circle(bot[7], bot[8], bot[14]); Circle(bot[7], bot[8], bot[13]); Rectangle(bot[9],bot[10], bot[11],bot[12]);
{while (true) do begin
bohod;
if keypressed then yahod;
end;}
end.

Последний раз редактировалось InoyKe; 24.08.2012 в 16:50.
InoyKe вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Определить по данным массива, где есть сигнал, а где его нет. AnutkaSolnce C# (си шарп) 1 28.12.2011 17:09
Visual Studio 2010 Trial лаг или так задумано... Casper-SC Софт 2 07.06.2010 18:35
То ли лаг, то ли хз Жека-старший Общие вопросы Delphi 1 16.05.2010 18:05
Лаг со скриптом Shaitan63 PHP 4 13.04.2010 15:05
лаг при смене картинки DANNY Общие вопросы Delphi 9 19.05.2008 11:19