Thema: 4gewinnt

Einzelnen Beitrag anzeigen

Wega2104

Registriert seit: 20. Mai 2017
2 Beiträge
 
#1

4gewinnt

  Alt 20. Mai 2017, 15:55
Guten Tag allerseits,

ich bräuchte dringend hilfe beim programmieren von 4gewinnt (mit Shapes und Buttons). Leider versteh ich gerade nicht warum bei mir die Shapes sich nicht färben. Kann sich das jemand mal ansehen? Danke im vorraus

Code:
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Button10: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Button9: TButton;
    Panel1: TPanel;
    Panel2: TPanel;
    S1: TShape;
    S10: TShape;
    S11: TShape;
    S12: TShape;
    S13: TShape;
    S14: TShape;
    S15: TShape;
    S16: TShape;
    S17: TShape;
    S18: TShape;
    S19: TShape;
    S2: TShape;
    S20: TShape;
    S21: TShape;
    S22: TShape;
    S23: TShape;
    S24: TShape;
    S25: TShape;
    S26: TShape;
    S27: TShape;
    S28: TShape;
    S29: TShape;
    S3: TShape;
    S30: TShape;
    S31: TShape;
    S32: TShape;
    S33: TShape;
    S34: TShape;
    S35: TShape;
    S36: TShape;
    S37: TShape;
    S38: TShape;
    S39: TShape;
    S4: TShape;
    S40: TShape;
    S41: TShape;
    S42: TShape;
    S5: TShape;
    S6: TShape;
    S7: TShape;
    S8: TShape;
    S9: TShape;
    Timer1: TTimer;
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SelectS(col:integer;player:integer);

  private
    { private declarations }
  public
    { public declarations }
    arrayInt: array[1..6,1..7] of integer;
    list:array[1..42] of TShape;

  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button2Click(Sender: TObject);
begin

end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  close;
end;

procedure TForm1.Button4Click(Sender: TObject);
  var i,j,x:integer;
begin
  SelectS(1,1);
  for i:=1 to 6 do
            for j:=1 to 7 do
                if arrayInt[i,j]=1 then
                   list[i*j].Brush.Color:=clred
                else if arrayInt[i,j]=2 then
                   list[i*j].Brush.color:=clblue;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  i,j:integer;
begin
    for i:=1 to 6 do
        for j:=1 to 7 do
            arrayInt[i,j]:=0;
    timer1.enabled:=true;
    timer1.Interval:=10;
    list[1]:=S1;
    list[2]:=S2;
    list[3]:=S3;
    list[4]:=S4;
    list[5]:=S5;
    list[6]:=S6;
    list[7]:=S7;
    list[9]:=S8;
    list[10]:=S9;
    list[11]:=S10;
    list[12]:=S11;
    list[13]:=S12;
    list[14]:=S13;
    list[15]:=S14;
    list[16]:=S15;
    list[17]:=S16;
    list[18]:=S17;
    list[18]:=S18;
    list[19]:=S19;
    list[20]:=S20;
    list[21]:=S21;
    list[22]:=S22;
    list[23]:=S23;
    list[24]:=S24;
    list[25]:=S25;
    list[26]:=S26;
    list[27]:=S27;
    list[28]:=S28;
    list[29]:=S29;
    list[30]:=S30;
    list[31]:=S31;
    list[32]:=S32;
    list[33]:=S33;
    list[34]:=S34;
    list[35]:=S35;
    list[36]:=S36;
    list[37]:=S37;
    list[38]:=S38;
    list[39]:=S39;
    list[40]:=S40;
    list[41]:=S41;
    list[42]:=S42;


end;
procedure TForm1.SelectS(col:integer;player:integer);    //wählt bei buttonclick das shape aus, welches der player färbt.
var
  i,x:integer;
begin
repeat
        i:=1;
   x:=0;
   if arrayInt[i,col] = 0 then
   begin
   arrayInt[1,col]:=player;
   x:=1;
   end;
   i:=i+1;
until x=1
 end;



end.
  Mit Zitat antworten Zitat