<?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[Kleines Spiel auf der Konsole]]></title><description><![CDATA[<p>Hallo ich bin gerade dabei ein Kleines Spiel für die Konsole zu machen bis hier hin bin ich gekommen.</p>
<p>Aber jetzt weiss ich nicht wie es machen soll das ich meine Figur rauf und runter bewegen kann.</p>
<p>Der Teil zum runter laufen.<br />
Aber die Figur bewegt sich nur ganz schnell nach Links unten in die Ecke ...</p>
<pre><code class="language-cpp">if (eingabe == key_down)
                {
                         clrscr();

                         px = px + px;
                         py = py+ py;

                         cursor_pos( px  , py);
                         cout&lt;&lt;&quot;\x1 &quot;;
                }
</code></pre>
<p>Das Komplette Programm</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;conio&gt;
#include &lt;windows&gt;

#define key_left 97
#define key_right 100
#define key_up 119
#define key_down 115

using namespace std;

void cursor_pos(int pos_x , int pos_y);

int main()
{

int px = 10;
int py = 10;

int eingabe;

cursor_pos( px  , py);
cout&lt;&lt;&quot;\x1 &quot;;

        while(1)
        {
                eingabe = getch();

                if (eingabe == key_left)
                {
                         clrscr();
                         px = px - 1;

                         cursor_pos( px  , py);
                         cout&lt;&lt;&quot;\x1 &quot;;
                }

                if (eingabe == key_right)
                {
                         clrscr();
                         px = px +1;

                         cursor_pos( px  , py);
                         cout&lt;&lt;&quot;\x1 &quot;;
                }

                if (eingabe == key_down)
                {
                         clrscr();

                         px = px + px;
                         py = py+ py;

                         cursor_pos( px  , py);
                         cout&lt;&lt;&quot;\x1 &quot;;
                }

        }

}

        void cursor_pos(int pos_x , int pos_y)
        {

                COORD topLeft={pos_x,pos_y};
                HANDLE fenster;

                fenster = GetStdHandle( STD_OUTPUT_HANDLE );
                SetConsoleCursorPosition(fenster,topLeft);

        }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/237834/kleines-spiel-auf-der-konsole</link><generator>RSS for Node</generator><lastBuildDate>Wed, 23 Sep 2026 09:34:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/237834.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 02 Apr 2009 14:11:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Kleines Spiel auf der Konsole on Thu, 02 Apr 2009 14:11:00 GMT]]></title><description><![CDATA[<p>Hallo ich bin gerade dabei ein Kleines Spiel für die Konsole zu machen bis hier hin bin ich gekommen.</p>
<p>Aber jetzt weiss ich nicht wie es machen soll das ich meine Figur rauf und runter bewegen kann.</p>
<p>Der Teil zum runter laufen.<br />
Aber die Figur bewegt sich nur ganz schnell nach Links unten in die Ecke ...</p>
<pre><code class="language-cpp">if (eingabe == key_down)
                {
                         clrscr();

                         px = px + px;
                         py = py+ py;

                         cursor_pos( px  , py);
                         cout&lt;&lt;&quot;\x1 &quot;;
                }
</code></pre>
<p>Das Komplette Programm</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;conio&gt;
#include &lt;windows&gt;

#define key_left 97
#define key_right 100
#define key_up 119
#define key_down 115

using namespace std;

void cursor_pos(int pos_x , int pos_y);

int main()
{

int px = 10;
int py = 10;

int eingabe;

cursor_pos( px  , py);
cout&lt;&lt;&quot;\x1 &quot;;

        while(1)
        {
                eingabe = getch();

                if (eingabe == key_left)
                {
                         clrscr();
                         px = px - 1;

                         cursor_pos( px  , py);
                         cout&lt;&lt;&quot;\x1 &quot;;
                }

                if (eingabe == key_right)
                {
                         clrscr();
                         px = px +1;

                         cursor_pos( px  , py);
                         cout&lt;&lt;&quot;\x1 &quot;;
                }

                if (eingabe == key_down)
                {
                         clrscr();

                         px = px + px;
                         py = py+ py;

                         cursor_pos( px  , py);
                         cout&lt;&lt;&quot;\x1 &quot;;
                }

        }

}

        void cursor_pos(int pos_x , int pos_y)
        {

                COORD topLeft={pos_x,pos_y};
                HANDLE fenster;

                fenster = GetStdHandle( STD_OUTPUT_HANDLE );
                SetConsoleCursorPosition(fenster,topLeft);

        }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1689919</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1689919</guid><dc:creator><![CDATA[blup]]></dc:creator><pubDate>Thu, 02 Apr 2009 14:11:00 GMT</pubDate></item><item><title><![CDATA[Reply to Kleines Spiel auf der Konsole on Thu, 02 Apr 2009 14:31:06 GMT]]></title><description><![CDATA[<p>blup schrieb:</p>
<blockquote>
<p>Hallo ich bin gerade dabei ein Kleines Spiel für die Konsole zu machen bis hier hin bin ich gekommen.</p>
<p>Aber jetzt weiss ich nicht wie es machen soll das ich meine Figur rauf und runter bewegen kann.</p>
<p>Der Teil zum runter laufen.<br />
Aber die Figur bewegt sich nur ganz schnell nach Links unten in die Ecke ...</p>
<pre><code class="language-cpp">if (eingabe == key_down)
                {
                         clrscr();

                         px = px + px;
                         py = py+ py;

                         cursor_pos( px  , py);
                         cout&lt;&lt;&quot;\x1 &quot;;
                }
</code></pre>
</blockquote>
<p>Wenn du hoch oder runter willst musst du nur die y Koordinate verändern. Wenn du x und y veränderst gehst du schräg <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>
<p>Keros</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1689928</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1689928</guid><dc:creator><![CDATA[Keros]]></dc:creator><pubDate>Thu, 02 Apr 2009 14:31:06 GMT</pubDate></item><item><title><![CDATA[Reply to Kleines Spiel auf der Konsole on Thu, 02 Apr 2009 14:36:28 GMT]]></title><description><![CDATA[<p>Warum erhöhst du px, wenn du dich runter bewegen willst? Das sollte nur py sein, oder? Und wieso &quot;py = py+ py;&quot;? Wieso nicht einfach +1? Du willst doch schließlich ein Zeichen nach unten (bei py==5 springst du nach py==10...).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1689930</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1689930</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 02 Apr 2009 14:36:28 GMT</pubDate></item><item><title><![CDATA[Reply to Kleines Spiel auf der Konsole on Thu, 02 Apr 2009 14:33:37 GMT]]></title><description><![CDATA[<p>Jo funktioniert ty.</p>
<p>Dann werd ich mich mal am Level bau versuchen^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1689932</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1689932</guid><dc:creator><![CDATA[blup]]></dc:creator><pubDate>Thu, 02 Apr 2009 14:33:37 GMT</pubDate></item></channel></rss>