← Journey
1996 · BASIC, Pascal & olympiads

Pascal

Moved to Pascal — the language of every olympiad and my first real games.

Pascal

Original source code

TONEL.PAS
PROGRAM TOHKI;
USES CRT,GRAPH;
VAR
  c,A,B,x,y:INTEGER;
  q:string;
  i,j,p:word;
  x1:array[1..96]of integer;
  y1:array[1..96]of integer;
BEGIN
  randomize;
  A:=DETECT;
  INITGRAPH(A,B,'A:\PASKAL\GRAFIKA');
  x:=320;
  y:=280;
  for i:=1 to 48 do x1[i]:=0;
  for i:=48 to 96 do x1[i]:=640;
  for i:=1 to 48 do y1[i]:=i*10-5;
  for i:=48 to 96 do y1[i]:=i*10-485;
  setbkcolor(4);
  repeat
    SETCOLOR(15);
    circle(600,100,10);
    for i:=1 to 96 do line(x,y,x1[i],y1[i]);
    q:=readkey;
    if (q=#72) or(q=#77)or(q=#80)or(q=#75) then begin
    SETCOLOR(0);
    for i:=1 to 96 do line(x,y,x1[i],y1[i]);
    if q=#72 then y:=y-10;
    if q=#77 then x:=x+10;
    if q=#80 then y:=y+10;
    if q=#75 then x:=x-10;
    end;
    if q=#32 then begin
      for i:=1 to round(x/2) do  begin
       p:=1;
       setcolor(14);
       sector(i*2,y,0,359,round((320-i)/10),round((320-i)/60));
       setcolor(4);
       sector(i*2,y,0,359,round((320-i)/10),round((320-i)/60));
     end;
     c:=random(5);
     for j:=1 to c+1 do begin
        setcolor(14);
        a:=random(100);
        b:=random(20);
        for i:=1 to a do begin circle(x+b,y+b,i);
            sound(i+10);
        end;
        nosound;
        setcolor(4);
        for i:=a downto 50 do begin
           circle(x+b,y+b,i);
           SOUND(I+100);
         end;
      end;
     for i:=1 to a do begin circle(x+b,y+b,i);
            sound(i+100);
        end;
      NOSOUND;
    end;
    if (x<610)and(x>590)and(p=1) then begin
      settextstyle(0,0,9); setcolor(2); setusercharsize(2000,100,2000,100);
       if (y>90)and(y<110)then begin
         outtextxy(20,220,'You  win');
         delay(1000); halt(1);
       end;
    end;
  p:=0;
  until q=#27;

END.

1996, Turbo Pascal: one of my first real games. 96 lines from your point to the screen edges draw a tunnel; the arrows move the point, Space fires a shot and explosions with PC-speaker sound, and hitting the white circle wins.