AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi Berührung 2er bewegter Kreise
Thema durchsuchen
Ansicht
Themen-Optionen

Berührung 2er bewegter Kreise

Ein Thema von mr____zero · begonnen am 25. Mai 2009 · letzter Beitrag vom 26. Mai 2009
 
mr____zero

Registriert seit: 22. Mär 2009
13 Beiträge
 
#1

Berührung 2er bewegter Kreise

  Alt 25. Mai 2009, 15:23
ersteinmal hallo bin hier schonwas länger angemeldet brauchte aber bisher noch nicht wirklich hilfe
jetzt schon^^

mein problem ist das wir für die schule ein prog schreiben sollen indem sich auf einem canvas 2 kreise bewegen die gleiche oder verschiedene geschwindigkeiten haben
treffen diese auf die wände sollen sie reflektiert werden was auch klappt aller dings sollen sie auch reflecktiert werden wenn sie sich gegenseitig berühren und da liegt mein problem

hier einmal den quelltext

Code:
verschx := StrToInt(edit1.text);
    verschy := StrToInt(edit2.text);
    verschx1 := StrToInt(edit3.text);
    verschy1 := StrToInt(edit4.text);

    image1.Canvas.Pen.Color := clwhite;
    image1.Canvas.Brush.Color := clwhite;
    image1.Canvas.Rectangle(x,y,x+50,y+50);
    image1.Canvas.Rectangle(x1,y1,x1+50,y1+50);

    x := x+verschx;
    y := y+verschy;
    x1 := x1+verschx1;
    y1 := y1+verschy1;
    image1.Canvas.Pen.Color := clred;
    image1.Canvas.Brush.Color := clred;

    {if (((x1 <= x+50) and (x1 >= x)) and ((y1 <= y+50) and (y1 >= y)))
    then begin
             edit1.Text := IntToStr(StrToInt(Edit1.Text)*(-1));
             edit3.Text := IntToStr(StrToInt(Edit3.Text)*(-1));
             edit2.Text := IntToStr(StrToInt(Edit2.Text)*(-1));
             edit4.Text := IntToStr(StrToInt(Edit4.Text)*(-1));
         end;}
    if (x1+25-x+25+y1+25-y+25) > 0
    then if (Round(sqrt(x1+25-x+25+y1+25-y+25))) <= 50
         then begin
               edit1.Text := IntToStr(StrToInt(Edit1.Text)*(-1));
               edit3.Text := IntToStr(StrToInt(Edit3.Text)*(-1));
               edit2.Text := IntToStr(StrToInt(Edit2.Text)*(-1));
               edit4.Text := IntToStr(StrToInt(Edit4.Text)*(-1));
              end ;



    if x <= 0
    then edit1.Text := IntToStr(StrToInt(Edit1.Text)*(-1));

    if x >= image1.Width-50-StrToInt(Edit1.Text)
    then edit1.Text := IntToStr(StrToInt(Edit1.Text)*(-1));

    if y <= 0
    then edit2.Text := IntToStr(StrToInt(Edit2.Text)*(-1));

    if y >= image1.Height-50-StrToInt(Edit2.Text)
    then edit2.Text := IntToStr(StrToInt(Edit2.Text)*(-1));

    image1.Canvas.Ellipse(x,y,x+50,y+50);

    if x1 <= 0
    then edit3.Text := IntToStr(StrToInt(Edit3.Text)*(-1));

    if x1 >= image1.Width-50-StrToInt(Edit3.Text)
    then edit3.Text := IntToStr(StrToInt(Edit3.Text)*(-1));

    if y1 <= 0
    then edit4.Text := IntToStr(StrToInt(Edit4.Text)*(-1));

    if y1 >= image1.Height-50-StrToInt(Edit4.Text)
    then edit4.Text := IntToStr(StrToInt(Edit4.Text)*(-1));

    image1.Canvas.Brush.Color := clblue;
    image1.Canvas.Pen.Color := clblue;
    image1.Canvas.Ellipse(x1,y1,x1+50,y1+50);
hoffe das ihr mir helfen könnt
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:30 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz