AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi Problem mit "Programm" für die Schule
Thema durchsuchen
Ansicht
Themen-Optionen

Problem mit "Programm" für die Schule

Ein Thema von just.cause · begonnen am 28. Apr 2009 · letzter Beitrag vom 5. Mai 2009
 
Patrick L.

Registriert seit: 22. Mär 2009
10 Beiträge
 
FreePascal / Lazarus
 
#23

Re: Problem mit "Programm" für die Schule

  Alt 4. Mai 2009, 16:35
Ich hab mal was geschrieben.

Delphi-Quellcode:
...
var
  akSp: integer=1;
  pkSp: array [1..2] of integer;
  run: boolean=true;

implementation

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
VAR Select:integer;
begin
if Run=true then
begin
  case Key of
  's': shape1.top:=shape1.top+10;
  'w': shape1.top:=shape1.top-10;
  'd': shape1.Left:=shape1.Left+10;
  'a': shape1.left:=shape1.left-10;
  'k': shape2.top:=shape2.top+10;
  'i': shape2.top:=shape2.top-10;
  'l': shape2.Left:=shape2.Left+10;
  'j': shape2.left:=shape2.left-10;
  end;

rungame;
end
Else
begin
Select:=MessageDlg('Sie wurden gefangen! Möchten Sie weiter spielen?',mtConfirmation,[mbYes,mbNo],0);
  case Select of
  mrYes: begin
          Shape1.Top:=128;
          Shape1.Left:=144;
          Shape2.Top:=128;
          Shape2.Left:=416;
          Run:=true;
          end;
  mrNo: close;
  end;
end;
end;

procedure TForm1.RunGame;
var abstand:real;
x1,y1,x2,y2:real;
begin
x1:=Shape1.Left+Shape1.Width/2;
x2:=Shape2.Left+Shape2.Width/2;
y1:=Shape1.Top+Shape1.Height/2;
y2:=Shape2.Top+Shape2.Height/2;
abstand:=sqrt(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)))-105;
 if abstand<0 then
  begin
  pkSp[akSp]:=pkSp[akSp]+1;
  Label4.Caption:=inttostr(pkSp[1])+':'+inttostr(PkSp[2]);
  run:=false;
  end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
akSP:=setGegner(akSp);
end;

function TForm1.setGegner(aksp:integer):integer;
begin
if aksp=1 then result:=2
else result:=1;
Label3.Caption:='Spieler '+inttostr(result)+' du bist dran!';
end;
Leider weiß ich noch nicht, wie man die Kreise zur gleichen Zeit steuern kann. Vielleicht mit GetAsyncKeystate() und einer Procedure die immer wieder aufgerufen wird.
Angehängte Dateien
Dateityp: exe project_157.exe (648,0 KB, 7x aufgerufen)
Patrick
  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 08:03 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