hallo!
ich programmiere gerade ein tischtennisspiel:
ich habe bereits programmiert dass man zwei shapes auf und ab bewegen kann, also für 2 spieler.
der ball bewegt sich auch schon
nur wie kann ich jetzt programmieren dass, wenn der ball auf die beiden shapes kommt wieder zurückkommt?
Quelltext
1: 2: 3: 4:
| if shape2.top>=5 then if key='ü' then shape2.top:=shape2.top-8; if shape1.top>=5 then if key='q' then shape1.top:=shape1.top-8; if shape2.top+shape2.height<=clientheight-5 then if key='ö' then shape2.top:=shape2.top+8; if shape1.top+shape1.height<=clientheight-5 then if key='a' then shape1.top:=shape1.top+8; |
dass ist meine testenbelegung
gut, aber jetzt ist das problem, wie prallt der ball vom schläger ab,
ich habe es soweit das er an allen seiten abprallt, doch am schläger?
für alle 4 seiten:
Quelltext
1: 2: 3: 4: 5: 6: 7:
| if image1.Left >= form1.clientwidth - image1.width then dx:=-dx;
if image1.Left < 0 then dx:=-dx;
if image1.top >= form1.clientheight - image1.height then dy:=-dy;
if image1.top < 0 then dy:=-dy; |