<?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[Anfängerproblem]]></title><description><![CDATA[<p>Hi zusammen,</p>
<p>ich habe eine Frage an Euch. Ich möchte ein kleines Prog. schreiben, bei dem ein Ball über den Bildschirm wandert und am Rand des Bildschirmes wieder abprallt. Das wandern über den Bildschirm ist kein Problem.</p>
<p>Nur die Sache mit dem Rand bekomme ich nicht hin. Kann mir da jemand eine Hilfestellung geben ?</p>
<p>cu</p>
<p>Michael</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/118234/anfängerproblem</link><generator>RSS for Node</generator><lastBuildDate>Fri, 21 Aug 2026 08:17:00 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/118234.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 16 Aug 2005 13:14:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Anfängerproblem on Tue, 16 Aug 2005 13:14:40 GMT]]></title><description><![CDATA[<p>Hi zusammen,</p>
<p>ich habe eine Frage an Euch. Ich möchte ein kleines Prog. schreiben, bei dem ein Ball über den Bildschirm wandert und am Rand des Bildschirmes wieder abprallt. Das wandern über den Bildschirm ist kein Problem.</p>
<p>Nur die Sache mit dem Rand bekomme ich nicht hin. Kann mir da jemand eine Hilfestellung geben ?</p>
<p>cu</p>
<p>Michael</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853397</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853397</guid><dc:creator><![CDATA[spike78]]></dc:creator><pubDate>Tue, 16 Aug 2005 13:14:40 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerproblem on Tue, 16 Aug 2005 13:41:07 GMT]]></title><description><![CDATA[<p>Hier ein Beispiel wie ma es machen könnte:</p>
<p>#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
using namespace std;</p>
<p>#include &lt;conio.h&gt; // Für kbhit() und getch()<br />
#include &quot;myMakros.h&quot;</p>
<p>#define ESC 27 // ESC beendet das Programm</p>
<p>unsigned long delay = 100L; // Verzögerung in Millisekunden</p>
<p>int main()<br />
{<br />
int x = 2, y = 2, dx = 1, geschw = 0;<br />
bool ende = false;<br />
string boden(80, '-'),<br />
header = &quot;**** SPRINGENDER BALL ****&quot;,<br />
commands = &quot;[Esc] = Beenden &quot;<br />
<div class="plugin-markdown"><input type="checkbox" id="checkbox7798" /><label for="checkbox7798">= Langsamer&quot;;</label></div></p>
<p>FARBE(WEISS,BLAU);<br />
CLS;<br />
LOCATE(1,25); cout &lt;&lt; header;<br />
LOCATE(24,1); cout &lt;&lt; boden;<br />
LOCATE(25,10); cout &lt;&lt; commands;</p>
<p>while( !ende) // solange das Ende-Flag<br />
{ // nicht gesetzt ist.<br />
LOCATE(y,x); cout &lt;&lt; 'o'; // Ball anzeigen</p>
<p>Sleep(delay); // Etwas warten</p>
<p>if(x == 1 || x == 79) dx = -dx; // An einer Wand?<br />
if( y == 23 ) // Am Boden?<br />
{<br />
geschw = - geschw;<br />
if( geschw == 0 ) geschw = -7; // Neu anstossen<br />
}<br />
geschw += 1; // Beschleunigung = 1</p>
<p>LOCATE(y,x); cout &lt;&lt; ' '; // Anzeige löschen<br />
y += geschw; x += dx; // Neue Position</p>
<p>if( kbhit() != 0 ) // Taste gedrückt?<br />
{<br />
switch(getch()) // ja<br />
{<br />
case '+': delay -= delay/5; // schneller<br />
break;<br />
case '-': delay += 1+ delay/5; // langsamer<br />
break;<br />
case ESC: ende = true; // Pgm. beenden<br />
}<br />
}<br />
}<br />
NORMAL;<br />
CLS;<br />
return 0;<br />
}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853423</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853423</guid><dc:creator><![CDATA[gomorra]]></dc:creator><pubDate>Tue, 16 Aug 2005 13:41:07 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerproblem on Tue, 16 Aug 2005 16:34:59 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>erst mal danke. Aber ich denke als Anfänger bin ich da etwas überfordert. Wie bekomm ich nur die Sache mit dem Rand raus ?</p>
<p>Gruß</p>
<p>Michael</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853573</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853573</guid><dc:creator><![CDATA[spike78]]></dc:creator><pubDate>Tue, 16 Aug 2005 16:34:59 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerproblem on Wed, 17 Aug 2005 06:49:32 GMT]]></title><description><![CDATA[<p>Hi Spike,</p>
<p>Wie lässt du denn den Ball wandern:<br />
Benutzt du direkt die Win32 API oder bedienst du den X-Server?<br />
Oder verwendest du ein GUI-Toolkit (MFC/QT)?<br />
Wandert dein Ball innerhalb eines Fensters oder wirklich über den Bildschirm?<br />
Möchtest du die Bildschirmgrösse (in Pixeln) oder die Fenstergrösse?</p>
<p>Sorry das ich mehr Fragen als Antworten gebe - aber ich fand die Frage etwas schwammig gestellt</p>
<p>gruss<br />
Tobi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853846</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853846</guid><dc:creator><![CDATA[RabiLöw]]></dc:creator><pubDate>Wed, 17 Aug 2005 06:49:32 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerproblem on Wed, 17 Aug 2005 06:56:12 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>also ich habe folgende Aufgabenstellung.</p>
<p>Ich soll ein Programm schreiben, bei dem ein Ball (&quot;o&quot;) per Tastatureingabe über den Bildschirm läuft. Dieser soll, sobald er am Bildschirmrand angekommen ist abprallen.<br />
Das Programm soll mit der Eingabe von &quot;e&quot; abgebrochen werden.<br />
Soweit habe ich das so gemacht:</p>
<p>int main()<br />
{<br />
int x,y;<br />
char taste;<br />
printf(&quot;Anfangsposition festlegen&quot;);<br />
printf(&quot;\n\nPosition x:&quot;);<br />
scanf(&quot;%i&quot;,&amp;x);<br />
printf(&quot;Position y:&quot;);<br />
scanf(&quot;%i&quot;,&amp;y);<br />
clrscr();</p>
<p>do<br />
{<br />
gotoxy(x,y);</p>
<p>// Rand testen</p>
<p>printf(&quot;o&quot;);<br />
printf(&quot;%i %i&quot;,x,y);<br />
x=x+1;<br />
y=y+1;<br />
taste=getch();<br />
}<br />
while (taste!='e');</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853850</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853850</guid><dc:creator><![CDATA[spike78]]></dc:creator><pubDate>Wed, 17 Aug 2005 06:56:12 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerproblem on Wed, 17 Aug 2005 09:01:46 GMT]]></title><description><![CDATA[<p>Erstmal: Bitte, bitte Codetags benutzen, denn das ist ja grauenvoll zu lesen.</p>
<p>Zweitens: Wo hast du denn gotoxy hergezaubert? Ist das eine Bibliotheksfunktion? Was bedeuten die Werte x und y? _Falls_ x und y Pixelkoordinaten sind, muss du nur prüfen, ob diese Koordinaten ausserhalb des sichtbaren bereiches sind.</p>
<p>Etwa so:</p>
<p>spike78 schrieb:</p>
<blockquote>
<pre><code class="language-cpp">int main()
{
    int x,y;
    char taste;
    printf(&quot;Anfangsposition festlegen&quot;);
    printf(&quot;\n\nPosition x:&quot;);
    scanf(&quot;%i&quot;,&amp;x);
    printf(&quot;Position y:&quot;);
    scanf(&quot;%i&quot;,&amp;y);
    clrscr();

    do
    {
        /**
         * Erst den Rand testen, dann dahingehen, oder eben nicht
         */

        if (x&lt;=0)
        {
            // andere Richtung z.B.
            x--;
        }
        else if (x&gt;=SCREENSIZE_X)    // also Anzahl der Pixel in x-Richtung,                    
        {                            // oder eben Koordinaten, was du da halt hast
            x++;
        }

        (if &lt;= 0)
        {
            // ...
        }
        else if (y &gt;= SCREENSIZE_Y)
        {
            // ...
        }

        gotoxy(x,y);

        printf(&quot;o&quot;);
        printf(&quot;%i %i&quot;,x,y);
        x=x+1;
        y=y+1;
        taste=getch();
    } while (taste!='e');

    // kommt da noch was ???

    return 0;
}
</code></pre>
</blockquote>
<p>SCREENSIZE_X und SCREENSIZE_Y sind nur Platzhalter. So würde ich das mit einer ganz simplen Collisiondetection machen.</p>
<p>Gruß Mea</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853956</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853956</guid><dc:creator><![CDATA[Meaculpa]]></dc:creator><pubDate>Wed, 17 Aug 2005 09:01:46 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerproblem on Wed, 17 Aug 2005 09:23:09 GMT]]></title><description><![CDATA[<p>Die Idee von Meaculpa geht schon in die richtige Richtung. Funktioniert aber leider so nicht ganz. Würde es so machen.</p>
<pre><code class="language-cpp">int main() {
    int x,y, dx, dy;
    dx=1; dy=1;
    char taste;
    printf(&quot;Anfangsposition festlegen&quot;);
    printf(&quot;\n\nPosition x:&quot;);
    scanf(&quot;%i&quot;,&amp;x);
    printf(&quot;Position y:&quot;);
    scanf(&quot;%i&quot;,&amp;y);
    clrscr();
    do {
        if ( x&lt;=0 || x&gt;=SCREENSIZE_X ) {
            // andere Richtung
            dx=-dx;
        }
        (if y&lt;= 0 || y &gt;= SCREENSIZE_Y ) {
            // andere Richtung
            dy=-dy;
        }
        gotoxy(x,y);
        printf(&quot;o&quot;);
        printf(&quot;%i %i&quot;,x,y);
        x+=dx;
        y+=dy;
        taste=getch();
    } while (taste!='e');
    return 0;
}
</code></pre>
<p>Kurt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853995</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853995</guid><dc:creator><![CDATA[ZuK]]></dc:creator><pubDate>Wed, 17 Aug 2005 09:23:09 GMT</pubDate></item></channel></rss>