<?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[Snake in Konsole wächst nicht]]></title><description><![CDATA[<p>Hallo<br />
Ich habe versucht ein snake spiel in der Konsole zu programmieren. Ich bekomm es auch soweit hin, nur ich weiß nicht wie ich die Schlange wenn sie eine Frucht gegessen hat zum wachsen bringen kann!<br />
Ich habe die Schlange und das Feld in einem Vector gespeichert!</p>
<pre><code>int main()
{

SetConsoleTitle(&quot;Snake&quot;);

vector &lt;char&gt; feld (800);
vector &lt;char&gt; snake (10);
int x = 0;
int merke = 0;
int i = 0; // position des Kopfes
char c;
int obst; 
int score = -1;
int life = 3;
int anzahl = 1;//anzahl wieviele teile der körper hat

... //bestimmt zufallszahl wo das obst ist und bewegt den kopf der schlange i;

 if (feld[i] == feld [obst]) 
 {
    if (snake[anzahl] &lt; snake.size())
    {
        if( c == 'd')// soll eigentlich (von welcher seite man kommt) die      nächsten teile der schlange ausgeben
        { 
        snake[anzahl] = feld[obst] + 1;
        }
        if( c== 'w')
        {
        snake[anzahl] = feld[obst] - 40;
        }
        if( c == 'a')
        {
        snake[anzahl] = feld[obst] - 1;
        }
        if ( c== 's')
        {
        snake[anzahl]= feld[obst] + 40;
        }
        feld[anzahl] = snake[anzahl];
        anzahl++;
     }
   srand(GetTickCount());
   obst = rand()%800; // wählt neue zuffalszahl für Obst
   ++score;
 }

... // gibt noch spielfeld und schlange aus
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/313358/snake-in-konsole-wächst-nicht</link><generator>RSS for Node</generator><lastBuildDate>Sat, 01 Aug 2026 09:48:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/313358.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 28 Jan 2013 17:50:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Mon, 28 Jan 2013 17:50:02 GMT]]></title><description><![CDATA[<p>Hallo<br />
Ich habe versucht ein snake spiel in der Konsole zu programmieren. Ich bekomm es auch soweit hin, nur ich weiß nicht wie ich die Schlange wenn sie eine Frucht gegessen hat zum wachsen bringen kann!<br />
Ich habe die Schlange und das Feld in einem Vector gespeichert!</p>
<pre><code>int main()
{

SetConsoleTitle(&quot;Snake&quot;);

vector &lt;char&gt; feld (800);
vector &lt;char&gt; snake (10);
int x = 0;
int merke = 0;
int i = 0; // position des Kopfes
char c;
int obst; 
int score = -1;
int life = 3;
int anzahl = 1;//anzahl wieviele teile der körper hat

... //bestimmt zufallszahl wo das obst ist und bewegt den kopf der schlange i;

 if (feld[i] == feld [obst]) 
 {
    if (snake[anzahl] &lt; snake.size())
    {
        if( c == 'd')// soll eigentlich (von welcher seite man kommt) die      nächsten teile der schlange ausgeben
        { 
        snake[anzahl] = feld[obst] + 1;
        }
        if( c== 'w')
        {
        snake[anzahl] = feld[obst] - 40;
        }
        if( c == 'a')
        {
        snake[anzahl] = feld[obst] - 1;
        }
        if ( c== 's')
        {
        snake[anzahl]= feld[obst] + 40;
        }
        feld[anzahl] = snake[anzahl];
        anzahl++;
     }
   srand(GetTickCount());
   obst = rand()%800; // wählt neue zuffalszahl für Obst
   ++score;
 }

... // gibt noch spielfeld und schlange aus
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2294215</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2294215</guid><dc:creator><![CDATA[lolipoplol]]></dc:creator><pubDate>Mon, 28 Jan 2013 17:50:02 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Mon, 28 Jan 2013 18:06:33 GMT]]></title><description><![CDATA[<p>Schaue dir mal Klassen und ggf. eine grafische Library an (z.B. SFML 2.0, gut und einfach) und komme dann wieder. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2294218</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2294218</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Mon, 28 Jan 2013 18:06:33 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Thu, 12 Jun 2014 10:18:32 GMT]]></title><description><![CDATA[<p>...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2294227</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2294227</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Thu, 12 Jun 2014 10:18:32 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Mon, 28 Jan 2013 18:17:47 GMT]]></title><description><![CDATA[<p>Und genau das meinte ich mit Klassen... :p</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2294231</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2294231</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Mon, 28 Jan 2013 18:17:47 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Mon, 28 Jan 2013 19:46:09 GMT]]></title><description><![CDATA[<p>Swordfish schrieb:</p>
<blockquote>
<pre><code class="language-cpp">class texception_t {
 
    private:
        std::shared_ptr&lt; tchar_t &gt; message;
 
    public:
        texception_t::texception_t( tchar_t const * const what )
        :   message( new tchar_t[ ( _tcsclen( what ) + 1 ) * sizeof( tchar_t ) ] )
        {
            _tcscpy( message.get(), what );
        }
 
        tchar_t const * what() { return message.get(); }
};
</code></pre>
</blockquote>
<p>Spätestens wenn der <code>shared_ptr</code> zerstört wird, ist das undefiniertes Verhalten.<br />
Da wird zu viel Speicher angefordert.</p>
<pre><code class="language-cpp">void * message_buffer = nullptr;
...
        tstring_t error_message( reinterpret_cast&lt; tchar_t* &gt;( message_buffer ) );
</code></pre>
<p><code>static_cast</code> würde reichen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2294281</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2294281</guid><dc:creator><![CDATA[TyRoXx]]></dc:creator><pubDate>Mon, 28 Jan 2013 19:46:09 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Sun, 24 Feb 2013 17:26:13 GMT]]></title><description><![CDATA[<p>ich hab mir jezt klassen gelernt aber ich weiß immer noch nicht so richtig wie ich die Schlange mit Klassen zum wachsen bringe <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301702</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301702</guid><dc:creator><![CDATA[lolipoplol]]></dc:creator><pubDate>Sun, 24 Feb 2013 17:26:13 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Sun, 24 Feb 2013 17:57:05 GMT]]></title><description><![CDATA[<p>So jetzt lernst du die Grundlagen eines Spiels mit SFML 2.0.<br />
Grafisch ist das nämlich wesentlich einfacher.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301705</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301705</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Sun, 24 Feb 2013 17:57:05 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Sun, 24 Feb 2013 18:03:11 GMT]]></title><description><![CDATA[<p>wollt eig erstmal nur in der Konsole...<br />
aber ich bekomms iwi trotzdem nicht hin, dass die Schlange wächst</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301708</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301708</guid><dc:creator><![CDATA[lolipoplol]]></dc:creator><pubDate>Sun, 24 Feb 2013 18:03:11 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Sun, 24 Feb 2013 19:06:35 GMT]]></title><description><![CDATA[<p>lolipoplol schrieb:</p>
<blockquote>
<p>wollt eig erstmal nur in der Konsole...<br />
aber ich bekomms iwi trotzdem nicht hin, dass die Schlange wächst</p>
</blockquote>
<p>muttu füttern <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f4a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--light_bulb"
      title=":bulb:"
      alt="💡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301723</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301723</guid><dc:creator><![CDATA[schlau++]]></dc:creator><pubDate>Sun, 24 Feb 2013 19:06:35 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Sun, 24 Feb 2013 20:31:20 GMT]]></title><description><![CDATA[<p>Mache erst einmal eine Klasse, die ein zweidimensionales char-Array als Map verwaltet.<br />
Eine Funktion update() fügt an zufälliger Stelle Obst hinzu, draw() zeichnet das Array auf der Konsole.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301739</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301739</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Sun, 24 Feb 2013 20:31:20 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Mon, 25 Feb 2013 18:13:05 GMT]]></title><description><![CDATA[<p>ok hab ich soweit gemacht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /> hab aber das feld immer noch in eine vector da ich es besser finde <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301958</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301958</guid><dc:creator><![CDATA[lolipoplol]]></dc:creator><pubDate>Mon, 25 Feb 2013 18:13:05 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Mon, 25 Feb 2013 18:39:36 GMT]]></title><description><![CDATA[<p>Wunderbar!<br />
Das ist auch die bessere Wahl.<br />
Als nächstes machst du die Schlange.<br />
Die hat wiederum einen vector als Speicher. Der speichert den Index für jedes Element der Schlange. Die Zeichen-Funktion setzt in der Map die Zeichen an jedem gespeicherten Index durch das Schlangenzeichen.<br />
Die update-Funktion kümmert sich um die Benutzereingabe und bewegt die Schlange entsprechend. Anschließend kümmert sich eine Kollsionsabfrage darum, dass wenn das Feld in der Map, auf dem der Kopf nun ist, Obst war, dass hinten im Vector ein Feld hinzugefügt wird.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301965</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301965</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Mon, 25 Feb 2013 18:39:36 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Tue, 26 Feb 2013 15:48:35 GMT]]></title><description><![CDATA[<p>ist es besser wenn ich die funktionen draw() und update() auch in die klasse mach? Hab da im moment nämlich nur den Vektor drin ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2302198</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2302198</guid><dc:creator><![CDATA[lolipoplol]]></dc:creator><pubDate>Tue, 26 Feb 2013 15:48:35 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Tue, 26 Feb 2013 15:50:17 GMT]]></title><description><![CDATA[<p>Ja klar in der Klasse, Memberfunktion.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2302199</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2302199</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Tue, 26 Feb 2013 15:50:17 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Tue, 26 Feb 2013 16:30:11 GMT]]></title><description><![CDATA[<p>jetz gibt das immer ein Fehler aus...<br />
Hab nochmal komplett neu angefangen mit dem code um die funktionen in die klasse zu tun. Nun weiß ich aber nicht, wo der Fehler liegt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<pre><code>class cfeld{

  public:
  void draw(vector&lt;char&gt;); // fkt die feld ausgibt
  void update (); //fügt obst hinzu
  static vector&lt;char&gt; feld;

 // private:
    static int merke;

};

vector&lt;char&gt; cfeld::feld (800);
int cfeld::merke = 0;

void draw (vector&lt;char&gt; feld)
{
    for(int x = 0; x &lt; 800; x++)// gibt spielfeld aus (40 * in einer reihe dann endl)
    {
     feld.at(x) = '*';
     cout &lt;&lt; feld[x];
     cfeld::merke++;

        if (cfeld::merke == 40)// gibt wenn die for schleife 40 mal durchgelaufen ist eine endl aus
        {
        cout&lt;&lt; endl;
        cfeld::merke = 0;
        }
    }
}

int main()
{
  cfeld feld;

  feld.draw(cfeld::feld);

    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2302210</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2302210</guid><dc:creator><![CDATA[lolipoplol]]></dc:creator><pubDate>Tue, 26 Feb 2013 16:30:11 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Wed, 27 Feb 2013 17:06:36 GMT]]></title><description><![CDATA[<pre><code>class map
{
    std::vector&lt;char&gt; data_;
    std::size_t width_, height_;

public:
    map(std::size_t width, std::size_t height)
    : data_(width * height, '*'), width_(width), height_(height) {}

    void update();
    void draw(std::ostream &amp;os = std::cout);
};

void map::draw(std::ostream &amp;os)
{
    for (std::size_t y = 0; y &lt; height_; ++y)
    {
        for (std::size_t x = 0; x &lt; width_; ++x)
            os &lt;&lt; data_[y * width_ + x];
        os &lt;&lt; '\n';
    }
}
</code></pre>
<p>?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2302214</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2302214</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Wed, 27 Feb 2013 17:06:36 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Tue, 26 Feb 2013 16:57:16 GMT]]></title><description><![CDATA[<p>das gibt bei mir nach dem linken auch den Fehler aus:<br />
undefined reference to...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2302220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2302220</guid><dc:creator><![CDATA[lolipoplol]]></dc:creator><pubDate>Tue, 26 Feb 2013 16:57:16 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Tue, 26 Feb 2013 17:04:24 GMT]]></title><description><![CDATA[<p>update</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2302222</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2302222</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Tue, 26 Feb 2013 17:04:24 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Tue, 26 Feb 2013 20:08:25 GMT]]></title><description><![CDATA[<p>Danke <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /> bin fast fertig <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> jetz häng ich wieder daran, die Schlange wachsen zu lassen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /> hab die Schlange und das Feld ja in einen Vector gespeichert aber jetz weiß ich wieder nicht, wie ich das Verknüpfen soll...</p>
<pre><code>class cfeld{

  ...

  public:
  void draw(vector&lt;char&gt;, vector&lt;int&gt;); // fkt die feld ausgibt
  void update (int&amp;); 
  static vector&lt;char&gt; feld;
  static int obst;
  static vector&lt;int&gt; snake;
};

...
</code></pre>
<p>jetzt weiß ich nicht, wie ich, wenn die Schlange wächst, das auf der konsole ausgeben soll und wie ich das mache, dass wenn man die Schlange steuert die hinteren Teile nicht von dem Kopf getrennt werden. hab im moment einfach nur den kopf zum starten</p>
<pre><code>feld.at(cfeld::snake[0]) = 'O';
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2302292</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2302292</guid><dc:creator><![CDATA[lolipoplol]]></dc:creator><pubDate>Tue, 26 Feb 2013 20:08:25 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Wed, 27 Feb 2013 14:50:26 GMT]]></title><description><![CDATA[<p>Danke <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /> muss nur noch ne kollisionsabfrage machen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> hab die bewegung der schlange aber ein bisschen umständlich gemacht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<pre><code>if(kbhit()) // Nur wenn auch eine Taste gedrückt ist
    {
        c = getch();
        switch(c)
        {
        case 'w':
         cfeld::snake[9] = cfeld::snake[8];
         cfeld::snake[8] = cfeld::snake[7];
         cfeld::snake[7] = cfeld::snake[6];
         cfeld::snake[6] = cfeld::snake[5];
         cfeld::snake[5] = cfeld::snake[4];
         cfeld::snake[4] = cfeld::snake[3];
         cfeld::snake[3] = cfeld::snake[2];
         cfeld::snake[2] = cfeld::snake[1];
         cfeld::snake[1] = cfeld::snake[0];
         cfeld::snake[0] = cfeld::snake[0] -40 ;
         break;

        case 'a':
         cfeld::snake[9] = cfeld::snake[8];
         cfeld::snake[8] = cfeld::snake[7];
         cfeld::snake[7] = cfeld::snake[6];
         cfeld::snake[6] = cfeld::snake[5];
         cfeld::snake[5] = cfeld::snake[4];
         cfeld::snake[4] = cfeld::snake[3];
         cfeld::snake[3] = cfeld::snake[2];
         cfeld::snake[2] = cfeld::snake[1];
         cfeld::snake[1] = cfeld::snake[0];
         cfeld::snake[0]--;
        break;

        case 's':
        cfeld::snake[9] = cfeld::snake[8];
        cfeld::snake[8] = cfeld::snake[7];
        cfeld::snake[7] = cfeld::snake[6];
        cfeld::snake[6] = cfeld::snake[5];
        cfeld::snake[5] = cfeld::snake[4];
        cfeld::snake[4] = cfeld::snake[3];
        cfeld::snake[3] = cfeld::snake[2];
        cfeld::snake[2] = cfeld::snake[1];
        cfeld::snake[1] = cfeld::snake[0];
        cfeld::snake[0] = cfeld::snake[0] +40;
        break;

        case 'd':
        cfeld::snake[9] = cfeld::snake[8];
         cfeld::snake[8] = cfeld::snake[7];
         cfeld::snake[7] = cfeld::snake[6];
         cfeld::snake[6] = cfeld::snake[5];
         cfeld::snake[5] = cfeld::snake[4];
         cfeld::snake[4] = cfeld::snake[3];
         cfeld::snake[3] = cfeld::snake[2];
         cfeld::snake[2] = cfeld::snake[1];
         cfeld::snake[1] = cfeld::snake[0];
        cfeld::snake[0]++;
        break;
        }

    }
else
{
    if( c == 'd')
    {
        cfeld::snake[9] = cfeld::snake[8];
         cfeld::snake[8] = cfeld::snake[7];
         cfeld::snake[7] = cfeld::snake[6];
         cfeld::snake[6] = cfeld::snake[5];
         cfeld::snake[5] = cfeld::snake[4];
         cfeld::snake[4] = cfeld::snake[3];
         cfeld::snake[3] = cfeld::snake[2];
         cfeld::snake[2] = cfeld::snake[1];
         cfeld::snake[1] = cfeld::snake[0];
        cfeld::snake[0]++;
    }
    if( c == 'w')
    {
        cfeld::snake[9] = cfeld::snake[8];
         cfeld::snake[8] = cfeld::snake[7];
         cfeld::snake[7] = cfeld::snake[6];
         cfeld::snake[6] = cfeld::snake[5];
         cfeld::snake[5] = cfeld::snake[4];
         cfeld::snake[4] = cfeld::snake[3];
         cfeld::snake[3] = cfeld::snake[2];
         cfeld::snake[2] = cfeld::snake[1];
         cfeld::snake[1] = cfeld::snake[0];
        cfeld::snake[0]=cfeld::snake[0]-40;

    }
    if( c == 'a')
    {
        cfeld::snake[9] = cfeld::snake[8];
         cfeld::snake[8] = cfeld::snake[7];
         cfeld::snake[7] = cfeld::snake[6];
         cfeld::snake[6] = cfeld::snake[5];
         cfeld::snake[5] = cfeld::snake[4];
         cfeld::snake[4] = cfeld::snake[3];
         cfeld::snake[3] = cfeld::snake[2];
         cfeld::snake[2] = cfeld::snake[1];
         cfeld::snake[1] = cfeld::snake[0];
        cfeld::snake[0]--;

    }
    if ( c== 's')
    {
        cfeld::snake[9] = cfeld::snake[8];
         cfeld::snake[8] = cfeld::snake[7];
         cfeld::snake[7] = cfeld::snake[6];
         cfeld::snake[6] = cfeld::snake[5];
         cfeld::snake[5] = cfeld::snake[4];
         cfeld::snake[4] = cfeld::snake[3];
         cfeld::snake[3] = cfeld::snake[2];
         cfeld::snake[2] = cfeld::snake[1];
         cfeld::snake[1] = cfeld::snake[0];
        cfeld::snake[0] = cfeld::snake[0]+40;

    }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2302588</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2302588</guid><dc:creator><![CDATA[lolipoplol]]></dc:creator><pubDate>Wed, 27 Feb 2013 14:50:26 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Wed, 27 Feb 2013 17:06:07 GMT]]></title><description><![CDATA[<p>Du hast OOP nicht im Geringsten verstanden.<br />
Lern es nochmal. Schaue dir die Beispiele an. Schaue dir mein Beispiel an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2302638</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2302638</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Wed, 27 Feb 2013 17:06:07 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Thu, 28 Feb 2013 18:21:55 GMT]]></title><description><![CDATA[<p>Ok -.- hab jetzt noch die mit einer for-schleife gemacht. Dann hab ich noch die kollisionsabfrage hinzugefügt. Jetz kann ichs spielen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2302919</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2302919</guid><dc:creator><![CDATA[lolipoplol]]></dc:creator><pubDate>Thu, 28 Feb 2013 18:21:55 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Fri, 01 Mar 2013 18:56:02 GMT]]></title><description><![CDATA[<p>Wie kann ich prüfen ob der kopf der Schlange kleiner ist als der Vector?</p>
<pre><code>if(snake[0] &gt; feld.size())
  {
   snake[0] = snake[0] - 800;
  }
</code></pre>
<p>Dies mach ich, wenn der Kopf größer ist, damit die Schlange auf der anderen Seite des Feldes wieder rauskommt.</p>
<p>(Hab mir das nochmal angeguckt aber iwi versteh ich das immer genau so wie ich das mit den Klassen mache -.-)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303428</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303428</guid><dc:creator><![CDATA[lolipoplol]]></dc:creator><pubDate>Fri, 01 Mar 2013 18:56:02 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Fri, 01 Mar 2013 19:55:42 GMT]]></title><description><![CDATA[<pre><code>if (snake[0] &lt; 0)
    snake[0] += 800;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2303440</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303440</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Fri, 01 Mar 2013 19:55:42 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Sat, 02 Mar 2013 17:08:45 GMT]]></title><description><![CDATA[<p>Danke <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<pre><code>bool exit = false;
while(!exit)
{

    if(kbhit()) // Nur wenn auch eine Taste gedrückt ist
    {
        c = getch();
        switch(c)
        {
        case 'w':
         for(int x = 9; x == 1; )
         {
         cfeld::snake[x] = cfeld::snake[--x];
         }
         cfeld::snake[0] = cfeld::snake[0] -40 ;
         break;

        case 'a':
         for(int x = 9; x == 1; )
         {
         cfeld::snake[x] = cfeld::snake[--x];
         }
         cfeld::snake[0]--;
        break;

        case 's':
        for(int x = 9; x == 1; )
         {
         cfeld::snake[x] = cfeld::snake[--x];
         }
        cfeld::snake[0] = cfeld::snake[0] +40;
        break;

        case 'd':
       for(int x = 9; x == 1; )
         {
         cfeld::snake[x] = cfeld::snake[--x];
         }
        cfeld::snake[0]++;
        break;
        }

    }

else
{
    if( c == 'd')
    {

         cfeld::snake[9] = cfeld::snake[8];
         cfeld::snake[8] = cfeld::snake[7];
         cfeld::snake[7] = cfeld::snake[6];
         cfeld::snake[6] = cfeld::snake[5];
         cfeld::snake[5] = cfeld::snake[4];
         cfeld::snake[4] = cfeld::snake[3];
         cfeld::snake[3] = cfeld::snake[2];
         cfeld::snake[2] = cfeld::snake[1];
         cfeld::snake[1] = cfeld::snake[0];
         cfeld::snake[0]++;

    }
    if( c == 'w')
    {

         cfeld::snake[9] = cfeld::snake[8];
         cfeld::snake[8] = cfeld::snake[7];
         cfeld::snake[7] = cfeld::snake[6];
         cfeld::snake[6] = cfeld::snake[5];
         cfeld::snake[5] = cfeld::snake[4];
         cfeld::snake[4] = cfeld::snake[3];
         cfeld::snake[3] = cfeld::snake[2];
         cfeld::snake[2] = cfeld::snake[1];
         cfeld::snake[1] = cfeld::snake[0];
         cfeld::snake[0]=cfeld::snake[0]-40;

    }
    if( c == 'a')
    {

         cfeld::snake[9] = cfeld::snake[8];
         cfeld::snake[8] = cfeld::snake[7];
         cfeld::snake[7] = cfeld::snake[6];
         cfeld::snake[6] = cfeld::snake[5];
         cfeld::snake[5] = cfeld::snake[4];
         cfeld::snake[4] = cfeld::snake[3];
         cfeld::snake[3] = cfeld::snake[2];
         cfeld::snake[2] = cfeld::snake[1];
         cfeld::snake[1] = cfeld::snake[0];
         cfeld::snake[0]--;

    }
    if ( c == 's')
    {

         cfeld::snake[9] = cfeld::snake[8];
         cfeld::snake[8] = cfeld::snake[7];
         cfeld::snake[7] = cfeld::snake[6];
         cfeld::snake[6] = cfeld::snake[5];
         cfeld::snake[5] = cfeld::snake[4];
         cfeld::snake[4] = cfeld::snake[3];
         cfeld::snake[3] = cfeld::snake[2];
         cfeld::snake[2] = cfeld::snake[1];
         cfeld::snake[1] = cfeld::snake[0];
         cfeld::snake[0] = cfeld::snake[0]+40;
    }
}
</code></pre>
<p>Wieso kann ich bei else die blöcke</p>
<pre><code>cfeld::snake[9] = cfeld::snake[8];
         cfeld::snake[8] = cfeld::snake[7];
         cfeld::snake[7] = cfeld::snake[6];
         cfeld::snake[6] = cfeld::snake[5];
         cfeld::snake[5] = cfeld::snake[4];
         cfeld::snake[4] = cfeld::snake[3];
         cfeld::snake[3] = cfeld::snake[2];
         cfeld::snake[2] = cfeld::snake[1];
         cfeld::snake[1] = cfeld::snake[0];
</code></pre>
<p>nicht in eine for- Schleife tun wie bei if?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303612</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303612</guid><dc:creator><![CDATA[lolipoplol]]></dc:creator><pubDate>Sat, 02 Mar 2013 17:08:45 GMT</pubDate></item><item><title><![CDATA[Reply to Snake in Konsole wächst nicht on Sun, 03 Mar 2013 04:18:13 GMT]]></title><description><![CDATA[<p>lolipoplol schrieb:</p>
<blockquote>
<pre><code class="language-cpp">/* ... */
</code></pre>
</blockquote>
<pre><code>1&gt;main.cpp(2): error C2059: syntax error : 'while'
1&gt;main.cpp(3): error C2143: syntax error : missing ';' before '{'
1&gt;main.cpp(3): error C2447: '{' : missing function header (old-style formal list?)
1&gt;main.cpp(109): fatal error C1004: unexpected end-of-file found
</code></pre>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
<p>Nachdem du hier schon mehrere Male Codefetzen gepostest hast, möchtest du evtl. <a href="http://www.c-plusplus.net/forum/304133-full" rel="nofollow">http://www.c-plusplus.net/forum/304133-full</a> lesen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303760</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303760</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Sun, 03 Mar 2013 04:18:13 GMT</pubDate></item></channel></rss>