Advertisement
Guest User

Codigo Ajuda!

a guest
Jan 2nd, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6. Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7. Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.Imaging.pngimage,
  8. Vcl.Imaging.jpeg, Vcl.StdCtrls;
  9. type
  10. TPlane=record //Aqui O Type De variavel novo
  11. x,y: integer;
  12. w,h: integer;
  13. visible: boolean;
  14. TempBitmap: Tbitmap;
  15.  
  16. end;
  17.  
  18. type
  19. TForm1 = class(TForm)
  20. aviao: TImage;
  21. fundo: TImage;
  22. TimerTrabalho: TTimer;
  23. Image1: TImage;
  24. TimerBit: TTimer;
  25. rato: TImage;
  26. Label1: TLabel;
  27. StaticText1: TStaticText;
  28. procedure TimerTrabalhoTimer(Sender: TObject);
  29. procedure FormCreate(Sender: TObject);
  30. procedure FormDestroy(Sender: TObject);
  31. procedure TimerBitTimer(Sender: TObject);
  32. procedure FormShow(Sender: TObject);
  33. procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
  34. procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
  35. Shift: TShiftState; X, Y: Integer);
  36.  
  37. private
  38. { Private declarations }
  39. public
  40. { Public declarations }
  41. end;
  42.  
  43. var
  44. Form1: TForm1;
  45. avioes: array [0..3] of TPlane; //Aqui Crio O Array De 0 a 3 Ou Seja 4
  46. //Que Irá Fazer Uma Multiplicação Assim Dizendo Daquele Tipo De 0 Ate 4
  47. x: integer; //Aqui As Cordenadas Inteiras Do X
  48. y: integer;
  49. TempBitmap: Tbitmap; //Aqui E A Variavel Para Dizer Que Isto E Um Bitmap
  50. r1:TRect; //Estrutura que representa um rectangulo
  51. p1:TPoint;
  52. HCursor : THandle;
  53. cursorx,cursory: integer; //Aqui Sao criadas as cordenadas Do
  54. //cursor x e y
  55. pontos: integer;
  56.  
  57. implementation
  58.  
  59. {$R *.dfm}
  60.  
  61. procedure TForm1.FormCreate(Sender: TObject);
  62. begin
  63. TempBitmap:=Tbitmap.Create;
  64. TempBitmap.Width:=width; //Cria O TBitMap No Evento OnCreate Do Form
  65. TempBitmap.Height:=height;
  66. Statictext1.Caption:= 'Pontuação = ' +inttostr(pontos);
  67. Statictext1.Color:= clRed;
  68. end;
  69.  
  70. procedure TForm1.FormDestroy(Sender: TObject);
  71. begin
  72. TempBitmap.free; //Liberta A Memoria Do Tempbitmap
  73. end;
  74.  
  75. procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  76. Shift: TShiftState; X, Y: Integer);
  77. begin
  78. p1.X:=0;
  79. p1:=Point(10,20);
  80. p1.SetLocation(20,30);
  81. r1:=Rect(10,10,50,60);
  82. r1.Offset(20,20);
  83. if PtinRect(r1,p1) then
  84. ShowMessage('Acertou Em Cheio');
  85. end;
  86.  
  87. procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  88. Y: Integer);
  89. begin
  90. cursorx:=x-95; //No Evento MouseMouve Sao Postas As Cordenadas
  91. cursory:=y-95; //Do Cursor E Faz-se Desapareçer O
  92. showcursor(false); //Cursor Antigo
  93. end;
  94.  
  95. procedure TForm1.FormShow(Sender: TObject);
  96. begin
  97. avioes[0].x:=475;
  98. avioes[1].x:=475; //Cordenadas De Onde Vai Comecar Os Avioes
  99. avioes[1].y:=120;
  100. avioes[2].x:=475;
  101. avioes[2].y:=270;
  102. end;
  103.  
  104. procedure TForm1.TimerBitTimer(Sender: TObject);
  105. begin
  106. with TempBitmap do
  107. begin
  108. canvas.FillRect(Rect(0,0,width,height));
  109. canvas.Draw(x,y,fundo.Picture.Graphic);
  110. canvas.Draw(avioes[0].x,avioes[0].y,aviao.Picture.Graphic);
  111. canvas.Draw(avioes[1].x,avioes[1].y,aviao.Picture.Graphic);
  112. canvas.Draw(avioes[2].x,avioes[2].y,aviao.Picture.Graphic);
  113. canvas.Draw(cursorx,cursory,rato.Picture.graphic);
  114. //Aqui Na Ultima Linha E Onde A Mira Sera Desenhada
  115. //Por Cima Do Rato Nas Cordenadas Defenidas
  116. end;
  117. self.canvas.draw(0,0,TempBitMap);
  118.  
  119. //No Final Ponho Este Comando Para Ele Apareçer Com O Timer
  120.  
  121. end;
  122.  
  123. procedure TForm1.TimerTrabalhoTimer(Sender: TObject);
  124. begin
  125. if avioes[0].x < x-300 then avioes[0].x:= x+750;
  126. avioes[0].x:=avioes[0].x-5;
  127. if avioes[1].x < x-500 then avioes[1].x:= x+800;
  128. avioes[1].x:=avioes[1].x-10;
  129. if avioes[2].x < x-600 then avioes[2].x:= x+950;
  130. avioes[2].x:=avioes[2].x-7;
  131. //Aqui A Zona Para Mover Os Avioes As Cordenadas Ate Onde Vao Velocidade Etc...
  132. end;
  133.  
  134. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement