unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 =
class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
procedure FormKeyUp(Sender: TObject;
var Key: Word; Shift: TShiftState);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
Keys:
Array[0..255]
of Boolean;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
Keys[Key]:=True;
end;
procedure TForm1.FormKeyUp(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
Keys[Key]:=False;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if Keys[Ord('
W')]
then
movie1.Top:= movie1.Top -10;
if Keys[Ord('
S')]
then
movie1.Top:= movie1.Top +10;
if Keys[Ord('
A')]
then
movie1.left:= movie1.left -10;
if Keys[Ord('
D')]
then
movie1.left:= movie1.left +10;
if Keys[VK_UP]
then
movie2.Top:= movie2.Top -10;
if Keys[VK_DOWN] =
then
movie2.Top:= movie2.Top +10;
if Keys[VK_LEFT]
then
movie2.left:= movie2.left -10;
if Keys[VK_RIGHT]
then
movie2.left:= movie2.left +10;
end;
end.