Delphi-PRAXiS
Seite 12 von 18   « Erste     2101112 1314     Letzte »    

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   tic tac toe.... mal wieder:) versteh aufgabestellung nicht ganz (https://www.delphipraxis.net/162412-tic-tac-toe-mal-wieder-versteh-aufgabestellung-nicht-ganz.html)

DeddyH 25. Aug 2011 09:47

AW: tic tac toe.... mal wieder:) versteh aufgabestellung nicht ganz
 
Oder rechte Maustaste aufs Fomular -> Ansicht als Text/Ansicht als Formular ;)

mleyen 25. Aug 2011 09:50

AW: tic tac toe.... mal wieder:) versteh aufgabestellung nicht ganz
 
Zitat:

Zitat von biby90 (Beitrag 1119493)
Delphi-Quellcode:
function TForm1.CheckForWin(AIndex: array of string): Boolean;

Hier liegt das Problem. Bei normalen Arrays fängt der Index bei 0 an.
Mach das so:
Delphi-Quellcode:
//...
  TMyArr = array[1..9] of string;
  TForm1 = class(TForm)
//...
     function CheckForWin(AIndex:TMyArr): Boolean;
//...
   GBuffer: TMyArr;
//...
function TForm1.CheckForWin(AIndex: TMyArr): Boolean;

biby90 25. Aug 2011 09:58

AW: tic tac toe.... mal wieder:) versteh aufgabestellung nicht ganz
 
Delphi-Quellcode:
object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'TicTacToe'
  ClientHeight = 455
  ClientWidth = 582
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 8
    Top = 8
    Width = 137
    Height = 129
    Alignment = taCenter
    AutoSize = False
    Color = clWhite
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -107
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentColor = False
    ParentFont = False
    OnClick = Label1Click
  end
  object Label2: TLabel
    Left = 151
    Top = 8
    Width = 137
    Height = 129
    Alignment = taCenter
    AutoSize = False
    Color = clWhite
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -107
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentColor = False
    ParentFont = False
    OnClick = Label2Click
  end
  object Label3: TLabel
    Left = 294
    Top = 8
    Width = 137
    Height = 129
    Alignment = taCenter
    AutoSize = False
    Color = clWhite
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -107
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentColor = False
    ParentFont = False
    OnClick = Label3Click
  end
  object Label4: TLabel
    Left = 8
    Top = 143
    Width = 137
    Height = 129
    Alignment = taCenter
    AutoSize = False
    Color = clWhite
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -107
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentColor = False
    ParentFont = False
    OnClick = Label4Click
  end
  object Label5: TLabel
    Left = 151
    Top = 143
    Width = 137
    Height = 129
    Alignment = taCenter
    AutoSize = False
    Color = clWhite
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -107
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentColor = False
    ParentFont = False
    OnClick = Label5Click
  end
  object Label6: TLabel
    Left = 294
    Top = 143
    Width = 137
    Height = 129
    Alignment = taCenter
    AutoSize = False
    Color = clWhite
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -107
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentColor = False
    ParentFont = False
    OnClick = Label6Click
  end
  object Label8: TLabel
    Left = 151
    Top = 278
    Width = 137
    Height = 129
    Alignment = taCenter
    AutoSize = False
    Color = clWhite
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -107
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentColor = False
    ParentFont = False
    OnClick = Label8Click
  end
  object Label9: TLabel
    Left = 294
    Top = 278
    Width = 137
    Height = 129
    Alignment = taCenter
    AutoSize = False
    Color = clWhite
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -107
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentColor = False
    ParentFont = False
    OnClick = Label9Click
  end
  object Label10: TLabel
    Left = 437
    Top = 8
    Width = 221
    Height = 33
    AutoSize = False
  end
  object Label7: TLabel
    Left = 8
    Top = 278
    Width = 137
    Height = 129
    Alignment = taCenter
    AutoSize = False
    Color = clBtnHighlight
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -107
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentColor = False
    ParentFont = False
    OnClick = Label7Click
  end
  object CloseButton: TButton
    Left = 437
    Top = 342
    Width = 137
    Height = 65
    Caption = 'Schlie'#223'en'
    TabOrder = 0
    OnClick = CloseButtonClick
  end
  object NewGameButton: TButton
    Left = 437
    Top = 271
    Width = 137
    Height = 65
    Caption = 'Neues Spiel'
    TabOrder = 1
    OnClick = NewGameButtonClick
  end
end

ach du liebe Zeit... was ist denn das?!:shock:

Neutral General 25. Aug 2011 10:00

AW: tic tac toe.... mal wieder:) versteh aufgabestellung nicht ganz
 
Hallo,

Das ist der Code der hinter deinem Formular steckt :mrgreen:
Aber scheinbar liegts daran nicht. Du solltest den Hinweis von mleyen besser weiterverfolgen.

DeddyH 25. Aug 2011 10:04

AW: tic tac toe.... mal wieder:) versteh aufgabestellung nicht ganz
 
Tja, wenn man typisiert, kann einem so etwas nicht so schnell passieren.
Delphi-Quellcode:
type
  TBuffer = array[1..9] of string;

var
  GBuffer: TBuffer;

function CheckForWin(Buffer: TBuffer): Boolean;
[edit]:oops: Das hatte mleyen ja bereits geschrieben [/edit]

biby90 25. Aug 2011 10:04

AW: tic tac toe.... mal wieder:) versteh aufgabestellung nicht ganz
 
Zitat:

Das ist der Code der hinter deinem Formular steckt
joa, hab ich mir gedacht.... wusste garnicht, dass es das gibt

biby90 25. Aug 2011 10:08

AW: tic tac toe.... mal wieder:) versteh aufgabestellung nicht ganz
 
Delphi-Quellcode:
procedure TForm1.MakeArray;
begin
 GBuffer[1] := Label1.Caption;
 GBuffer[2] := Label2.Caption;
 GBuffer[3] := Label3.Caption;
 GBuffer[4] := Label4.Caption;
 GBuffer[5] := Label5.Caption;
 GBuffer[6] := Label6.Caption;
 GBuffer[7] := Label7.Caption;
 GBuffer[8] := Label8.Caption;
 GBuffer[9] := Label9.Caption;
end;
Das kann so bleiben, ja?
Ich starte mal...

biby90 25. Aug 2011 10:10

AW: tic tac toe.... mal wieder:) versteh aufgabestellung nicht ganz
 
:dancer2:
Es Fukntioniert!!!!!!!
Jetzt noch mal was ganz kleines dass seit ihr mich los^^

wenn ich das dritte Feld Klicke um zu gewinnen, dann sagt er schon gewonnen obwohl da noch kein x oder O drin steht...!?

Neutral General 25. Aug 2011 10:12

AW: tic tac toe.... mal wieder:) versteh aufgabestellung nicht ganz
 
Hallo,

Dann schreib mal in den OnClicks:

Delphi-Quellcode:
 if IsFieldEmpty(Label2.Caption) then
 begin
    Label2.Caption := WriteToField(GPlayer);
    Label2.Repaint; // oder: Application.ProcessMessages
    MakeArray;
    // Weiterer Code

biby90 25. Aug 2011 10:13

AW: tic tac toe.... mal wieder:) versteh aufgabestellung nicht ganz
 
Wofür steht das Repaint?


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:05 Uhr.
Seite 12 von 18   « Erste     2101112 1314     Letzte »    

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz