Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.Imaging.pngimage,
- Vcl.Imaging.jpeg, Vcl.StdCtrls;
- type
- TPlane=record //Aqui O Type De variavel novo
- x,y: integer;
- w,h: integer;
- visible: boolean;
- TempBitmap: Tbitmap;
- end;
- type
- TForm1 = class(TForm)
- aviao: TImage;
- fundo: TImage;
- TimerTrabalho: TTimer;
- Image1: TImage;
- TimerBit: TTimer;
- rato: TImage;
- Label1: TLabel;
- StaticText1: TStaticText;
- procedure TimerTrabalhoTimer(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- procedure TimerBitTimer(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
- procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- avioes: array [0..3] of TPlane; //Aqui Crio O Array De 0 a 3 Ou Seja 4
- //Que Irá Fazer Uma Multiplicação Assim Dizendo Daquele Tipo De 0 Ate 4
- x: integer; //Aqui As Cordenadas Inteiras Do X
- y: integer;
- TempBitmap: Tbitmap; //Aqui E A Variavel Para Dizer Que Isto E Um Bitmap
- r1:TRect; //Estrutura que representa um rectangulo
- p1:TPoint;
- HCursor : THandle;
- cursorx,cursory: integer; //Aqui Sao criadas as cordenadas Do
- //cursor x e y
- pontos: integer;
- implementation
- {$R *.dfm}
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- TempBitmap:=Tbitmap.Create;
- TempBitmap.Width:=width; //Cria O TBitMap No Evento OnCreate Do Form
- TempBitmap.Height:=height;
- Statictext1.Caption:= 'Pontuação = ' +inttostr(pontos);
- Statictext1.Color:= clRed;
- end;
- procedure TForm1.FormDestroy(Sender: TObject);
- begin
- TempBitmap.free; //Liberta A Memoria Do Tempbitmap
- end;
- procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- begin
- p1.X:=0;
- p1:=Point(10,20);
- p1.SetLocation(20,30);
- r1:=Rect(10,10,50,60);
- r1.Offset(20,20);
- if PtinRect(r1,p1) then
- ShowMessage('Acertou Em Cheio');
- end;
- procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- begin
- cursorx:=x-95; //No Evento MouseMouve Sao Postas As Cordenadas
- cursory:=y-95; //Do Cursor E Faz-se Desapareçer O
- showcursor(false); //Cursor Antigo
- end;
- procedure TForm1.FormShow(Sender: TObject);
- begin
- avioes[0].x:=475;
- avioes[1].x:=475; //Cordenadas De Onde Vai Comecar Os Avioes
- avioes[1].y:=120;
- avioes[2].x:=475;
- avioes[2].y:=270;
- end;
- procedure TForm1.TimerBitTimer(Sender: TObject);
- begin
- with TempBitmap do
- begin
- canvas.FillRect(Rect(0,0,width,height));
- canvas.Draw(x,y,fundo.Picture.Graphic);
- canvas.Draw(avioes[0].x,avioes[0].y,aviao.Picture.Graphic);
- canvas.Draw(avioes[1].x,avioes[1].y,aviao.Picture.Graphic);
- canvas.Draw(avioes[2].x,avioes[2].y,aviao.Picture.Graphic);
- canvas.Draw(cursorx,cursory,rato.Picture.graphic);
- //Aqui Na Ultima Linha E Onde A Mira Sera Desenhada
- //Por Cima Do Rato Nas Cordenadas Defenidas
- end;
- self.canvas.draw(0,0,TempBitMap);
- //No Final Ponho Este Comando Para Ele Apareçer Com O Timer
- end;
- procedure TForm1.TimerTrabalhoTimer(Sender: TObject);
- begin
- if avioes[0].x < x-300 then avioes[0].x:= x+750;
- avioes[0].x:=avioes[0].x-5;
- if avioes[1].x < x-500 then avioes[1].x:= x+800;
- avioes[1].x:=avioes[1].x-10;
- if avioes[2].x < x-600 then avioes[2].x:= x+950;
- avioes[2].x:=avioes[2].x-7;
- //Aqui A Zona Para Mover Os Avioes As Cordenadas Ate Onde Vao Velocidade Etc...
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement