<?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[Ok erledigt || Bild von rechts nach links wandern lassen]]></title><description><![CDATA[<p>Hey leute, ich versuche grade ein kleines 2D game zuerstellen läuft ansich auch alles ganz gut versuche nur aktuell noch das sich die extra monster hin und her bewegen können das hab ich so versucht:</p>
<pre><code class="language-cpp">bool mmove = true;  //bewegrichtung
int movevar = 50;   // noch zulaufende entfernung

int drawmob(BITMAP *where, int x)
{
  int move = 0;
  if ( (mmove) &amp; (movevar &gt;= 0) )
  {
           movevar -= 5;
           move += 5; 
  } 
  else if( (!mmove) &amp; (movevar &gt;= 0) )
  {
           movevar += 5;
           move -= 5; 
  } 
  else 
  {
       movevar = 50;
       if (mmove) mmove = false;  //richtungswechsel
       else mmove = true;
  }

  BITMAP *Mob;
  Mob = load_bitmap(&quot;Mob.bmp&quot;, NULL);
  draw_sprite(where, Mob, 300 + x + move, 335);   
}
</code></pre>
<p>allerdings läuft das monster so wies aussieht nur einmal nach links und bleibt stehen jemand ne idee? oder evtl ne andere lösungsidee?</p>
<p>mfg friedrich</p>
<p>Edit: ok danke habs jetzt so gelöst:</p>
<pre><code class="language-cpp">int movevar = 0;
bool movetype = true;

int drawmob(BITMAP *where, int x)
{
  if (movetype) 
  {
                movevar++;
                if (movevar &gt;= 20) movetype = false;
  }
  else 
  {
                movevar--;
                if (movevar &lt;= 0) movetype = true;
}  
  BITMAP *Mob;
  Mob = load_bitmap(&quot;Mob.bmp&quot;, NULL);
  draw_sprite(where, Mob, 300 + x + movevar * 2, 335);   
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/289277/ok-erledigt-bild-von-rechts-nach-links-wandern-lassen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 19 Aug 2026 07:35:06 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/289277.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 01 Jul 2011 16:36:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ok erledigt || Bild von rechts nach links wandern lassen on Fri, 01 Jul 2011 17:23:26 GMT]]></title><description><![CDATA[<p>Hey leute, ich versuche grade ein kleines 2D game zuerstellen läuft ansich auch alles ganz gut versuche nur aktuell noch das sich die extra monster hin und her bewegen können das hab ich so versucht:</p>
<pre><code class="language-cpp">bool mmove = true;  //bewegrichtung
int movevar = 50;   // noch zulaufende entfernung

int drawmob(BITMAP *where, int x)
{
  int move = 0;
  if ( (mmove) &amp; (movevar &gt;= 0) )
  {
           movevar -= 5;
           move += 5; 
  } 
  else if( (!mmove) &amp; (movevar &gt;= 0) )
  {
           movevar += 5;
           move -= 5; 
  } 
  else 
  {
       movevar = 50;
       if (mmove) mmove = false;  //richtungswechsel
       else mmove = true;
  }

  BITMAP *Mob;
  Mob = load_bitmap(&quot;Mob.bmp&quot;, NULL);
  draw_sprite(where, Mob, 300 + x + move, 335);   
}
</code></pre>
<p>allerdings läuft das monster so wies aussieht nur einmal nach links und bleibt stehen jemand ne idee? oder evtl ne andere lösungsidee?</p>
<p>mfg friedrich</p>
<p>Edit: ok danke habs jetzt so gelöst:</p>
<pre><code class="language-cpp">int movevar = 0;
bool movetype = true;

int drawmob(BITMAP *where, int x)
{
  if (movetype) 
  {
                movevar++;
                if (movevar &gt;= 20) movetype = false;
  }
  else 
  {
                movevar--;
                if (movevar &lt;= 0) movetype = true;
}  
  BITMAP *Mob;
  Mob = load_bitmap(&quot;Mob.bmp&quot;, NULL);
  draw_sprite(where, Mob, 300 + x + movevar * 2, 335);   
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2087328</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2087328</guid><dc:creator><![CDATA[friedrich]]></dc:creator><pubDate>Fri, 01 Jul 2011 17:23:26 GMT</pubDate></item><item><title><![CDATA[Reply to Ok erledigt || Bild von rechts nach links wandern lassen on Fri, 01 Jul 2011 16:52:55 GMT]]></title><description><![CDATA[<ol>
<li><code>&amp;</code> ist kein logisches und. Nimm <code>&amp;&amp;</code> oder <code>and</code><br />
2. In Zeile 14 soll wohl auch <code>-=</code> statt <code>+=</code> stehen</li>
</ol>
]]></description><link>https://www.c-plusplus.net/forum/post/2087339</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2087339</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 01 Jul 2011 16:52:55 GMT</pubDate></item><item><title><![CDATA[Reply to Ok erledigt || Bild von rechts nach links wandern lassen on Fri, 01 Jul 2011 16:58:00 GMT]]></title><description><![CDATA[<p>danke aufjedenfall schonmal für die antwort<br />
zu 1. danke sofort geändert^^<br />
zu 2. ne ist schon richtig so wenn die noch zu laufende strecke sinkt soll<br />
die gelaufene strecke steigen</p>
<p>insgesamt klappts leider dennoch noch nicht</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2087341</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2087341</guid><dc:creator><![CDATA[friedrich]]></dc:creator><pubDate>Fri, 01 Jul 2011 16:58:00 GMT</pubDate></item><item><title><![CDATA[Reply to Ok erledigt || Bild von rechts nach links wandern lassen on Fri, 01 Jul 2011 17:27:27 GMT]]></title><description><![CDATA[<p>friedrich schrieb:</p>
<blockquote>
<p>zu 2. ne ist schon richtig so wenn die noch zu laufende strecke sinkt soll<br />
die gelaufene strecke steigen</p>
</blockquote>
<p>Ja, wenn du auf einmal die Abfrage an movevar umdrehst (dein 2. Quelltext), dann ist das natürlich nicht richtig. Aber im ersten Quelltext war dies der Fehler, da du dort auf größer 0 geprüft hast.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2087354</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2087354</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 01 Jul 2011 17:27:27 GMT</pubDate></item><item><title><![CDATA[Reply to Ok erledigt || Bild von rechts nach links wandern lassen on Fri, 01 Jul 2011 17:30:49 GMT]]></title><description><![CDATA[<p>ahh ok jetzt seh ichs auch in der 2. if abfrage hättes &lt;= sein müssen ok hätt ich mirs umschreiben sparen können^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2087356</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2087356</guid><dc:creator><![CDATA[friedrich]]></dc:creator><pubDate>Fri, 01 Jul 2011 17:30:49 GMT</pubDate></item></channel></rss>