Шустрый

Профиль
Группа: Участник
Сообщений: 71
Регистрация: 12.2.2010
Репутация: нет Всего: нет
|
Код |
unit Unit1;
{$mode objfpc}{$H+}
interface
uses Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, Calendar;
type
{ TForm1 }
TForm1 = class(TForm) Button1: TButton; PaintBox1: TPaintBox; Timer1: TTimer; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure PaintBox1Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure Ship(cx,cy:Integer; ColorShip :TColor); private
{ private declarations } public { public declarations } end;
var Form1: TForm1; Var cx,cy: Integer; Var x,y : Double; i,j :Integer;
implementation
{ TForm1 }
procedure TForm1.Ship (cx,cy:Integer; ColorShip :TColor); begin with PaintBox1.Canvas do begin Pen.Style := psSolid; Brush.Color :=ColorShip;
// nachalo korabl'a
PaintBox1.Canvas.Brush.Color := RGBToColor(20,100,50); // цвет корпуса PaintBox1.Canvas.Polygon([Point(cx+30,cy+100),Point(cx,cy),Point(2*cx,cy-80),Point(cx+300,cy-80),Point(14*cx,cy-40),Point(12*cx+20,cy+70),Point(10*cx,cy+100)]); // корпус
PaintBox1.Canvas.MoveTo(cx,cy); PaintBox1.Canvas.LineTo(10*cx,cy); PaintBox1.Canvas.LineTo(14*cx,cy-40);
PaintBox1.Canvas.MoveTo(cx+300,cy-80); PaintBox1.Canvas.LineTo(10*cx,cy); PaintBox1.Canvas.LineTo(10*cx,cy+100);
with PaintBox1.Canvas do begin Brush.Color := RGBToColor(150,155,50); Polygon([Point(cx,cy),Point(cx,cy-100),Point(5*cx,cy-100),Point(5*cx,cy)]); //каюта Polygon([Point(5*cx,cy-100),Point(6*cx,cy-170),Point(2*cx,cy-170),Point(cx,cy-100)]); Polygon([Point(6*cx,cy-170),Point(6*cx,cy-80),Point(5*cx,cy),Point(5*cx,cy-100)]);
Brush.Color:=clBlack; Ellipse(cx+10,cy-80,cx+50,cy-40); // элюминатор Brush.Color:=clWhite; Ellipse(cx+15,cy-75,cx+45,cy-45);
Brush.Color:=clBlack; Ellipse(cx+70,cy-80,cx+110,cy-40); // элюминатор Brush.Color:=clWhite; Ellipse(cx+75,cy-75,cx+105,cy-45);
Brush.Color := RGBToColor(90,120,100); Polygon([Point(7*cx+10,cy-190),Point(7*cx+10,cy-30),Point(9*cx,cy-30),Point(9*cx,cy-190)]); //труба
Ellipse(7*cx+10,cy-200,9*cx,cy-180); Brush.Color := RGBToColor(70,80,70); Ellipse(7*cx+15,cy-195,8*cx+25,cy-185);
end; // konec korabl'a
end; end;
procedure TForm1.PaintBox1Click(Sender: TObject); begin
end;
procedure TForm1.Timer1Timer(Sender: TObject); begin
{ARect := Rect (cx,cy,cx+390,cy+330); // что тут писать? PaintBox1.Canvas.CopyRect (Arect,BitMap,Canvas,ARect); Ship (cx,cy,clWhite); cx := cx + 5; } end;
procedure TForm1.Button1Click(Sender: TObject);
begin
PaintBox1.width :=800; PaintBox1.height :=800;
PaintBox1.Canvas.Brush.Color := RGBToColor(540,185,740); // цвет воды в реке , не на всем экране ? PaintBox1.Canvas.Rectangle(0,0,PaintBox1.width,PaintBox1.height);
cx := 0; // река cy := PaintBox1.Height - 200; x := -2.314159;
while x < PaintBox1.width do begin y := sin(x); PaintBox1.Canvas.Pixels[cx+round(x*80),cy+round(y*20)] := clBlue; x:=x + 0.01; end;
cx := 0; cy := PaintBox1.Height - 600; x := -2.314159;
while x < PaintBox1.width do begin y := cos(x); PaintBox1.Canvas.Pixels[cx+round(x*80),cy+round(y*20)] := clBlue; x:=x + 0.01; end;
// nachalo korabl'a cx:=30; cy:=450;
PaintBox1.Canvas.Brush.Color := RGBToColor(20,100,50); // цвет корпуса PaintBox1.Canvas.Polygon([Point(cx+30,cy+100),Point(cx,cy),Point(2*cx,cy-80),Point(cx+300,cy-80),Point(14*cx,cy-40),Point(12*cx+20,cy+70),Point(10*cx,cy+100)]); // корпус
PaintBox1.Canvas.MoveTo(cx,cy); PaintBox1.Canvas.LineTo(10*cx,cy); PaintBox1.Canvas.LineTo(14*cx,cy-40);
PaintBox1.Canvas.MoveTo(cx+300,cy-80); PaintBox1.Canvas.LineTo(10*cx,cy); PaintBox1.Canvas.LineTo(10*cx,cy+100);
with PaintBox1.Canvas do begin Brush.Color := RGBToColor(150,155,50); Polygon([Point(cx,cy),Point(cx,cy-100),Point(5*cx,cy-100),Point(5*cx,cy)]); //каюта Polygon([Point(5*cx,cy-100),Point(6*cx,cy-170),Point(2*cx,cy-170),Point(cx,cy-100)]); Polygon([Point(6*cx,cy-170),Point(6*cx,cy-80),Point(5*cx,cy),Point(5*cx,cy-100)]);
Brush.Color:=clBlack; Ellipse(cx+10,cy-80,cx+50,cy-40); // элюминатор Brush.Color:=clWhite; Ellipse(cx+15,cy-75,cx+45,cy-45);
Brush.Color:=clBlack; Ellipse(cx+70,cy-80,cx+110,cy-40); // элюминатор Brush.Color:=clWhite; Ellipse(cx+75,cy-75,cx+105,cy-45);
Brush.Color := RGBToColor(90,120,100); Polygon([Point(7*cx+10,cy-190),Point(7*cx+10,cy-30),Point(9*cx,cy-30),Point(9*cx,cy-190)]); //труба
Ellipse(7*cx+10,cy-200,9*cx,cy-180); Brush.Color := RGBToColor(70,80,70); Ellipse(7*cx+15,cy-195,8*cx+25,cy-185);
end;
// konec korabl'a
{ BitMap := TBitmap.Create; BitMap.Width := PaintBox1.Width; BitMap.Height:= PaintBox1.Height; ARect := Rect (0,0,PaintBox1.Width, PaintBox1.Height); BitMap.Canvas.CopyRect (ARect,PaintBox1,Canvas,ARect); }
Timer1.Enabled:=True;
end;
procedure TForm1.FormCreate(Sender: TObject); begin
end;
initialization {$I unit1.lrs}
end.
|
как заставить карабль двигаться по неоднородному фону с помощью создания дубля? Пока что у меня фон однородный, но надо неоднородный. Help! )
|