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.

Looks okay to me. Have you tried without setting background and color?

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...

What kind of keys do you mean, two regular ones, or something like control or alt ?

w,a,s,d, space, esc, left, right, down, up(arrows), and 0 numpad

Not sure, never tried multiple.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.