Einzelnen Beitrag anzeigen

Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#3

AW: Ping Pong Programm - Punktescore, Game Over und Start/Stopp

  Alt 23. Mai 2014, 21:27
Zum GameOver und Start/Stop:

Das ist doch Stati die das Programm einnehmen kann. Also erstelle dir eine Variable (bitte keine globale Variable, sondern erstelle die einfach im private Teil der Form-Klasse).

Möglichkeit 1:

Delphi-Quellcode:
const
  GAME_START = 0;
  GAME_RUN = 1;
  GAME_OVER = 2;

type
  TForm1 = class(TForm)
  ...
  private
    FGameState : integer;
  ...
  end;

case FGameState of
  GAME_START : ;
  GAME_RUN : ;
  GAME_OVER : ;
end;
Immer dann wenn du meinst du musst in einen anderen Status, dann trägst du das dort ein und dein Programm kann darauf reagieren.

Möglichkeit 2:

Delphi-Quellcode:
type
  TGameState = ( gsStart, gsRun, gsGameOver );

  TForm1 = class(TForm)
  ...
  private
    FGameState : TGameState;
  ...
  end;

case FGameState of
  gsStart : ;
  gsRun : ;
  gsGameOver : ;
end;
Eigentlich gleiche Vorgehensweise wie in 1
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat