Hello again! I am trying to make a little game in pascal and I'm using graph. And it changes the background but when i'm trying to draw a black line it doesn't work. I don't know why.

uses graph;
var grDriver,grMode,ErrCode: Integer;

procedure initg;
begin grDriver := Detect;
      InitGraph(grDriver, grMode,'e:/bp/bgi');
      ErrCode := GraphResult;
      if ErrCode <> grOk then
      begin write('Graphics error:', GraphErrorMsg(ErrCode));
            exit;
            readln
      end
end;

begin initg;
      setbkcolor(7);
      setcolor(black);
      line(0,0,300,300);
      readln;
      closegraph
end.

If i don't set the background an color it will go with the preset values, and that means background black and color white. I used darkgray color, it's not the same as the black color but it's good...

And i have another question: how do i read multiple keys?
Here's how i did:

 c:=#0;   
  if keypressed then
   while keypressed do
        begin c:=readkey;
              case c of
               . . .
               . . .
        end;

But there's a little problem here. If i keep pressing a key and in the same time i press another key, the first key will stop working, and the other key works. And if i keep pressing 2 keys in the same time nothing happens. I have a liitle idea in my head: for each key i use a variable, and if a variable's value is 0 then do the things specified for that variable, but i don't know how to make that in code...

This article has been dead for over six months. Start a new discussion instead.