Recent

Author Topic: pascal assignment  (Read 11007 times)

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
Re: pascal assignment
« Reply #15 on: April 27, 2016, 07:05:05 pm »
The error message itself is answering to you:

"BGI Error:- Graphics not Initialized(Use Initgraph)".
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

user4592357

  • New member
  • *
  • Posts: 9
Re: pascal assignment
« Reply #16 on: April 27, 2016, 08:29:25 pm »
Well but idk how to correct that

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: pascal assignment
« Reply #17 on: April 27, 2016, 08:36:56 pm »
Well but idk how to correct that
It seems you have difficulty to comprehend that you (originally) have two completely separate programs. The compiler is only able to understand one of them, and therefor will not compile/execute any of the second part.

You failed to produce current code, you failed to describe what you expect your code to do (and more importantly in what order), yet you expect others to give you a solution for the problems that arise from your code...  :o

user4592357

  • New member
  • *
  • Posts: 9
Re: pascal assignment
« Reply #18 on: April 27, 2016, 08:57:51 pm »
One doesn't work without the other one so idk how to compile and run the separately

ab1jx

  • New Member
  • *
  • Posts: 23
    • Just some photos on Nikonians
Re: pascal assignment
« Reply #19 on: April 27, 2016, 09:46:04 pm »
For one thing outtextxy and write don't belong together at all, one is graphics mode and one is text mode.

You need initgraph in the graphics section, but it looks like you copied and pasted from multiple things into your posting.

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: pascal assignment
« Reply #20 on: April 27, 2016, 10:09:09 pm »
For one thing outtextxy and write don't belong together at all, one is graphics mode and one is text mode.
That's not entirely correct, but i get the gist of your remark. e.g. you would have to know a bit more how to know how to reroute you text input and output.

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: pascal assignment
« Reply #21 on: April 28, 2016, 05:24:34 pm »
One doesn't work without the other one so idk how to compile and run the separately
I have not the faintest idea what the above sentence entails :-S

idk, maybe this works for you ?
Code: Pascal  [Select][+][-]
  1. program blue30;
  2.  
  3. uses
  4.   crt,
  5.   graph;
  6.  
  7.  
  8. const
  9.   xmax = 640;
  10.   ymax = 480;
  11.  
  12.  
  13. type
  14.   mat = array[0..10,0..10] of integer;
  15.   vec = array[0..10] of integer;
  16.  
  17.  
  18. var
  19.   f         : file of integer;
  20.   zr,n      : byte;
  21.   m,t,k     : integer;
  22.   c         : char;
  23.   zx0, zx1,
  24.   zy0, zy1  : real;
  25.   y         : array[0..2] of real;
  26.   graphdriver,
  27.   graphmode : integer;
  28.   j,i       : integer;
  29.   l,Q       : byte;
  30.   x         : mat;
  31.   z,d       : vec;
  32.  
  33.  
  34. function baz (a,b:integer): boolean;
  35. begin
  36.   if (a mod b=2) and (a>0)
  37.   then baz:=true
  38.   else baz:=false
  39. end;
  40.  
  41.  
  42. //procedure vector (n2:integer;x2:vec);
  43. procedure vector (n2:integer;var x2:vec);
  44. begin
  45.   for i:=1 to n2
  46.   do readln(x2[i]);
  47. end;
  48.  
  49.  
  50. procedure ask;
  51. begin
  52.   repeat
  53.     write ('m=');
  54.     readln (m)
  55.   until (m>1) and (m<=10);
  56.  
  57.   for i:=1 to m
  58.   do  vector (m,z);
  59.  
  60.   for j:=1 to m
  61.   do x[i,j] := z [j];
  62.  
  63.   l:=0;
  64.  
  65.   for i:=1 to m do
  66.     for j:=1 to m do
  67.       if baz (x[i,j],5)= true
  68.       then l:=l+1;
  69.  
  70.   write('l=',l);
  71. end;
  72.  
  73.  
  74.  
  75. {===============MENU=====================}
  76.  
  77. procedure menu(c1,c2,c3,c4:byte);
  78. begin {cleardevice;}
  79.   setbkcolor(0);
  80.  
  81.   {==MeC==}
  82.   Line(324,12,560,120);
  83.   line(560,120,560,350);
  84.   line(560,350,324,458);
  85.   Line(324,458,90,350);
  86.   line(90,350,90,120);
  87.   line(90,120,324,12);
  88.  
  89.   setfillstyle(14,5);
  90.  
  91.   {===4 hat ==}
  92.  
  93.   setcolor(4);
  94.   line(320,20,320,226);
  95.   line(320,226,100,128);
  96.   line(100,128,320,20);
  97.  
  98.   setfillstyle(1,4);
  99.   setcolor(4);
  100.   line(328,20,328,226);
  101.   line(328,226,552,128);
  102.   line(552,128,328,20);
  103.  
  104.   setfillstyle(1,4);
  105.   line(328,236,328,450);
  106.   line(328,450,552,342);
  107.   line(552,342,328,236);
  108.  
  109.   setfillstyle(1,4);
  110.   setcolor(4);
  111.  
  112.   line(320,234,320,450);
  113.   line(320,450,100,342);
  114.   line(100,342,320,234);
  115.   setfillstyle(1,4);
  116.  
  117.   {====2 poqr===}
  118.   setcolor(15);
  119.   line(124,180,268,230);
  120.   line(268,230,124,278);
  121.   line(124,278,124,180);
  122.   setfillstyle(1,15);
  123.  
  124.   setcolor(15);
  125.   line(526,180,526,278);
  126.   line(526,278,380,230);
  127.   line(380,230,526,180);
  128.   setfillstyle(1,15);
  129.  
  130.  
  131.  {---------------}
  132.   settextstyle(6,0,3);
  133.  
  134.   setcolor(c1);
  135.   outtextxy(160,115,'Little');
  136.   setcolor(c2);
  137.   outtextxy(340,115,'Critters');
  138.   setcolor(c3);
  139.   outtextxy(170,340,'Snow');
  140.   setcolor(c4);
  141.  
  142.   outtextxy(360,340,'Exit');
  143. end;
  144.  
  145.  
  146.  
  147. {-------------Pahanj----------------}
  148.  
  149. procedure pahanj;
  150. begin
  151.   RestoreCrtMode;
  152.   Ask;
  153.   SetGraphMode(GetGraphMode);
  154.  
  155.  
  156.   cleardevice;
  157.   settextstyle(3,0,5);
  158.   setcolor(15);
  159.   outtextxy(120,50,'Little lord Fauntleroy...');
  160.  
  161.   readkey
  162. end;
  163.  
  164. {------------------------------------------------------------------------------}
  165.  
  166.  
  167.  
  168. {----------------Lucum------------}
  169.  
  170. procedure lucum;
  171. // Critters from swag - Nossaman
  172. const
  173.   radcon:real=0.017453292;totalbodies=22;speedfactor:real=30;
  174. type
  175.   debris=record mass,dir,speed,x,y:real;oldx,oldy:integer;end;
  176. var
  177.   b:array[1..totalbodies]of debris;errcode: integer;ch:char;
  178.   i,countdown,walls,delayfactor:integer;stampede:boolean;bait:debris;
  179. function theta(p1x,p1y,p2x,p2y:real):real; var t,lx,ly:real;
  180. begin
  181.   lx:=p2x-p1x; ly:=p2y-p1y; if((lx=0)and(ly=0))then theta:=0 else begin if lx=0
  182.   then t:=arctan(ly/0.0000000001)/radcon else t:=arctan(ly/lx)/radcon; if lx<0
  183.   then t:=t+180; if((lx>=0)and(ly<0))then t:=t+360; theta:=abs(t); end;
  184. end;
  185. function hypotenuse(x1,y1,x2,y2:real):real;var h1,h2:real;
  186. begin
  187.   hypotenuse:=sqrt(sqr(abs(x1-x2))+sqr(abs(y1-y2)));
  188. end;
  189. procedure initcritter; var i:integer; g:real;
  190. begin
  191.   for i:=1 to totalbodies do begin b[i].x:=random(600)+20; b[i].y:=random(440)+
  192.   20;b[i].dir:=random(359)+1; b[i].speed:=(random(100)+50)/speedfactor;b[i].mass
  193.   :=random(50)+100;bait.x:=random(600)+20;bait.y:=random(440)+20;bait.mass:=100;
  194.   end; delayfactor:=round(500/b[1].speed);
  195. end;
  196.  
  197. procedure orbit(a:integer);
  198. var i,a2,min,xmax,ymax:integer; t,m1,m2,ax,ay,newdir,rate:real;
  199. begin
  200.   if a=1 then a2:=totalbodies else a2:=a-1;if (stampede and (a=1)) then begin
  201.   t:=theta(b[a].x,b[a].y,bait.x,bait.y); m2:=hypotenuse(b[a].x,b[a].y,bait.x,bait.y);
  202.   m1:=bait.mass; rate:=10; end else begin t:=theta(b[a].x,b[a].y,b[a2].x,b[a2].y);
  203.   m2:=hypotenuse(b[a].x,b[a].y,b[a2].x,b[a2].y); m1:=b[a2].mass; rate:=4; end;
  204.   ax:=b[a].x+(m1*cos(b[a].dir*radcon))+(m2*cos(t*radcon));
  205.   ay:=b[a].y+(m1*sin(b[a].dir*radcon))+(m2*sin(t*radcon));
  206.   newdir:=theta(b[a].x,b[a].y,ax,ay);if a=1 then begin if abs(newdir-b[a].dir)>=
  207.   180 then begin if newdir>b[a].dir then newdir:=newdir-360 else newdir:=newdir+
  208.   360; end; if newdir>b[a].dir then b[a].dir:=b[a].dir+((newdir-b[a].dir)/rate);
  209.   if newdir<b[a].dir then b[a].dir:=b[a].dir-((b[a].dir-newdir)/rate); if
  210.   round(newdir)=round(b[a].dir) then b[a].dir:=b[a].dir+random(10)-5; end else
  211.   b[a].dir:=newdir;if b[a].dir>359 then b[a].dir:=b[a].dir-360;if b[a].dir<0
  212.   then b[a].dir:=b[a].dir+360;b[a].x:=b[a].x+(b[a].speed*cos(b[a].dir*radcon));
  213.   b[a].y:=b[a].y+(b[a].speed*sin(b[a].dir*radcon));if b[a].x<3 then b[a].x:=3;
  214.   if b[a].x>637 then b[a].x:=637;if b[a].y<3 then b[a].y:=3;if b[a].y>477 then
  215.   b[a].y:=477;if(b[a].x=637)or(b[a].x=3)or(b[a].y=477)or(b[a].y=3) then begin
  216.   b[a].speed:=(random(100)+50)/speedfactor;if a=1 then delayfactor:=round(500/
  217.   b[1].speed);end;if (b[a].oldx<>round(b[a].x))or(b[a].oldy<>round(b[a].y)) then
  218.   begin setcolor(black);circle(b[a].oldx,b[a].oldy,1);if a=1 then circle(b[a].
  219.   oldx,b[a].oldy,2);setcolor(white);circle(round(b[a].x),round(b[a].y),1);if a=
  220.   1 then begin setcolor(lightgray);circle(round(b[a].x),round(b[a].y),2);end;
  221.   end;b[a].oldx:=round(b[a].x);b[a].oldy:=round(b[a].y);end;
  222. begin cleardevice;settextstyle(3,0,5);setcolor(15);outtextxy(120,50,'Critters');
  223.   outtextxy(120,150,'esc to return to menu');
  224.   countdown:=100;stampede:=false;randomize;ch:=#0;setgraphmode(2);initcritter;
  225.   while keypressed do ch:=readkey;repeat for i:=1 to totalbodies do orbit(i);
  226.   dec(countdown);if countdown<0 then begin stampede:=not stampede; if stampede
  227.   then begin walls:=random(4); countdown:=random(delayfactor)+delayfactor*2;
  228.   case walls of
  229.   0:begin bait.x:=20; bait.y:=random(480); end;
  230.   1:begin bait.x:=619;bait.y:=random(480); end;
  231.   2:begin bait.y:=20; bait.x:=random(640); end;
  232.   3:begin bait.y:=459;bait.x:=random(640); end;
  233.   end;
  234.   end else countdown:=random(delayfactor)+delayfactor*2; end;
  235.   if keypressed then ch:=readkey; until ch=#27;
  236. end;
  237.  
  238.  
  239. procedure animation;
  240. var
  241.   X, Y:array [1..400] of integer;
  242.   i, Gx, Gy, Gy1, Gd, Gm: integer;
  243.   z:byte;
  244.  
  245. BEGIN
  246.   Gd:=Detect;
  247.   InitGraph(Gd, Gm, 'X:\BP');
  248.  
  249.   randomize;
  250.  
  251.   Gx:=GetMaxX;
  252.   Gy:=GetMaxY;
  253.   SetColor(15);
  254.  
  255.   for i:=1 to 200 do
  256.   begin
  257.     X[i]:= random(Gx);
  258.     Y[i]:= random(Gy div 1);
  259.     PutPixel(X[i],Y[i],15)
  260.   end;
  261.  
  262.   repeat
  263.     inc (z);
  264.  
  265.     for i:=1 to 200 do
  266.     begin
  267.       if (Y[i] < Gy) and (GetPixel(X[i],Y[i]+1)= 0) then
  268.       begin
  269.         PutPixel(X[i], Y[i],0);
  270.         Y[i]:= Y[i]+1;
  271.         PutPixel(X[i], Y[i],15)
  272.       end
  273.       else
  274.       begin
  275.         if Y[i] < 20 then
  276.         begin
  277.           PutPixel(X[i], Y[i],0);
  278.         end
  279.         else
  280.         begin
  281.           Line(X[i] - 3, Y[i] - 2, X[i] + 3, Y[i] + 2);
  282.           Line(X[i] + 3, Y[i] - 2, X[i] - 3, Y[i] + 2);
  283.           Line(X[i], Y[i] - 3, X[i], Y[i] + 3);
  284.         end;
  285.  
  286.         Y[i]:={random(Gy div 40)}0;
  287.         X[i]:= random(Gx);
  288.         PutPixel(X[i], Y[i], 15);
  289.       end;
  290.     end;
  291.  
  292.     settextstyle(7,0,7);
  293.     outtextxy(60,150,'Sometimes ');
  294.     outtextxy(300,250,'it snows ');
  295.     outtextxy(500,350,'in April');
  296.  
  297.     settextstyle(7,0,6);
  298.     outtextxy(60,470,'Thanks For Watching');
  299.   until keypressed;
  300.   readkey;
  301. END;
  302.  
  303.  
  304. begin
  305.   initgraph(m,t,'');
  306.   repeat
  307.     k:=1;  
  308.     cleardevice;
  309.     repeat
  310.       case k of
  311.         1:menu(15,4,4,4);
  312.         2:menu(4,15,4,4);
  313.         3:menu(4,4,15,4);
  314.         4:menu(4,4,4,15);
  315.       end;
  316.       c:=readkey;
  317.  
  318.       if ord(C)=80 then k:=k-1;
  319.       if ord(C)=72 then k:=k+1;
  320.       if k=0 then k:=4;
  321.       if k=5 then k:=1;
  322.     until ord(c)=13;
  323.  
  324.     case k of
  325.       1:pahanj;
  326.       2:lucum;
  327.       3:animation;
  328.     end;
  329.   until k=4;
  330. end.
  331.  

 

TinyPortal © 2005-2018