1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
program roue;
uses Flash8;
const R=80;
e=4;
{$FRAME_WIDTH 1000}
{$FRAME_HEIGHT 200}
{$FRAME_RATE 100}
type
TRayon =class(MovieClip)
constructor Create(parent: MovieClip);
end;
TRoue = class(MovieClip)
Rayon: TRayon;
constructor Create(parent: MovieClip);
procedure onEnterFrame;
end;
TSol=class(MovieClip)
roue:TRoue;
constructor Create;
end;
var retour:boolean;
dtheta:double;
sol:TSol;
constructor TSol.Create;
begin
inherited Create(nil,'sol',1);
BeginFill($000000);
moveto(0,180+e);
lineto(1000,180+e);
lineto(1000,185+e);
lineto(0,185+e);
lineto(0,180+e);
EndFill();
roue:=TRoue.create(self);
end;
constructor TRoue.Create(parent:MovieClip);
var a,b:double;
begin
inherited Create(parent,'roue', 1);
_x := R;
_y := 100;
a:= r * 0.414213562;
b:= r * 0.707106781;
lineStyle(2*e, $000000);
moveTo(r, 0);
curveTo( r, -a, +b, -b);
curveTo( a, -r, 0, -r);
curveTo(-a, -r, -b, -b);
curveTo(-r, -a, -r, 0);
curveTo(-r, +a, -b, +b);
curveTo(-a, +r, 0, +r);
curveTo( a, +r, +b, +b);
curveTo( r, +a, +r, 0);
EndFill();
retour:=true;
dtheta:=3.14/180;
Rayon := TRayon.Create(self);
end;
constructor TRayon.Create(Parent: MovieClip);
begin
inherited Create(parent,'rayon',1);
lineStyle(e,$000000);
moveto(-R,0);
lineto(0,0);
moveto(0,-R);
lineto(0,R);
lineStyle(e,$ff0000);
moveto(0,0);
lineto(R,0);
end;
procedure TRoue.onEnterFrame;
begin
if retour then
begin
_x := _x + R*dtheta;
Rayon._rotation:=Rayon._rotation +1; //1°
end
else
begin
_x:= _x -R*dtheta ;
Rayon._rotation:=Rayon._rotation -1;
end;
if (_x+R>=1000) or (_x-R<=0) then retour:=not retour; //modif <=0 ! sinon quand la valeur est nulle,c'est indéfini...
end;
begin
sol:= TSol.Create;
end. |
Partager