home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / GFXFX2.ZIP / CANNON.PAS < prev    next >
Pascal/Delphi Source File  |  1995-02-14  |  997b  |  35 lines

  1.  
  2. program cannonball; { CANNON.PAS }
  3. { Cannonball simulation, with the REAL formula's.
  4.   Draws the track of a launched cannonball - assuming no air-friction.
  5.   By Bas van Gaalen. }
  6. uses u_vga,u_kb;
  7. const
  8.   g=-9.81;    { acceleration due to gravity on Earth at 52°NB (Holland) }
  9.   x0=0;       { x-pos of ball at t=0 }
  10.   y0=100;     { y-pos of ball at t=0 }
  11.   v0=50;      { speed of ball at t=0 }
  12.   phi=50;     { angle to the horizontal at which ball is launched (degrees) }
  13.   dt=0.01;    { interpolation step-size }
  14. var
  15.   t:real;     { time }
  16.   xt,         { x-pos at time t }
  17.   yt,         { y-pos at time t }
  18.   v:integer;  { speed }
  19.  
  20. function rad(alpha:integer):real; begin
  21.   rad:=(alpha/180)*pi; end;
  22.  
  23. begin
  24.   setvideo($13);
  25.   t:=0; v:=v0; yt:=1;
  26.   while (not keypressed) and (yt>0) do begin
  27.     xt:=x0+round(v0*cos(rad(phi))*t);
  28.     yt:=y0+round(v*sin(rad(phi))*t+0.5*g*t*t);
  29.     putpixel(xt,199-yt,15);
  30.     t:=t+dt;
  31.   end;
  32.   waitkey(0);
  33.   setvideo(u_lm);
  34. end.
  35.