Прочитайте Обращение к программистам!!!
Обращение к Программистам
Предлагаю свою наработку по управлению игрой.
Код:
unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Menus, ExtCtrls; type { TForm1 } TForm1 = class(TForm) Image1: TImage; Image2: TImage; MainMenu1: TMainMenu; MenuItem1: TMenuItem; MenuItem2: TMenuItem; Timer1: TTimer; procedure FormCreate(Sender: TObject); procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); procedure Image1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Image1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure MenuItem2Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); private public end; var Form1: TForm1; lf1,rf1: Boolean; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState ); begin If (Key=37) or (Key=65)then lf1:= True; If (Key=39) or (Key=83)then rf1:= True; end; procedure TForm1.FormCreate(Sender: TObject); begin lf1:= False; rf1:= False; end; procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); begin If (Key=37) or (Key=65)then lf1:= False; If (Key=39) or (Key=83)then rf1:= False; end; procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin If (Button=mbLeft) then lf1:= True; If (Button=mbRight) then rf1:= True; end; procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin If (Button=mbLeft) then lf1:= False; If (Button=mbRight) then rf1:= False; end; procedure TForm1.MenuItem2Click(Sender: TObject); begin Timer1.Enabled:=true; end; procedure TForm1.Timer1Timer(Sender: TObject); begin If lf1 and (Image2.Left>20) then Image2.Left:=Image2.Left-2; If rf1 and (Image2.Left<(280-Image2.Width)) then Image2.Left:=Image2.Left+2; end; end.