Autor Beitrag
ConditionZero
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 190

Win XP
Delphi 7 PE, C++ (Dev-C++), HTML+PHP (Dreamweaver MX), JavaScript(MS FrontPage)
BeitragVerfasst: Sa 04.11.06 21:17 
nabend,

hab mich heut abend mal aus Langeweile an den PC gesessen und hab mir gedacht ich könnt mal wieder in Delphi aktiv werden und wollt ein kleines Ping Pong zu begin machen. nur als ich versucht habe den Ball an der unteren Wand abprallen zu lassen kam mir ein Logikfehler auf und weiß nicht was machen.
hier mein code ihr werdet schnell daran erkennen was mir für ein fehler passiert ist.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.AnimTimerTimer(Sender: TObject);
begin
if Ball.Height < Form1.Height then
  begin
  Ball.Height:= Ball.Height+2;
  end;

if Ball.Height >= Form1.Height then
  begin
  Ball.Height:= Ball.Height-2;
  end;

end;


warum es nicht geht weiß ich jetzt aber wie ichs beheben soll nicht, kann mir vll jmd. weiterhelfen. danke im vorraus schonmal.
LG
Marc

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt
SchwiegerSohn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25



BeitragVerfasst: Sa 04.11.06 23:45 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
var StepL : Integer = 1;
    StepT : Integer = 1;


Procedure Form1.Timer1OnTimer(...);
begin
  if ball.top <= 0 then
    StepT := StepT * -1;

  if ball.left <=0 then
    StepL := StepL * -1;

  if (ball.Top + Ball.height) >= Form1.Height then
    StepT := StepT * -1;

  if (ball.Left + Ball.width) >= Form1.Width then
    StepL := StepL * -1;

  ball.left := ball.left + StepL;
  ball.top := ball.top + StepT;
end;

_________________
Wer rechtschreibfehler findet darf sie behalten!
SchwiegerSohn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25



BeitragVerfasst: Sa 04.11.06 23:47 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
var StepL : Integer = 1;
    StepT : Integer = 1;


Procedure Form1.Timer1OnTimer(...);
begin
  if ball.top <= 0 then
    StepT := StepT * -1;

  if ball.left <=0 then
    StepL := StepL * -1;

  if (ball.Top + Ball.height) >= Form1.Height then
    StepT := StepT * -1;

  if (ball.Left + Ball.width) >= Form1.Width then
    StepL := StepL * -1;

  ball.left := ball.left + StepL;
  ball.top := ball.top + StepT;
end;


Moderiert von user profile iconAXMD: Delphi-Tags korrigiert

_________________
Wer rechtschreibfehler findet darf sie behalten!
ConditionZero Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 190

Win XP
Delphi 7 PE, C++ (Dev-C++), HTML+PHP (Dreamweaver MX), JavaScript(MS FrontPage)
BeitragVerfasst: So 05.11.06 00:22 
dankeschöööön =)