<?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[collideMap() only in the main loop scope?]]></title><description><![CDATA[<p dir="auto">I couldn't find the problem, why my collision boxes had no effect. Then I realized, that calling <code>collideMap(sprite)</code> outside of my function, namely in the main loop, make them work. Did you make the same experience? If not I maybe have to change the order of function calls, or dig where the real problem lies in my code.</p>
<p dir="auto">Its a long time ago, I tried something with map collision, and the last time, I postponed the project, so I am a newbie to map collisions and this could be very obvious to you.</p>
<p dir="auto">This pseudo code worked: the collision boxes worked</p>
<pre><code>loadMap("level1") // a map with collision boxes I draw in the map editor
// sprites[] is a global array of sprites
// players is a global int with the number of sprites/players
loop
   updateSprites()
   drawMap()
   for i = 0 to players loop
      collideMap(sprites[i])
   repeat
   drawSprites()
repeat
</code></pre>
<p dir="auto">The following code caused the collision borders to be ignored.</p>
<pre><code>loadMap("level1") // a map with collision boxes I draw in the map editor
// sprites[] is a global array of sprites
// players is a global int with the number of sprites/players
loop
   updateSprites()
   drawMap()
   for i = 0 to players loop
     updatePlayers(i)
   repeat
   drawSprites()
repeat

function updatePlayers(player)
   collideMap(sprites[i])
return void
</code></pre>
]]></description><link>http://fuzearena.com/forum//topic/1284/collidemap-only-in-the-main-loop-scope</link><generator>RSS for Node</generator><lastBuildDate>Wed, 16 Sep 2026 09:44:56 GMT</lastBuildDate><atom:link href="http://fuzearena.com/forum//topic/1284.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 13 Aug 2020 08:06:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to collideMap() only in the main loop scope? on Thu, 13 Aug 2020 14:46:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://fuzearena.com/forum//uid/393">@waldron</a> i appreciate that guidance. I will do it like this.</p>
]]></description><link>http://fuzearena.com/forum//post/11323</link><guid isPermaLink="true">http://fuzearena.com/forum//post/11323</guid><dc:creator><![CDATA[spikey]]></dc:creator><pubDate>Thu, 13 Aug 2020 14:46:36 GMT</pubDate></item><item><title><![CDATA[Reply to collideMap() only in the main loop scope? on Thu, 13 Aug 2020 09:18:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://fuzearena.com/forum//uid/360">@spikey</a> i usually drawmap() then updatesprites() the sprite location i put at the top of the loop so that shouldn't effect the collision not in my experience anyway maybe because the sprites are getting updated before the map</p>
]]></description><link>http://fuzearena.com/forum//post/11315</link><guid isPermaLink="true">http://fuzearena.com/forum//post/11315</guid><dc:creator><![CDATA[waldron]]></dc:creator><pubDate>Thu, 13 Aug 2020 09:18:53 GMT</pubDate></item><item><title><![CDATA[Reply to collideMap() only in the main loop scope? on Thu, 13 Aug 2020 08:28:48 GMT]]></title><description><![CDATA[<p dir="auto">Oh, I just found out <strong>how to make it fail</strong> again.<br />
If I do a <code>getSpriteLocation()</code> before the <code>collideMap()</code> call, the collision box have no effect and the sprite can walk through the boxes.</p>
<p dir="auto">This inhibits the collision boxes:</p>
<pre><code>pos = getSpriteLocation(sprite)
collideMap(sprite)
// do some clamping of the coordinates
setSpriteLocation(sprite)
</code></pre>
<p dir="auto">This works:</p>
<pre><code>collideMap(sprite)
pos = getSpriteLocation(sprite)
// do some clamping of the coordinates
setSpriteLocation(sprite)
</code></pre>
<p dir="auto">I think I just have to study these commands a bit more and read more example code.</p>
]]></description><link>http://fuzearena.com/forum//post/11314</link><guid isPermaLink="true">http://fuzearena.com/forum//post/11314</guid><dc:creator><![CDATA[spikey]]></dc:creator><pubDate>Thu, 13 Aug 2020 08:28:48 GMT</pubDate></item><item><title><![CDATA[Reply to collideMap() only in the main loop scope? on Thu, 13 Aug 2020 08:13:31 GMT]]></title><description><![CDATA[<p dir="auto">Gosh! it works now! After putting the function back in. So, sorry. But no clue, yet why.<br />
I get some coffee.</p>
]]></description><link>http://fuzearena.com/forum//post/11313</link><guid isPermaLink="true">http://fuzearena.com/forum//post/11313</guid><dc:creator><![CDATA[spikey]]></dc:creator><pubDate>Thu, 13 Aug 2020 08:13:31 GMT</pubDate></item></channel></rss>