<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Probleme bei einem MemorySpiel]]></title><description><![CDATA[<p>ich habe ein MemorySpiel erstellt, muss aber jetzt noch eine sogenannte Schummelfuntion einbauen. D.h. alle Felder die noch zugedeckt sind (Bildindex 21) müssen über den Timer2 für wenige Sekunden angezeigt werden und danach wieder umgedreht werden. So das an dem Spielfeld selbst nicht geändert wird. Ich habe mir dazu überlegt das ich ein globales Feld benötige das den aktuellen Zustand des Feldes &quot;SpielFeld&quot; zwischenspeichert. Dieses globale SpielFeld nenne ich der einfachheit &quot;SpielFeldCopy&quot;. Die Schummelfunktion soll durch ein klicken auf den Button1 gestartet werden.</p>
<p>Ich hoffe das da jemand durchblickt.<br />
Ich hänge mal den kopletten Code an. Das Formular lege ich erstmal nicht bei.<br />
Ich denke mal an diesesn beiden Funktionen hapert es:</p>
<pre><code>void __fastcall TForm1::Button1Click(TObject *Sender)
{
if (Timer1-&gt;Enabled==0){
        SpielFeldCopy= SpielFeld;
         for (int i =0; i&lt;7; i++)
                for (int j = 0; j&lt;6; j++){
                        if(Aufgedeckt[SpielFeldCopy[i+1][j+1&rsqb;&rsqb;[0]==21){
                        SpielFeldCopy.KarteOeffnen(i,j);
                        }
                }
         }
         Timer2-&gt;Enabled=1;
}
DrawGrid1-&gt;Repaint();

}
</code></pre>
<pre><code>void __fastcall TForm1::Timer2Timer(TObject *Sender)
{
Timer2-Enabled=0;
SpielFeldCopy.SchliesseKarten();

}
</code></pre>
<p>Hier einmal der komplette Code mit Header Dateien:</p>
<p>Hauptformular.cpp:</p>
<pre><code>//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;hauptformular.h&quot;
#include &quot;memoryfeld.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
TForm1 *Form1;

MemoryFeld SpielFeld;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DrawGrid1DrawCell(TObject *Sender, int ACol,
      int ARow, TRect &amp;Rect, TGridDrawState State)
{
ImageList1-&gt;Draw(DrawGrid1-&gt;Canvas,Rect.Left,Rect.Top,SpielFeld.SpielFeld[ACol][ARow]);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DrawGrid1DblClick(TObject *Sender)
{
int x=DrawGrid1-&gt;Col;
int y=DrawGrid1-&gt;Row;
if (SpielFeld.OffeneKarten==0 &amp;&amp; SpielFeld.player==1)
        SpielFeld.player = 0;
if (SpielFeld.OffeneKarten==0 &amp;&amp; SpielFeld.player==0){
        // keine Karte offen
        if (SpielFeld.SpielFeld[x][y]==22)
                SpielFeld.KarteOeffnen(x,y);
}else
if (SpielFeld.OffeneKarten==1 &amp;&amp; SpielFeld.player ==0){
        // 1 Karte bereits offen
        if (SpielFeld.SpielFeld[x][y]==22){
                SpielFeld.KarteOeffnen(x,y);
                Timer1-&gt;Enabled = 1;
        }
}
DrawGrid1-&gt;Repaint();

}
//---------------------------------------------------------------------------

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
Timer1-&gt;Enabled=0;
SpielFeld.SchliesseKarten();
Label3-&gt;Caption=IntToStr(SpielFeld.Paare[0]);
Label4-&gt;Caption=IntToStr(SpielFeld.Paare[1]);
if (SpielFeld.Paare[0] &gt;10)
        Label5-&gt;Caption=&quot;Der Mensch hat gewonnen!&quot;;
if (SpielFeld.Paare[1] &gt;10)
        Label5-&gt;Caption=&quot;Der Computer hat gewonnen!&quot;;
DrawGrid1-&gt;Repaint();

}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
if (Timer1-&gt;Enabled==0){
        SpielFeldCopy= SpielFeld;
         for (int i =0; i&lt;7; i++)
                for (int j = 0; j&lt;6; j++){
                        if(Aufgedeckt[SpielFeldCopy[i+1][j+1&rsqb;&rsqb;[0]==21){
                        SpielFeldCopy.KarteOeffnen(i,j);
                        }
                }
         }
         Timer2-&gt;Enabled=1;
}
DrawGrid1-&gt;Repaint();

}
//---------------------------------------------------------------------------

void __fastcall TForm1::Timer2Timer(TObject *Sender)
{
Timer2-Enabled=0;
SpielFeldCopy.SchliesseKarten();

}
//---------------------------------------------------------------------------
</code></pre>
<p>Hauptformular.h:</p>
<pre><code>//---------------------------------------------------------------------------

#ifndef hauptformularH
#define hauptformularH
//---------------------------------------------------------------------------
#include &lt;Classes.hpp&gt;
#include &lt;Controls.hpp&gt;
#include &lt;StdCtrls.hpp&gt;
#include &lt;Forms.hpp&gt;
#include &lt;Grids.hpp&gt;
#include &lt;ImgList.hpp&gt;
#include &lt;ExtCtrls.hpp&gt;
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// Von der IDE verwaltete Komponenten
        TDrawGrid *DrawGrid1;
        TImageList *ImageList1;
        TTimer *Timer1;
        TLabel *Label1;
        TLabel *Label2;
        TLabel *Label3;
        TLabel *Label4;
        TLabel *Label5;
        TTimer *Timer2;
        TButton *Button1;
        void __fastcall DrawGrid1DrawCell(TObject *Sender, int ACol,
          int ARow, TRect &amp;Rect, TGridDrawState State);
        void __fastcall DrawGrid1DblClick(TObject *Sender);
        void __fastcall Timer1Timer(TObject *Sender);
        void __fastcall Button1Click(TObject *Sender);
        void __fastcall Timer2Timer(TObject *Sender);
private:	// Anwender-Deklarationen
public:		// Anwender-Deklarationen
        __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
</code></pre>
<p>memory.cpp:</p>
<pre><code>//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#pragma hdrstop
//---------------------------------------------------------------------------
USEFORM(&quot;hauptformular.cpp&quot;, Form1);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
        try
        {
                 Application-&gt;Initialize();
                 Application-&gt;CreateForm(__classid(TForm1), &amp;Form1);
                 Application-&gt;Run();
        }
        catch (Exception &amp;exception)
        {
                 Application-&gt;ShowException(&amp;exception);
        }
        catch (...)
        {
                 try
                 {
                         throw Exception(&quot;&quot;);
                 }
                 catch (Exception &amp;exception)
                 {
                         Application-&gt;ShowException(&amp;exception);
                 }
        }
        return 0;
}
//--------------------------------------------
</code></pre>
<p>memoryfeld.h:</p>
<pre><code>//---------------------------------------------------------------------------

#ifndef memoryfeldH
#define memoryfeldH
struct pos {int x; int y;};

class MemoryFeld{
        public:
        MemoryFeld();
        void KarteOeffnen(int x, int y);
        void SchliesseKarten();
        void ComputerZug();
        int OffeneKarten;
        int player;
        pos OffeneKartenPos[2];
        int Paare[2];
        // das Feld fuer die Indizes der Bilder
        int InitFeld[7][6];
        // das Spielfeld
        int SpielFeld[7][6];
        // Bilder, die bereits aufgedeckt wurden
        pos Aufgedeckt[21][2];
};
//---------------------------------------------------------------------------
#endif
</code></pre>
<p>memoryfeld.cpp:</p>
<pre><code>//---------------------------------------------------------------------------

#pragma hdrstop

#include &quot;memoryfeld.h&quot;
#include &quot;hauptformular.h&quot;
#include &lt;algorithm.h&gt;

MemoryFeld::MemoryFeld(){
        int bild=0;
        int Feld[42];
        OffeneKarten=0;
        player = 0;
        Paare[0]=0;
        Paare[1]=0;
        // Initialisiere Aufgedeckt mit -1
        for (int i=0; i&lt;21;i++)
                for (int j=0; j&lt;2; j++){
                        Aufgedeckt[i][j].x=-1;
                        Aufgedeckt[i][j].y=-1;
                }
        //Belegen von Feld
        for (int i=0; i&lt;42; i++){
                Feld[i]= bild;
                if(((i+1) % 2 == 0)) bild++;
        }
        // Mischen von Feld
        randomize();
        random_shuffle(Feld,Feld+42);
        // Kopieren aus Feld in InitFeld
        for (int i =0; i&lt;7; i++)
                for (int j = 0; j&lt;6; j++){
                        InitFeld[i][j]=Feld[j*7+i];
                        SpielFeld[i][j]=22;
                }
}
void MemoryFeld::KarteOeffnen(int x, int y){
        int a=0;
        SpielFeld[x][y]=InitFeld[x][y];
        OffeneKartenPos[OffeneKarten].x=x;
        OffeneKartenPos[OffeneKarten].y=y;
        if (Aufgedeckt[SpielFeld[x][y&rsqb;&rsqb;[0].x!=-1 &amp;&amp; !(Aufgedeckt[SpielFeld[x][y&rsqb;&rsqb;[0].x==x &amp;&amp; Aufgedeckt[SpielFeld[x][y&rsqb;&rsqb;[0].y==y))
                a=1;
        Aufgedeckt[SpielFeld[x][y&rsqb;&rsqb;[a].x=x;
        Aufgedeckt[SpielFeld[x][y&rsqb;&rsqb;[a].y=y;
        OffeneKarten++;
}
void MemoryFeld::SchliesseKarten(){
        bool treffer=0;
        if (InitFeld[OffeneKartenPos[0].x][OffeneKartenPos[0].y]==InitFeld[OffeneKartenPos[1].x][OffeneKartenPos[1].y]){
                SpielFeld[OffeneKartenPos[0].x][OffeneKartenPos[0].y]=21;
                SpielFeld[OffeneKartenPos[1].x][OffeneKartenPos[1].y]=21;
                for (int i=0; i&lt;2;i++){
                        Aufgedeckt[InitFeld[OffeneKartenPos[i].x][OffeneKartenPos[i].y&rsqb;&rsqb;[i].x=-1;
                }
                Paare[player]++;
                treffer=1;
        }else{
                SpielFeld[OffeneKartenPos[0].x][OffeneKartenPos[0].y]=22;
                SpielFeld[OffeneKartenPos[1].x][OffeneKartenPos[1].y]=22;
        }
        OffeneKarten=0;
        if ((Paare[0]+Paare[1])!=21){
                if((player==0 &amp;&amp; treffer==0) || (player==1 &amp;&amp; treffer==1)){
                        player =1;
                        ComputerZug();
                }
        }
}
void MemoryFeld::ComputerZug(){
        int x1,y1,x2,y2, found=0;
        randomize();
        for (int i=0; i&lt;21;i++){
                if (Aufgedeckt[i][0].x!=-1 &amp;&amp; Aufgedeckt[i][1].x!=-1){
                        x1=Aufgedeckt[i][0].x;
                        y1=Aufgedeckt[i][0].y;
                        x2=Aufgedeckt[i][1].x;
                        y2=Aufgedeckt[i][1].y;
                        found=1;
                }
        }
        found=(found &amp;&amp; random(3));
        if (found==1)
                KarteOeffnen(x2,y2);
        else{
                do{
                        x1=random(7);
                        y1=random(6);
                }while (SpielFeld[x1][y1]!=22);
                if (Aufgedeckt[InitFeld[x1][y1&rsqb;&rsqb;[0].x!=-1 &amp;&amp; !(Aufgedeckt[InitFeld[x1][y1&rsqb;&rsqb;[0].x==x1 &amp;&amp; Aufgedeckt[InitFeld[x1][y1&rsqb;&rsqb;[0].y==y1)){
                        KarteOeffnen(Aufgedeckt[InitFeld[x1][y1&rsqb;&rsqb;[0].x,Aufgedeckt[InitFeld[x1][y1&rsqb;&rsqb;[0].y);
                }else{
                        do{
                                x2=random(7);
                                y2=random(6);
                        } while (SpielFeld[x2][y2]!=22 || (x1==x2 &amp;&amp; y1==y2));
                        KarteOeffnen(x2,y2);
                }
        }
        KarteOeffnen(x1,y1);
        Form1-&gt;DrawGrid1-&gt;Repaint();
        Form1-&gt;Timer1-&gt;Enabled=1;

}

//---------------------------------------------------------------------------

#pragma package(smart_init)
</code></pre>
<p>Ich hoffe das mir jemand helfen kann.</p>
<p>MFG</p>
<p>Angelus</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/102048/probleme-bei-einem-memoryspiel</link><generator>RSS for Node</generator><lastBuildDate>Tue, 14 Jul 2026 07:27:14 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/102048.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 22 Feb 2005 10:11:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Probleme bei einem MemorySpiel on Tue, 22 Feb 2005 10:11:39 GMT]]></title><description><![CDATA[<p>ich habe ein MemorySpiel erstellt, muss aber jetzt noch eine sogenannte Schummelfuntion einbauen. D.h. alle Felder die noch zugedeckt sind (Bildindex 21) müssen über den Timer2 für wenige Sekunden angezeigt werden und danach wieder umgedreht werden. So das an dem Spielfeld selbst nicht geändert wird. Ich habe mir dazu überlegt das ich ein globales Feld benötige das den aktuellen Zustand des Feldes &quot;SpielFeld&quot; zwischenspeichert. Dieses globale SpielFeld nenne ich der einfachheit &quot;SpielFeldCopy&quot;. Die Schummelfunktion soll durch ein klicken auf den Button1 gestartet werden.</p>
<p>Ich hoffe das da jemand durchblickt.<br />
Ich hänge mal den kopletten Code an. Das Formular lege ich erstmal nicht bei.<br />
Ich denke mal an diesesn beiden Funktionen hapert es:</p>
<pre><code>void __fastcall TForm1::Button1Click(TObject *Sender)
{
if (Timer1-&gt;Enabled==0){
        SpielFeldCopy= SpielFeld;
         for (int i =0; i&lt;7; i++)
                for (int j = 0; j&lt;6; j++){
                        if(Aufgedeckt[SpielFeldCopy[i+1][j+1&rsqb;&rsqb;[0]==21){
                        SpielFeldCopy.KarteOeffnen(i,j);
                        }
                }
         }
         Timer2-&gt;Enabled=1;
}
DrawGrid1-&gt;Repaint();

}
</code></pre>
<pre><code>void __fastcall TForm1::Timer2Timer(TObject *Sender)
{
Timer2-Enabled=0;
SpielFeldCopy.SchliesseKarten();

}
</code></pre>
<p>Hier einmal der komplette Code mit Header Dateien:</p>
<p>Hauptformular.cpp:</p>
<pre><code>//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;hauptformular.h&quot;
#include &quot;memoryfeld.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
TForm1 *Form1;

MemoryFeld SpielFeld;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DrawGrid1DrawCell(TObject *Sender, int ACol,
      int ARow, TRect &amp;Rect, TGridDrawState State)
{
ImageList1-&gt;Draw(DrawGrid1-&gt;Canvas,Rect.Left,Rect.Top,SpielFeld.SpielFeld[ACol][ARow]);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DrawGrid1DblClick(TObject *Sender)
{
int x=DrawGrid1-&gt;Col;
int y=DrawGrid1-&gt;Row;
if (SpielFeld.OffeneKarten==0 &amp;&amp; SpielFeld.player==1)
        SpielFeld.player = 0;
if (SpielFeld.OffeneKarten==0 &amp;&amp; SpielFeld.player==0){
        // keine Karte offen
        if (SpielFeld.SpielFeld[x][y]==22)
                SpielFeld.KarteOeffnen(x,y);
}else
if (SpielFeld.OffeneKarten==1 &amp;&amp; SpielFeld.player ==0){
        // 1 Karte bereits offen
        if (SpielFeld.SpielFeld[x][y]==22){
                SpielFeld.KarteOeffnen(x,y);
                Timer1-&gt;Enabled = 1;
        }
}
DrawGrid1-&gt;Repaint();

}
//---------------------------------------------------------------------------

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
Timer1-&gt;Enabled=0;
SpielFeld.SchliesseKarten();
Label3-&gt;Caption=IntToStr(SpielFeld.Paare[0]);
Label4-&gt;Caption=IntToStr(SpielFeld.Paare[1]);
if (SpielFeld.Paare[0] &gt;10)
        Label5-&gt;Caption=&quot;Der Mensch hat gewonnen!&quot;;
if (SpielFeld.Paare[1] &gt;10)
        Label5-&gt;Caption=&quot;Der Computer hat gewonnen!&quot;;
DrawGrid1-&gt;Repaint();

}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
if (Timer1-&gt;Enabled==0){
        SpielFeldCopy= SpielFeld;
         for (int i =0; i&lt;7; i++)
                for (int j = 0; j&lt;6; j++){
                        if(Aufgedeckt[SpielFeldCopy[i+1][j+1&rsqb;&rsqb;[0]==21){
                        SpielFeldCopy.KarteOeffnen(i,j);
                        }
                }
         }
         Timer2-&gt;Enabled=1;
}
DrawGrid1-&gt;Repaint();

}
//---------------------------------------------------------------------------

void __fastcall TForm1::Timer2Timer(TObject *Sender)
{
Timer2-Enabled=0;
SpielFeldCopy.SchliesseKarten();

}
//---------------------------------------------------------------------------
</code></pre>
<p>Hauptformular.h:</p>
<pre><code>//---------------------------------------------------------------------------

#ifndef hauptformularH
#define hauptformularH
//---------------------------------------------------------------------------
#include &lt;Classes.hpp&gt;
#include &lt;Controls.hpp&gt;
#include &lt;StdCtrls.hpp&gt;
#include &lt;Forms.hpp&gt;
#include &lt;Grids.hpp&gt;
#include &lt;ImgList.hpp&gt;
#include &lt;ExtCtrls.hpp&gt;
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// Von der IDE verwaltete Komponenten
        TDrawGrid *DrawGrid1;
        TImageList *ImageList1;
        TTimer *Timer1;
        TLabel *Label1;
        TLabel *Label2;
        TLabel *Label3;
        TLabel *Label4;
        TLabel *Label5;
        TTimer *Timer2;
        TButton *Button1;
        void __fastcall DrawGrid1DrawCell(TObject *Sender, int ACol,
          int ARow, TRect &amp;Rect, TGridDrawState State);
        void __fastcall DrawGrid1DblClick(TObject *Sender);
        void __fastcall Timer1Timer(TObject *Sender);
        void __fastcall Button1Click(TObject *Sender);
        void __fastcall Timer2Timer(TObject *Sender);
private:	// Anwender-Deklarationen
public:		// Anwender-Deklarationen
        __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
</code></pre>
<p>memory.cpp:</p>
<pre><code>//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#pragma hdrstop
//---------------------------------------------------------------------------
USEFORM(&quot;hauptformular.cpp&quot;, Form1);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
        try
        {
                 Application-&gt;Initialize();
                 Application-&gt;CreateForm(__classid(TForm1), &amp;Form1);
                 Application-&gt;Run();
        }
        catch (Exception &amp;exception)
        {
                 Application-&gt;ShowException(&amp;exception);
        }
        catch (...)
        {
                 try
                 {
                         throw Exception(&quot;&quot;);
                 }
                 catch (Exception &amp;exception)
                 {
                         Application-&gt;ShowException(&amp;exception);
                 }
        }
        return 0;
}
//--------------------------------------------
</code></pre>
<p>memoryfeld.h:</p>
<pre><code>//---------------------------------------------------------------------------

#ifndef memoryfeldH
#define memoryfeldH
struct pos {int x; int y;};

class MemoryFeld{
        public:
        MemoryFeld();
        void KarteOeffnen(int x, int y);
        void SchliesseKarten();
        void ComputerZug();
        int OffeneKarten;
        int player;
        pos OffeneKartenPos[2];
        int Paare[2];
        // das Feld fuer die Indizes der Bilder
        int InitFeld[7][6];
        // das Spielfeld
        int SpielFeld[7][6];
        // Bilder, die bereits aufgedeckt wurden
        pos Aufgedeckt[21][2];
};
//---------------------------------------------------------------------------
#endif
</code></pre>
<p>memoryfeld.cpp:</p>
<pre><code>//---------------------------------------------------------------------------

#pragma hdrstop

#include &quot;memoryfeld.h&quot;
#include &quot;hauptformular.h&quot;
#include &lt;algorithm.h&gt;

MemoryFeld::MemoryFeld(){
        int bild=0;
        int Feld[42];
        OffeneKarten=0;
        player = 0;
        Paare[0]=0;
        Paare[1]=0;
        // Initialisiere Aufgedeckt mit -1
        for (int i=0; i&lt;21;i++)
                for (int j=0; j&lt;2; j++){
                        Aufgedeckt[i][j].x=-1;
                        Aufgedeckt[i][j].y=-1;
                }
        //Belegen von Feld
        for (int i=0; i&lt;42; i++){
                Feld[i]= bild;
                if(((i+1) % 2 == 0)) bild++;
        }
        // Mischen von Feld
        randomize();
        random_shuffle(Feld,Feld+42);
        // Kopieren aus Feld in InitFeld
        for (int i =0; i&lt;7; i++)
                for (int j = 0; j&lt;6; j++){
                        InitFeld[i][j]=Feld[j*7+i];
                        SpielFeld[i][j]=22;
                }
}
void MemoryFeld::KarteOeffnen(int x, int y){
        int a=0;
        SpielFeld[x][y]=InitFeld[x][y];
        OffeneKartenPos[OffeneKarten].x=x;
        OffeneKartenPos[OffeneKarten].y=y;
        if (Aufgedeckt[SpielFeld[x][y&rsqb;&rsqb;[0].x!=-1 &amp;&amp; !(Aufgedeckt[SpielFeld[x][y&rsqb;&rsqb;[0].x==x &amp;&amp; Aufgedeckt[SpielFeld[x][y&rsqb;&rsqb;[0].y==y))
                a=1;
        Aufgedeckt[SpielFeld[x][y&rsqb;&rsqb;[a].x=x;
        Aufgedeckt[SpielFeld[x][y&rsqb;&rsqb;[a].y=y;
        OffeneKarten++;
}
void MemoryFeld::SchliesseKarten(){
        bool treffer=0;
        if (InitFeld[OffeneKartenPos[0].x][OffeneKartenPos[0].y]==InitFeld[OffeneKartenPos[1].x][OffeneKartenPos[1].y]){
                SpielFeld[OffeneKartenPos[0].x][OffeneKartenPos[0].y]=21;
                SpielFeld[OffeneKartenPos[1].x][OffeneKartenPos[1].y]=21;
                for (int i=0; i&lt;2;i++){
                        Aufgedeckt[InitFeld[OffeneKartenPos[i].x][OffeneKartenPos[i].y&rsqb;&rsqb;[i].x=-1;
                }
                Paare[player]++;
                treffer=1;
        }else{
                SpielFeld[OffeneKartenPos[0].x][OffeneKartenPos[0].y]=22;
                SpielFeld[OffeneKartenPos[1].x][OffeneKartenPos[1].y]=22;
        }
        OffeneKarten=0;
        if ((Paare[0]+Paare[1])!=21){
                if((player==0 &amp;&amp; treffer==0) || (player==1 &amp;&amp; treffer==1)){
                        player =1;
                        ComputerZug();
                }
        }
}
void MemoryFeld::ComputerZug(){
        int x1,y1,x2,y2, found=0;
        randomize();
        for (int i=0; i&lt;21;i++){
                if (Aufgedeckt[i][0].x!=-1 &amp;&amp; Aufgedeckt[i][1].x!=-1){
                        x1=Aufgedeckt[i][0].x;
                        y1=Aufgedeckt[i][0].y;
                        x2=Aufgedeckt[i][1].x;
                        y2=Aufgedeckt[i][1].y;
                        found=1;
                }
        }
        found=(found &amp;&amp; random(3));
        if (found==1)
                KarteOeffnen(x2,y2);
        else{
                do{
                        x1=random(7);
                        y1=random(6);
                }while (SpielFeld[x1][y1]!=22);
                if (Aufgedeckt[InitFeld[x1][y1&rsqb;&rsqb;[0].x!=-1 &amp;&amp; !(Aufgedeckt[InitFeld[x1][y1&rsqb;&rsqb;[0].x==x1 &amp;&amp; Aufgedeckt[InitFeld[x1][y1&rsqb;&rsqb;[0].y==y1)){
                        KarteOeffnen(Aufgedeckt[InitFeld[x1][y1&rsqb;&rsqb;[0].x,Aufgedeckt[InitFeld[x1][y1&rsqb;&rsqb;[0].y);
                }else{
                        do{
                                x2=random(7);
                                y2=random(6);
                        } while (SpielFeld[x2][y2]!=22 || (x1==x2 &amp;&amp; y1==y2));
                        KarteOeffnen(x2,y2);
                }
        }
        KarteOeffnen(x1,y1);
        Form1-&gt;DrawGrid1-&gt;Repaint();
        Form1-&gt;Timer1-&gt;Enabled=1;

}

//---------------------------------------------------------------------------

#pragma package(smart_init)
</code></pre>
<p>Ich hoffe das mir jemand helfen kann.</p>
<p>MFG</p>
<p>Angelus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/729388</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/729388</guid><dc:creator><![CDATA[Mr.Blond]]></dc:creator><pubDate>Tue, 22 Feb 2005 10:11:39 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme bei einem MemorySpiel on Tue, 22 Feb 2005 13:42:55 GMT]]></title><description><![CDATA[<p>Und dein Problem ist jetzt was?</p>
<p>btw:<br />
Bitte sprachspezifische Tags benutzen, hier wären zB C/C++ Tags sinnvoller.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/729612</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/729612</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Tue, 22 Feb 2005 13:42:55 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme bei einem MemorySpiel on Tue, 22 Feb 2005 21:13:08 GMT]]></title><description><![CDATA[<p>Ich möchte wenn ich den Button1 drücke erreichen das alle noch verdeckten Karten einmal über eine Timerfunktion &quot;Timer2&quot; aufgedeckt und dann wieder zugedeckt werden. Quasi eine Schummelfunktion. Das Spielfeld oder das Spiel selbst darf daduch aber nicht verändert werden. Ist kompliziert ...cih weiss. Hoffe trotzdem auf rege Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/730097</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/730097</guid><dc:creator><![CDATA[Mr.Blond]]></dc:creator><pubDate>Tue, 22 Feb 2005 21:13:08 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme bei einem MemorySpiel on Tue, 22 Feb 2005 22:19:38 GMT]]></title><description><![CDATA[<p>ich bezweifel, dass sich da jemand findet, der sich in deinen code reinarbeitet, nur um dir ne aufdeckfunktion zu schreiben.. Versuchs doch einfach selber oO</p>
]]></description><link>https://www.c-plusplus.net/forum/post/730140</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/730140</guid><dc:creator><![CDATA[life]]></dc:creator><pubDate>Tue, 22 Feb 2005 22:19:38 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme bei einem MemorySpiel on Wed, 23 Feb 2005 10:41:14 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile.php?mode=viewprofile&amp;u=403" rel="nofollow">HumeSikkins</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=15" rel="nofollow">C++</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=2" rel="nofollow">Borland C++ Builder (VCL/CLX)</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/730388</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/730388</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Wed, 23 Feb 2005 10:41:14 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme bei einem MemorySpiel on Wed, 23 Feb 2005 12:47:17 GMT]]></title><description><![CDATA[<p>Dein Ansatz mit dem Kopieren ist doch nicht schlecht. Woran hapert es denn direkt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/730478</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/730478</guid><dc:creator><![CDATA[Dasd]]></dc:creator><pubDate>Wed, 23 Feb 2005 12:47:17 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme bei einem MemorySpiel on Wed, 23 Feb 2005 15:20:59 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/8409">@Mr.Blond</a>: Sieht mir verflixt nach einer Aufgabe aus 'Heft 10' aus. Wenn du meinen kompletten Code als Anregung - aber auch wirklich nur als Anregung !!! - haben möchtest, mail mich an...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/730653</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/730653</guid><dc:creator><![CDATA[Rainbow99]]></dc:creator><pubDate>Wed, 23 Feb 2005 15:20:59 GMT</pubDate></item></channel></rss>