Mordobicie

0

Szykuje gre mordobicie. Mam wszystkie pomysły, kody obmyślane. Zrobiłęm małą próbę. Nie wychodzi. Dobra. Opisze. robie ruchy, a potem kod żeby nie wpadł na słup .

if glowa.left = slup.left - 2 then
begin
c.left := c.left - 3;
n1.left := n1.left - 3;
n2.left := n2.left - 3;
n3.left := n3.left - 3;
o.left := o.left - 3;
s.left := s.left - 3;
end;

Podzieliłęm ciało na różne części(c,n1,n2,n3 itd. ). Ale to nie działa. Więc do daje

var
x : integer;
z : integer;

i w formCreate

x := glowa.left;
z := slup.left;

i teraz:

if x = z - 2 then
begin
c.left := c.left - 3;
n1.left := n1.left - 3;
n2.left := n2.left - 3;
n3.left := n3.left - 3;
o.left := o.left - 3;
s.left := s.left - 3;
end

Nie działa - proszę o pomoc:(Kod źródłowy)

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;

type
TForm1 = class(TForm)
podloga: TShape;
n1: TShape;
n2: TShape;
sss: TShape;
c: TShape;
o: TShape;
s: TShape;
n3: TShape;
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
var
x : integer;
z : integer;
aa : integer;

procedure TForm1.FormCreate(Sender: TObject);
begin
x := o.left;
z := sss.Left;
end;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_LEFT then
begin
c.left := c.left - 10;
n1.left := n1.left - 10;
n2.left := n2.left - 10;
n3.left := n3.left - 10;
o.left := o.left - 10;
s.left := s.left - 10;
end;

if Key = VK_RIGHT then
begin
c.left := c.left + 10;
n1.left := n1.left + 10;
n2.left := n2.left + 10;
n3.left := n3.left + 10;
o.left := o.left + 10;
s.left := s.left + 10;
end;

if x = z - 2 then
begin
c.left := c.left - 3;
n1.left := n1.left - 3;
n2.left := n2.left - 3;
n3.left := n3.left - 3;
o.left := o.left - 3;
s.left := s.left - 3;

0

hmm pomijasz grubość słupa, lub grubość gostka :)

if glowa.left = slup.left+ slup.Width + 2 then // porusza sie wlewo gostek
begin
c.left := c.left - 3;
n1.left := n1.left - 3;
n2.left := n2.left - 3;
n3.left := n3.left - 3;
o.left := o.left - 3;
s.left := s.left - 3;
end;

1 użytkowników online, w tym zalogowanych: 0, gości: 1