私は Dephi に関する宿題をいくつか持っています (以前は使用したことがなく、c++/Java のみでしたが、私の大学では Delphi 言語の科目があります)。うーん、動くフィギュアで形を作ったり、ぶつかったりとか。抽象クラスのような uint を作り始めました
unit MyFigure;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Buttons, StdCtrls;
type
tPoint = record
x,y: Double;
end;
oFigure = class
c: TCanvas;
pos: tPoint;
vel: tPoint;
r: Double;
constructor create(coord, vect: tPoint; radius: Double);
protected
procedure move();
procedure draw(); virtual;
public
function isIntersected(x:oFigure):boolean;
end;
implementation
constructor oFigure.create(coord, vect: tPoint; radius: Double);
begin
pos.x:= coord.x;
pos.y:= coord.y;
vel.x:= vect.x;
vel.y:= vect.y;
r:=radius;
end;
procedure oShape.draw(); virtual;
begin
end;
procedure oShape.move();
begin
pos.x:= pos.x + vel.x;
pos.y:= pos.y + vel.y;
oShape.draw();
end;
function isIntersected(o:oFigure):boolean;
begin
if ((oShape.pos.x - o.pos.x)*(oShape.pos.x - o.pos.x) + (oShape.pos.y - o.pos.y)*(oShape.pos.y - o.pos.y)
< (oShape.r + o.r)*(oShape.r + o.r)) then Result:=True;
end;
end.
次に、その子を作成しました。さて、ここでキャンバスからアーク メソッドを呼び出してボールを描画する必要がありますが、表示されず、イブはunable to invoke code completion
. どうしたの?
unit Ball;
interface
uses
MyFigure;
type
oBall = class(oFigure);
c: TCanvas;
procedure draw(); override;
end;
implementation
procedure oBall.draw();
begin
c.Arc()//PROBLEM!
end;
end.