Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Delphi программирование > Паскаль, Turbo Pascal, PascalABC.NET
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 12.11.2009, 17:04   #1
Dartchuwak
Пользователь
 
Регистрация: 08.01.2009
Сообщений: 21
По умолчанию Pascal graph

Помогите доделать программу.Все готово осталось только закрасить квадрат,но у меня паскаль в полноэкранном режиме не работает.

Код:
Program Graphworld;
  Uses Graph, crt;
  Type
    Location = object
			x1,y1,x2,y2 :integer;
			constructor Init (initX1, initY1, initX2, inity2 :integer);
			destructor Done;
			function GetX :integer;
			function GetY :integer;
		   end;

  Constructor Location.Init (initX1, initY1, initx2, inity2 :integer);
	Begin
	  X1:=InitX1;
	  Y1:=InitY1;
          x2:=initx2;
          y2:=inity2;
	End;

  Destructor Location.Done;
	Begin
	End;

  Function Location.GetX:integer;
	Begin
	  GetX:=x1;
	End;

  Function Location.GetY:integer;
	Begin
	  GetY:=y1;
	End;


{=======================================================================}

  Type Point = object (Location)
visible:boolean;
			Procedure Show; virtual;
			Procedure Hide; virtual;
			Procedure Moveto (newX1, newY1 ,NewX2 ,NewY2 :integer);
		   End;

Procedure Point.Show;
	Begin
	  Putpixel(x1, y1, Getcolor);
	  Visible:=TRUE
	End;

  Procedure Point.Hide;
	Begin
	  Putpixel(x1, y1, GetBkColor);
	  Visible:=FALSE
	End;

  Procedure Point.Moveto;
        Var TempVisible:boolean;
	Begin
          TempVisible:=visible;
	  If TempVisible then Hide;
	  X1:=newX1;
	  Y1:=newY1;
          X2:=NewX2;
          y2:=NewY2 ;
	  If TempVisible then Show;
	End;



{=======================================================================}

  Type rect = object (Point)

			Constructor Init (initX1, initY1,initX2,InitY2:integer);
			Procedure Show; virtual;
			Procedure Hide; virtual;

		    end;

  Constructor rect.Init;
	Begin
	  X1:=initX1;
	  Y1:=initY1;
          X2:=InitX2;
          Y2:=InitY2;
	End;

  Procedure rect.Show;
        Var tempcolor :word;
	Begin
          TempColor:=GetBkColor;
          SetBKColor(GetColor);
	  Graph.rectangle(X1,Y1,X2,Y2);
          SetBkColor(TempColor);
	  Visible:=TRUE
	End;

  Procedure rect.Hide;
	Var tempcolor :word;
        Begin
	  Tempcolor:=Getcolor;
	  Setcolor(Getbkcolor);
	   Graph.rectangle(x1, y1, x2, y2);
	  Setcolor(Tempcolor);
	  Visible:=FALSE
	End;




{=============================================================================}

  Type World = object
			Mode :integer;
			Driver :integer;
			Procedure Initworld(gdr, gmode :integer; path :string);
			Procedure Endworld;
		   End;

  Procedure World.Initworld;
	Var rez :integer;
	Begin
	  Driver:=gdr;
	  Mode:=gmode;
	  Initgraph(driver, mode, path);
	  Rez:=Graphresult;
	  If rez<>GrOK then
		Begin
		  Writeln(GraphErrorMsg(rez));
		  Halt(1);
		End;
	End;

  Procedure World.Endworld;
	Begin
	  Closegraph;
	  Writeln('The end of the world.');
	End;

  Type ppoint = ^point;
       prect = ^rect;

     function Move(vo:prect;x1,y1,x2,y2:integer):boolean;
        var i,j:integer;
        getout:boolean;
        begin
        getout:=false;
        repeat
        for j:=1 to 300
        do begin
                 vo^.MoveTo(x1,y1+j,x2,y2+j);
                 delay(1500);
                 getout:=keypressed;
                 if getout then break
          end;
        for i:=1 to 300
        do begin
                 vo^.MoveTo(x1+i,y1+j,x2+i,y2+j);
                 delay(1500);
                 getout:=keypressed;
                 if getout then break
          end;
                  for j:=300 downto 1
        do begin
                 vo^.MoveTo(x1+i,y1+j,x2+i,y2+j);
                 delay(1500);
                 getout:=keypressed;
                 if getout then break
          end;
                  for i:=300 downto 1
        do begin
                 vo^.MoveTo(x1+i,y1+j,x2+i,y2+j);
                 delay(1500);
                 getout:=keypressed;
                 if getout then break
          end;
          until getout;
        end;

  Var namepathdriver :string;
	W :world;
	Pt :ppoint;
	Pc :prect;
        over:boolean;

  Begin
	{ инициализация мира }
	writeln('Путь к драйверу');
	readln(namepathdriver);
	w.initworld(detect, detect, namepathdriver);

	{ рождение объектов }
	pc:=new(prect,init(50,50,150,150));

	{ развитие объектов }
	pc^.show;
        repeat
             over:=Move(pc,50,50,100,100);
        until over;
	readln;
	{pt^.moveto(50, 50);
	pc^.moveto(250,250);
	readln;}

	{ смерть объектов }
	dispose(pt,done);
	dispose(pc,done);

	{ конец мира }
	w.endworld;
	readln;
 End.
Dartchuwak вне форума Ответить с цитированием
Старый 13.11.2009, 09:55   #2
OCTAGRAM
Oldschool geek
Форумчанин
 
Аватар для OCTAGRAM
 
Регистрация: 09.03.2009
Сообщений: 611
По умолчанию

Цитата:
Сообщение от Dartchuwak Посмотреть сообщение
но у меня паскаль в полноэкранном режиме не работает.
В School Pak работает.
If you want to get to the top, you have to start at the bottom

http://pascal.net.ru/
OCTAGRAM вне форума Ответить с цитированием
Старый 13.11.2009, 10:23   #3
Gapro
Форумчанин
 
Регистрация: 30.07.2009
Сообщений: 256
По умолчанию

Alt+Enter - полноэкранный режим
Gapro вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Graph Pascal Petr1K Помощь студентам 11 17.05.2009 20:39
Graph Pascal xBaGx Помощь студентам 4 17.05.2009 18:56
Graph(Pascal)+текст rox Помощь студентам 4 03.05.2009 13:49
Pascal. Graph. Razorishe Помощь студентам 6 19.03.2009 15:24