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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
program roue;
uses Flash8,math;
const R=80;
e=4;
{$FRAME_WIDTH 1000}
{$FRAME_HEIGHT 200}
{$FRAME_RATE 100}
{$BACKGROUND $008080}
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;
trajectoire:array[1..1000,1..2] of integer;// tableau dynamique inutilisable pas de setlength (1000 au pif)
//pas de tableau de TPoint-> Tpoint n'existe pas (point dans actionscript ? pourtant)- pas de possibilité d'en faire non plus-> pas de record.
sol:TSol;
constructor TSol.Create;
var i,nb:integer;
begin
inherited Create(nil,'sol',1);
nb:=floor(1000/(R*dtheta));//nombre d'avancées par frame_rate sur la largeur
for i:=1 to nb do
begin
trajectoire[i,1]:=floor(i*R*dtheta); //coord.x point cycloïde
trajectoire[i,2]:=floor(R*SIN(-i*dtheta)); //coord.y le moins pour le sens trigo
end;
lineStyle(e,$FFFBF0);
moveto(0,100);
for i:=1 to nb do lineto(trajectoire[i,1],trajectoire[i,2]);
BeginFill($FFFBF0);
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, $FFFBF0);
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,$FFFBF0);
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;
var j:integer;
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