Hello,
I'm working on a snake based game in pascal. I'm using graph window. But here is the problem: Yesterday i was doing great my project compiled and everything, today i turned on my computer, open my project and it wouldn't compile... I checked the code the was nothing strange or selfadded.

Erros i get: "No way to get the console handle" i press Ok and "Invalid function number" Appears, but im compiler there shows no errors ^^

Here is my code, it's really simple, btw i tried dev-pascal it didn't work there too..
Hope you can help me.

program Kubas;
uses Crt, Graph;

    var GraphMode   : integer;
        GraphDriver : integer;
        DriverPath  : string;
        option      : boolean;
        ch          : char;
        //score       : integer;
        x1          : integer;
        x2          : integer;
        y1          : integer;
        y2          : integer;
        c           : integer;
        //Rand        : integer;
        x3          : integer;
        x4          : integer;
        y3          : integer;
        y4          : integer;
        //rx          : array[200..980] of integer;
        //ry          : array[300..740] of integer;
        
begin
  x1 := 220; x2 := 240; y1 := 540; y2 := 560; c := 20; //score := 0;
  x3 := 0; x4 := 0; y3 := 0; y4 := 0;
  InitGraph(GraphDriver, GraphMode, '');
  SetFillStyle(12, 10); // dunno parameters ^^
  WriteLn('--------------------------------------------');
  WriteLn('Cube console                               |');
  WriteLn('--------------------------------------------');


  while 1 < 2 do
    begin
    repeat

        SetColor(white);
        Rectangle(x1, y1, x2, y2);
        // Arena
        MoveTo(200,300);
            LineTo(1000,300); // top
        MoveTo(200,760);
            LineTo(1000,760); // bottom
        MoveTo(200,300);
            LineTo(200,760); // left
        MoveTo(1000,300);
            LineTo(1000,760); // right

        ch := readkey;
        if ch = 'd' then
            begin
            ClearDevice;
            x1 := x1 + c;
            //y1 := x1 + c;
            x2 := x2 + c;
            //y2 := y2 + c;
            Rectangle(x1, y1, x2, y2);
            end;
            
        if ch = 's' then
            begin
            ClearDevice;
            //x1 := x1 + c;
            y1 := y1 + c;
            //x2 := x2 + c;
            y2 := y2 + c;
            Rectangle(x1, y1, x2, y2);
            end;
            
        if ch = 'a' then
            begin
            ClearDevice;
            x1 := x1 - c;
            //y1 := y1 + c;
            x2 := x2 - c;
            //y2 := y2 + c;
            Rectangle(x1, y1, x2, y2);
            end;
            
        if ch = 'w' then
            begin
            ClearDevice;
            //x1 := x1 + c;
            y1 := y1 - c;
            //x2 := x2 + c;
            y2 := y2 - c;
            Rectangle(x1, y1, x2, y2);
            end;
            
        if ch = 'x' then
            begin
            closegraph;
            WriteLn('Graph window - closed');
            end;
            
        // Collision [TEST]
        if (y1 = 280) or (x1 = 180) or (y1 = 760) or (x1 = 1000) then
            begin
            SetColor(red);
            OutTextXY(200, 780, 'Collision*');
            WriteLn('');
            WriteLn('Collision detected');
            //WriteLn('Score ',score);
            WriteLn('');
            //closegraph;
            end;
            
        if (x1 = x3) and (x2 = x4) and (y1 = y3) and (y2 = y4) then
            begin
            ClearDevice;
            x3 := x3 + 20;
            x4 := x4 + 20;
            y3 := y3 + 20;
            y4 := y4 + 20;
            end;






        SetColor(yellow);
        //Rectangle(x3, y3, x4, y4);

    WriteLn('Position: ',x1,' ',y1,' ',x2,' ',y2);
    until 1 < 2;
    end;

  Readln;
end.

Ok close this please.

#solved.

You as original poster should mark it solved.

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.