<?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[&amp;quot;Spielfeld&amp;quot; aufbauen dauert &amp;quot;ewig&amp;quot; &#x2F; mit vielen Images arbeiten]]></title><description><![CDATA[<p>Ich möchte ein Spielfeld für ein Schachspiel aufbauen, leider dauert das im Moment sehr lange. Ich mache es so:</p>
<pre><code class="language-cpp">for (int i=0; i&lt;N; i++)
      for (int j=0; j&lt;M; j++)
      {
        image_lst[i][j]=new TImage(WorkForm);
        image_lst[i][j]-&gt;Parent=WorkForm; 
        image_lst[i][j]-&gt;Picture-&gt;Bitmap-&gt;LoadFromFile(&quot;blablabla.bmp&quot;);
        image_lst[i][j]-&gt;Height = 32;
        image_lst[i][j]-&gt;Width = 32;
        image_lst[i][j]-&gt;Top = j*32;
        image_lst[i][j]-&gt;Left = i*32;
        image_lst[i][j]-&gt;OnClick = Click;
       }
</code></pre>
<p>Gibt es da eine effizientere Vorgehensweise?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/113272/quot-spielfeld-quot-aufbauen-dauert-quot-ewig-quot-mit-vielen-images-arbeiten</link><generator>RSS for Node</generator><lastBuildDate>Thu, 23 Jul 2026 04:40:51 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/113272.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 21 Jun 2005 11:20:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to &amp;quot;Spielfeld&amp;quot; aufbauen dauert &amp;quot;ewig&amp;quot; &#x2F; mit vielen Images arbeiten on Tue, 21 Jun 2005 11:20:50 GMT]]></title><description><![CDATA[<p>Ich möchte ein Spielfeld für ein Schachspiel aufbauen, leider dauert das im Moment sehr lange. Ich mache es so:</p>
<pre><code class="language-cpp">for (int i=0; i&lt;N; i++)
      for (int j=0; j&lt;M; j++)
      {
        image_lst[i][j]=new TImage(WorkForm);
        image_lst[i][j]-&gt;Parent=WorkForm; 
        image_lst[i][j]-&gt;Picture-&gt;Bitmap-&gt;LoadFromFile(&quot;blablabla.bmp&quot;);
        image_lst[i][j]-&gt;Height = 32;
        image_lst[i][j]-&gt;Width = 32;
        image_lst[i][j]-&gt;Top = j*32;
        image_lst[i][j]-&gt;Left = i*32;
        image_lst[i][j]-&gt;OnClick = Click;
       }
</code></pre>
<p>Gibt es da eine effizientere Vorgehensweise?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/813953</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/813953</guid><dc:creator><![CDATA[Heinricht]]></dc:creator><pubDate>Tue, 21 Jun 2005 11:20:50 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Spielfeld&amp;quot; aufbauen dauert &amp;quot;ewig&amp;quot; &#x2F; mit vielen Images arbeiten on Tue, 21 Jun 2005 13:25:24 GMT]]></title><description><![CDATA[<p>wenn du das spielfeld öfters neu aufbaus könnte es ,abhängig von der größe der bitmaps, was bringen wenn du die bitmaps beim programmstart erst in eine liste lädsts.Auf die einzelen Bitmaps kann man dann über GetBitmap zugreifen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/814082</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/814082</guid><dc:creator><![CDATA[Beliah]]></dc:creator><pubDate>Tue, 21 Jun 2005 13:25:24 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Spielfeld&amp;quot; aufbauen dauert &amp;quot;ewig&amp;quot; &#x2F; mit vielen Images arbeiten on Wed, 22 Jun 2005 06:37:52 GMT]]></title><description><![CDATA[<p>nimm ein einzelnes bild das die komplette spielfläche darstellt!</p>
<p>ausserdem gibt es nur 2 unterschiedliche felder (schwarz, weiss), warum also jedes mal das bild neu laden?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/814517</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/814517</guid><dc:creator><![CDATA[Sunday]]></dc:creator><pubDate>Wed, 22 Jun 2005 06:37:52 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Spielfeld&amp;quot; aufbauen dauert &amp;quot;ewig&amp;quot; &#x2F; mit vielen Images arbeiten on Wed, 22 Jun 2005 06:53:31 GMT]]></title><description><![CDATA[<p>Das Spiefeld als solches würde ich gar nicht als Bitmap(s) auslegen, sondern direkt auf den Canvas zeichnen. Sind doch nur ein paar Rechtecke.<br />
Außerdem hast Du dir anscheinend ein Array aus TImages gebastelt. So etwas gibt es schon fertig. Wirf mal einen Blick auf TImageList (nicht für das Spielfeld, sondern die Figuren).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/814524</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/814524</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 22 Jun 2005 06:53:31 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Spielfeld&amp;quot; aufbauen dauert &amp;quot;ewig&amp;quot; &#x2F; mit vielen Images arbeiten on Wed, 22 Jun 2005 07:15:45 GMT]]></title><description><![CDATA[<p>Wie das als Code funktioniert, weiß ich jetzt nicht, hab auch keinen BCB zur Hand, aber hier mal die Theorie:</p>
<ul>
<li>Spielfeld aus Rechtecken zeichnen (eine Funktion)</li>
<li>Positionen der Spielfiguren ermitteln</li>
<li>Spielfiguren aus TImageList laden und auf das Canvas zeichnen (ohne extra TImages)</li>
</ul>
<p>Ich denke, dass dir dabei die BCB-Hilfe behilflich sein kann, aber die Suche hier dürfte auch etwas dazu ergeben.</p>
<p>Die Funktion zum Rechtecke zeichnen ist recht einfach:</p>
<pre><code class="language-cpp">/*** Variablen ***\
FieldStartLeft  - Position des Spielfeldes von links
FieldStartTop   - Position des Feldes von oben
FieldWidth      - Hoehe und Breite eines Feldes

Diese Variablen muessen im Public-Bereich von &quot;TForm1&quot;
deklariert sein und später definiert werden.
\*** Ende ***/

void __fastcall TForm1::PaintField(int x,int y)
{
    for(int _x=0;_x&lt;x;++_x)
    for(int _y=0;_y&lt;y;++_y)
    {
        Canvas-&gt;Pen-&gt;Color=0xffffff*((_y+(_x&amp;1))&amp;1);
        Canvas-&gt;Brush-&gt;Color=Canvas-&gt;Pen-&gt;Color;
        Canvas-&gt;RectAngle(FieldStartLeft+_x*FieldWidth,
                          FieldStartTop+_y*FieldWidth,
                          FieldStartLeft+(_x+1)*FieldWidth+1,
                          FieldStartTop+(_y+1)*FieldWidth+1);
    }
}
</code></pre>
<p>Und die Theorie zum Aufbau der Spielfiguren: Es gibt folgende Figuren:</p>
<ul>
<li>Bauer</li>
<li>Turm</li>
<li>Pferd</li>
<li>Läufer</li>
<li>Königin</li>
<li>König</li>
</ul>
<p>Das sind 6 Figuren... am Besten du legst Klassen an (falls du das noch nicht getan hast) und dort eine Eigenschaft &quot;ImageIndex&quot; und mit diesem ImageIndex greifst du auf die TImageList zu... aber du musst noch das Team beachten, es gibt 2 Teams... da wir also 6 Spoielfiguren haben, je weiß und schwarz, macht das 12 Bilder, so rechnest du im tatsächlichen Index einfach <strong>ImageIndex + 6 * (Team==&quot;Schwarz&quot;)</strong>... soweit zur Theorie</p>
]]></description><link>https://www.c-plusplus.net/forum/post/814526</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/814526</guid><dc:creator><![CDATA[Windoof]]></dc:creator><pubDate>Wed, 22 Jun 2005 07:15:45 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Spielfeld&amp;quot; aufbauen dauert &amp;quot;ewig&amp;quot; &#x2F; mit vielen Images arbeiten on Fri, 08 Jul 2005 16:28:12 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">//bei den Variablen deklarieren
TPicture *Spielfeld, Bauer_w /*die restlichen der Figuren auch noch*/;

//in der FormCreate-Methode oder vergleichbar:

Spielfeld=new TPicture;//für alle anderen auch
Image1-&gt;Picture=Spielfeld;
//aufstellung:
Image1-&gt;Canvas-&gt;Draw(x,y,Bauer-&gt;Graphic);//ebenfalls für alle anderen Figuren noch machen, halt an die richtige stelle.
</code></pre>
<p>so musst du dich nur noch um die Position(en) kümmern bzw. ob die Figur überhaupt noch im Spiel ist, so wirds schon viel einfacher. und natürlich das &quot;schachbrett&quot; immer wieder neu zeichnen, sonst ist irgendwann das ganze Feld voller Figuren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/826805</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/826805</guid><dc:creator><![CDATA[AI::gamecock]]></dc:creator><pubDate>Fri, 08 Jul 2005 16:28:12 GMT</pubDate></item></channel></rss>