<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Circle Collision Detection</title>
		<link>http://www.allegro.cc/forums/view/591994</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 03 Jul 2007 13:11:36 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>does anyone know any tutorials of circle collision detection written with allegro? or source code maybe? i&#39;m really into physics stuff and simulations, the main reason I decided to try on programming <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /> hopefully i can make a pool game...</p><p>i want to know how to calculate the angle after impact, and if you are kind enough, maybe collision that involve mass (i think its momentum...errr...donno <img src="http://www.allegro.cc/forums/smileys/huh.gif" alt="???" />) <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Fishcake)</author>
		<pubDate>Sat, 23 Jun 2007 18:04:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><a href="http://www.allegro.cc/forums/thread/591703">Here. No spin effects, though.</a></p><p>If the circles/spheres/balls don&#39;t have different masses, just work with velocity vectors, no mass stuff.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Johan Halmén)</author>
		<pubDate>Sat, 23 Jun 2007 19:25:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><a href="http://www.allegro.cc/forums/thread/591684">My thread</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (James Stanley)</author>
		<pubDate>Sat, 23 Jun 2007 20:02:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>wow thanks Johan Halmén and James Stanley! and with graphical explanation! wootness <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Fishcake)</author>
		<pubDate>Sun, 24 Jun 2007 05:17:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Just curious.  How do you guys make a link to another page and give it a name like you just did?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (julian_boolean)</author>
		<pubDate>Sun, 24 Jun 2007 09:58:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><a href="http://www.allegro.cc/mockup.html">Please, read me.</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Paul whoknows)</author>
		<pubDate>Sun, 24 Jun 2007 11:54:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Awesome!! Thank you very much. <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (julian_boolean)</author>
		<pubDate>Sun, 24 Jun 2007 19:02:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>ok, i got a problem...</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="k1">double</span> distance<span class="k2">(</span><span class="k1">double</span> pos1_x, <span class="k1">double</span> pos1_y, <span class="k1">double</span> pos2_x, <span class="k1">double</span> pos2_y<span class="k2">)</span> <span class="k2">{</span></td></tr><tr><td class="number">2</td><td>   <span class="k1">return</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_738.html" target="_blank">sqrt</a><span class="k2">(</span><span class="k2">(</span>pos1_x-pos2_x<span class="k2">)</span><span class="k3">*</span><span class="k2">(</span>pos1_x-pos2_x<span class="k2">)</span> <span class="k3">+</span> <span class="k2">(</span>pos1_y-pos2_y<span class="k2">)</span><span class="k3">*</span><span class="k2">(</span>pos1_y-pos2_y<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">3</td><td><span class="k2">}</span></td></tr><tr><td class="number">4</td><td>&#160;</td></tr><tr><td class="number">5</td><td><span class="k1">void</span> bounce<span class="k2">(</span>Carrom<span class="k3">*</span> c1, Carrom<span class="k3">*</span> c2<span class="k2">)</span><span class="k2">{</span></td></tr><tr><td class="number">6</td><td>     </td></tr><tr><td class="number">7</td><td>  <span class="k1">double</span> cNorm <span class="k3">=</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_50.html" target="_blank">atan2</a><span class="k2">(</span>c2-&gt;y <span class="k3">-</span> c1-&gt;y, c2-&gt;x <span class="k3">-</span> c1-&gt;x<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">8</td><td>  <span class="k1">double</span> nX <span class="k3">=</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_113.html" target="_blank">cos</a><span class="k2">(</span>cNorm<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">9</td><td>  <span class="k1">double</span> nY <span class="k3">=</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_728.html" target="_blank">sin</a><span class="k2">(</span>cNorm<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">10</td><td>  </td></tr><tr><td class="number">11</td><td>  <span class="k1">double</span> a1 <span class="k3">=</span> c1-&gt;dx<span class="k3">*</span>nX <span class="k3">+</span> c1-&gt;dy<span class="k3">*</span>nY<span class="k2">;</span></td></tr><tr><td class="number">12</td><td>  <span class="k1">double</span> a2 <span class="k3">=</span> c2-&gt;dx<span class="k3">*</span>nX <span class="k3">+</span> c2-&gt;dy<span class="k3">*</span>nY<span class="k2">;</span></td></tr><tr><td class="number">13</td><td>  <span class="k1">double</span> optimisedP <span class="k3">=</span> <span class="k2">(</span><span class="n">2</span>.<span class="n">0</span> <span class="k3">*</span> <span class="k2">(</span>a1-a2<span class="k2">)</span><span class="k2">)</span> <span class="k3">/</span> <span class="k2">(</span>c1-&gt;m <span class="k3">+</span> c2-&gt;m<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">14</td><td>  </td></tr><tr><td class="number">15</td><td>  <span class="k1">if</span><span class="k2">(</span> distance<span class="k2">(</span>c1-&gt;x, c1-&gt;y, c2-&gt;x, c2-&gt;y<span class="k2">)</span> <span class="k3">&lt;</span> <span class="k2">(</span>c1-&gt;r <span class="k3">+</span> c2-&gt;r<span class="k2">)</span> <span class="k2">)</span><span class="k2">{</span></td></tr><tr><td class="number">16</td><td>    c1-&gt;dx <span class="k3">=</span> c1-&gt;dx <span class="k3">-</span> <span class="k2">(</span>optimisedP <span class="k3">*</span> c2-&gt;m <span class="k3">*</span> nX<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">17</td><td>    c1-&gt;dy <span class="k3">=</span> c1-&gt;dy <span class="k3">-</span> <span class="k2">(</span>optimisedP <span class="k3">*</span> c2-&gt;m <span class="k3">*</span> nY<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">18</td><td>    c2-&gt;dx <span class="k3">=</span> c2-&gt;dx <span class="k3">+</span> <span class="k2">(</span>optimisedP <span class="k3">*</span> c1-&gt;m <span class="k3">*</span> nX<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">19</td><td>    c2-&gt;dy <span class="k3">=</span> c2-&gt;dy <span class="k3">+</span> <span class="k2">(</span>optimisedP <span class="k3">*</span> c1-&gt;m <span class="k3">*</span> nY<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">20</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">21</td><td>     </td></tr><tr><td class="number">22</td><td><span class="k2">}</span></td></tr></tbody></table></div></div><p>

this code is actually from <a href="http://www.allegro.cc/forums/thread/591703">http://www.allegro.cc/forums/thread/591703</a>. i changed it  into a function. the problem is that sometimes when the circles collide, they stick together, which is not a nice scene..:-/ its sticking to each other just like magnet, except that they&#39;re overlapping...how do i fix that?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Fishcake)</author>
		<pubDate>Sun, 24 Jun 2007 19:08:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I know. I&#39;m in the middle of a game development and my balls stick, too. <img src="http://www.allegro.cc/forums/smileys/lipsrsealed.gif" alt=":-X" /> <br />The problem is, I think, when they collide and they get their new speeds and directions and in the next frame they still overlap. That would cause a negative collision, turning the velocity vectors once again against each other. Something like that.</p><p>Somehow it happens not very often in my game. First of all I thought my balls would never actually overlap. I thought I did the collision stuff in the frame before the overlap. I haven&#39;t checked that yet. Anyhow, if they overlap in the collision frame and still overlap in the next frame and that&#39;s what causes the stickyness, I must set a flag for collision and reset the flag not until there is no overlap anymore between the two balls in concern.</p><p>In my game I shoot balls against each others. The funny thing is that if two balls stick together like that, I can separate them by shooting a third ball against them. Actually that&#39;s so funny I think I won&#39;t fix the problem. I just have to find out a funny explanation for that in the gameplay. Extra bonus for shooting at magnetized balls, or something.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Johan Halmén)</author>
		<pubDate>Sun, 24 Jun 2007 21:38:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This may be of use 
</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td>Function UpdateBallPhysics<span class="k2">(</span><span class="k2">)</span></td></tr><tr><td class="number">2</td><td><span class="s">' This is the main physics function for the</span></td></tr><tr><td class="number">3</td><td><span class="s">'</span> balls. It contains the very basic movement</td></tr><tr><td class="number">4</td><td><span class="s">' physics as well as the collision response code</span></td></tr><tr><td class="number">5</td><td><span class="s">  For Local c:ballType = EachIn ballList</span></td></tr><tr><td class="number">6</td><td><span class="s">    '</span> update positions</td></tr><tr><td class="number">7</td><td>    c.x<span class="k3">=</span>c.x<span class="k3">+</span>c.dx</td></tr><tr><td class="number">8</td><td>    c.y<span class="k3">=</span>c.y<span class="k3">+</span>c.dy</td></tr><tr><td class="number">9</td><td>    <span class="s">' gradually slow down</span></td></tr><tr><td class="number">10</td><td><span class="s">    c.dx=c.dx*FRICTION</span></td></tr><tr><td class="number">11</td><td><span class="s">    c.dy=c.dy*FRICTION</span></td></tr><tr><td class="number">12</td><td><span class="s">    '</span> stop completely when below a certain speed</td></tr><tr><td class="number">13</td><td>    If Abs<span class="k2">(</span>c.dx<span class="k2">)</span><span class="k3">&lt;</span><span class="n">0</span>.<span class="n">068</span> Then c.dx<span class="k3">=</span><span class="n">0</span></td></tr><tr><td class="number">14</td><td>    If Abs<span class="k2">(</span>c.dy<span class="k2">)</span><span class="k3">&lt;</span><span class="n">0</span>.<span class="n">068</span> Then c.dy<span class="k3">=</span><span class="n">0</span></td></tr><tr><td class="number">15</td><td>    <span class="s">' COLLISION CHECKING</span></td></tr><tr><td class="number">16</td><td><span class="s">    '</span> Check each ball in the loop against</td></tr><tr><td class="number">17</td><td>    <span class="s">' every other (c against c2)</span></td></tr><tr><td class="number">18</td><td><span class="s">    For Local c2:ballType = EachIn ballList</span></td></tr><tr><td class="number">19</td><td><span class="s">      Local collisionDistance# = c.radius+c2.radius</span></td></tr><tr><td class="number">20</td><td><span class="s">      Local actualDistance# = Sqr((c2.x-c.x)^2+(c2.y-c.y)^2)</span></td></tr><tr><td class="number">21</td><td><span class="s">      '</span> collided <span class="k1">or</span> <span class="k1">not</span>?</td></tr><tr><td class="number">22</td><td>      If actualDistance<span class="k3">&lt;</span>collisionDistance Then</td></tr><tr><td class="number">23</td><td>        Local collNormalAngle#<span class="k3">=</span>ATan2<span class="k2">(</span>c2.y-c.y, c2.x-c.x<span class="k2">)</span></td></tr><tr><td class="number">24</td><td>        <span class="s">' position exactly touching, no intersection</span></td></tr><tr><td class="number">25</td><td><span class="s">        Local moveDist1#=(collisionDistance-actualDistance)*(c2.mass/Float((c.mass+c2.mass)))</span></td></tr><tr><td class="number">26</td><td><span class="s">        Local moveDist2#=(collisionDistance-actualDistance)*(c.mass/Float((c.mass+c2.mass)))</span></td></tr><tr><td class="number">27</td><td><span class="s">        c.x=c.x + moveDist1*Cos(collNormalAngle+180)</span></td></tr><tr><td class="number">28</td><td><span class="s">        c.y=c.y + moveDist1*Sin(collNormalAngle+180)</span></td></tr><tr><td class="number">29</td><td><span class="s">        c2.x=c2.x + moveDist2*Cos(collNormalAngle)</span></td></tr><tr><td class="number">30</td><td><span class="s">        c2.y=c2.y + moveDist2*Sin(collNormalAngle)</span></td></tr><tr><td class="number">31</td><td><span class="s">        '</span> COLLISION RESPONSE</td></tr><tr><td class="number">32</td><td>        <span class="s">' n = vector connecting the centers of the balls.</span></td></tr><tr><td class="number">33</td><td><span class="s">        '</span> we are finding the components of the normalised vector n</td></tr><tr><td class="number">34</td><td>        Local nX#<span class="k3">=</span>Cos<span class="k2">(</span>collNormalAngle<span class="k2">)</span></td></tr><tr><td class="number">35</td><td>        Local nY#<span class="k3">=</span>Sin<span class="k2">(</span>collNormalAngle<span class="k2">)</span></td></tr><tr><td class="number">36</td><td>        <span class="s">' now find the length of the components of each movement vectors</span></td></tr><tr><td class="number">37</td><td><span class="s">        '</span> along n, by <span class="k1">using</span> dot product.</td></tr><tr><td class="number">38</td><td>        Local a1# <span class="k3">=</span> c.dx<span class="k3">*</span>nX  <span class="k3">+</span>  c.dy<span class="k3">*</span>nY</td></tr><tr><td class="number">39</td><td>        Local a2# <span class="k3">=</span> c2.dx<span class="k3">*</span>nX <span class="k3">+</span>  c2.dy<span class="k3">*</span>nY</td></tr><tr><td class="number">40</td><td>        <span class="s">' optimisedP = 2(a1 - a2)</span></td></tr><tr><td class="number">41</td><td><span class="s">        '</span>             <span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span></td></tr><tr><td class="number">42</td><td>        <span class="s">'              m1 + m2</span></td></tr><tr><td class="number">43</td><td><span class="s">        Local optimisedP# = (2.0 * (a1-a2)) / (c.mass + c2.mass)</span></td></tr><tr><td class="number">44</td><td><span class="s">        '</span> now find out the resultant vectors</td></tr><tr><td class="number">45</td><td>        <span class="s">''</span> Local r1% <span class="k3">=</span> c1.v <span class="k3">-</span> optimisedP <span class="k3">*</span> mass2 <span class="k3">*</span> n</td></tr><tr><td class="number">46</td><td>        c.dx <span class="k3">=</span> c.dx <span class="k3">-</span> <span class="k2">(</span>optimisedP<span class="k3">*</span>c2.mass<span class="k3">*</span>nX<span class="k2">)</span></td></tr><tr><td class="number">47</td><td>        c.dy <span class="k3">=</span> c.dy <span class="k3">-</span> <span class="k2">(</span>optimisedP<span class="k3">*</span>c2.mass<span class="k3">*</span>nY<span class="k2">)</span></td></tr><tr><td class="number">48</td><td>        <span class="s">''</span> Local r2% <span class="k3">=</span> c2.v <span class="k3">-</span> optimisedP <span class="k3">*</span> mass1 <span class="k3">*</span> n</td></tr><tr><td class="number">49</td><td>        c2.dx <span class="k3">=</span> c2.dx <span class="k3">+</span> <span class="k2">(</span>optimisedP<span class="k3">*</span>c.mass<span class="k3">*</span>nX<span class="k2">)</span></td></tr><tr><td class="number">50</td><td>        c2.dy <span class="k3">=</span> c2.dy <span class="k3">+</span> <span class="k2">(</span>optimisedP<span class="k3">*</span>c.mass<span class="k3">*</span>nY<span class="k2">)</span></td></tr><tr><td class="number">51</td><td>      End If</td></tr><tr><td class="number">52</td><td>    Next</td></tr><tr><td class="number">53</td><td>    <span class="s">' Simple bouncing off walls.</span></td></tr><tr><td class="number">54</td><td><span class="s">    If c.x&lt;c.radius</span></td></tr><tr><td class="number">55</td><td><span class="s">      c.x=c.radius</span></td></tr><tr><td class="number">56</td><td><span class="s">      c.dx=c.dx*-0.9</span></td></tr><tr><td class="number">57</td><td><span class="s">    End If</span></td></tr><tr><td class="number">58</td><td><span class="s">    If c.x&gt;GraphicsWidth()-c.radius</span></td></tr><tr><td class="number">59</td><td><span class="s">      c.x=GraphicsWidth()-c.radius</span></td></tr><tr><td class="number">60</td><td><span class="s">      c.dx=c.dx*-0.9</span></td></tr><tr><td class="number">61</td><td><span class="s">    End If</span></td></tr><tr><td class="number">62</td><td><span class="s">    If c.y&lt;c.radius</span></td></tr><tr><td class="number">63</td><td><span class="s">      c.y=c.radius</span></td></tr><tr><td class="number">64</td><td><span class="s">      c.dy=c.dy*-0.9</span></td></tr><tr><td class="number">65</td><td><span class="s">    End If</span></td></tr><tr><td class="number">66</td><td><span class="s">    If c.y&gt;GraphicsHeight()-c.radius</span></td></tr><tr><td class="number">67</td><td><span class="s">      c.y=GraphicsHeight()-c.radius</span></td></tr><tr><td class="number">68</td><td><span class="s">      c.dy=c.dy*-0.9</span></td></tr><tr><td class="number">69</td><td><span class="s">    End If</span></td></tr><tr><td class="number">70</td><td><span class="s">  Next</span></td></tr><tr><td class="number">71</td><td><span class="s">End Function</span></td></tr></tbody></table></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gary_ramsgate)</author>
		<pubDate>Sun, 24 Jun 2007 21:48:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>brilliant solution gary_ramsgate! thanks!</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Actually that&#39;s so funny
</p></div></div><p>

yeah, its funny <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" /> but its not when a whole circle is inside another circle <img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" /> which always happens in my program
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Fishcake)</author>
		<pubDate>Mon, 25 Jun 2007 18:21:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I guess your step size is somewhat equal to a circle diameter, which is too much. My own project is still at that phase where I just calculate everything and then I draw everything, no matter of fps. My step size is maybe 5 pixels while the circle diameter is 31 pixels. Separating the game loop freq from the drawing freq will probably decrease the step size, increasing the quality of the simulation.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Johan Halmén)</author>
		<pubDate>Mon, 25 Jun 2007 18:59:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Depending on what you&#39;re doing with the circles, it might make sense to use a continuous time simulation rather than discrete time stepping. That means you start each frame with knowledge of object positions and trajectories, then you work out the first time at which something touches something else. Advance to that time, do the bounce or whatever, then work out how long until the next touch. And so on until you&#39;ve reached the end of the time encapsulated by that frame.</p><p>It&#39;s SDL based, but that&#39;s what I did for my brief &quot;messing about&quot; work on a Robotron-ish thing. Check it out at the bottom of <a href="http://members.allegro.cc/ThomasHarte/index.html">this page</a> (no Windows binary, but I&#39;ll correct that later this evening) — it&#39;s not perfect but you can introduce a ridiculous number of balls onto the display and everything continues to run correctly for a very long time. Also you can move a little squashed guy around and push the balls. What fun!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Harte)</author>
		<pubDate>Mon, 25 Jun 2007 22:26:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>About that sticking, back when I was using QBASIC, one of my first games was a Ball Breaker game(you know, the one where you hit the ball with the paddle and it breaks the blocks). Anyway, sometimes the ball would get stuck on the paddle and bouce along it, then shoot off the other end. This bug turned into an interesting feature when I changed the ball into a ring, and claimed that it was supposed to do that. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Black)</author>
		<pubDate>Tue, 26 Jun 2007 02:46:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Thomas Harte said:</div><div class="quote"><p>

Depending on what you&#39;re doing with the circles, it might make sense to use a continuous time simulation rather than discrete time stepping. That means you start each frame with knowledge of object positions and trajectories, then you work out the first time at which something touches something else. Advance to that time, do the bounce or whatever, then work out how long until the next touch. And so on until you&#39;ve reached the end of the time encapsulated by that frame.
</p></div></div><p>

One way of immagining how this would work is to immagine time being turned into an extra dimension (the time between the current frame and the next frame is the start and end points). If doing 2D circle-circle collisions, the moving circles will be turned into slanted cylinders (stationary circles become regular cylinders). You should try and find out if any of the cylinders (regular or slanted) intersect in the 3D space (2 spatial dimensions + 1 temporal dimension). If there&#39;s at east one intersection find the first point in the temporal dimension (the earliest point in time) in which two cylinders overlap. At that point in time, do a static circle-circle collision check (as described previously in this thread) to find out the velocities of the circles post-collision. Afterwards, repeat the process but starting with the time of the collision instead of the time of the start of the current frame (you can save time if you&#39;ve calculated the other collisions already, but even they could be affected by the new trajectories of the collided objects). To prevent infinite iteration/recursion where the circles are colliding forever, apply some friction or slow down the circles on each collision and once the velocity drops below a certain point, set it to 0.</p><p>AE.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Andrei Ellman)</author>
		<pubDate>Sat, 30 Jun 2007 01:23:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>ok, im trying to make a carrom game. its going pretty well. except for this problem...</p><p>lets say i have this one piece of carrom, with radius 10 pixels, making its diameter 20 pixels. and the striker (the one which you are controlling) is moving with a speed of lets say, 50 pixels per frame. sometimes, the striker just go through the carrom piece when a collision is supposed to happen.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Fishcake)</author>
		<pubDate>Mon, 02 Jul 2007 17:45:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Do you have to move 50 pixels per frame? Usually, rendering a frame takes so long that if you do it in each game loop, you really have to move 50 pixels. But it might be possible that if you render the graphics only in every 50th game loop, the striker might move only one pixel and the collision detection will be easier. And the rendering rate might still be say 50 fps. If this won&#39;t work, you have to find out the collision analytically. In frame n you have two pieces at two coordinates. In frame n+1 they have moved somewhere. Find out the least distance inbetween. A bit like what Thomas and Andrei said.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Johan Halmén)</author>
		<pubDate>Tue, 03 Jul 2007 00:05:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Johan Halmén said:</div><div class="quote"><p>

my balls stick, too.
</p></div></div><p>

It must hurt! <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Roberto)</author>
		<pubDate>Tue, 03 Jul 2007 00:09:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><ul><li><p>edited and moved to a new post below *
</p></li></ul></div>]]>
		</description>
		<author>no-reply@allegro.cc (Johan Halmén)</author>
		<pubDate>Tue, 03 Jul 2007 02:11:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
And I can reduce the step size by separating the redraw rate from logic loop rate. I think.
</p></div></div><p>
It should work well for a small number of objects; any kind of billiards will be fine. When larger quantities of objects are involved, and high speeds are possible (and thus many iterations of the logic loop per frame), you may experience performance problems though. This is where space partitioning algorithms come in.</p><p>About the sticky balls: This happens if the balls travel a smaller (relative) distance in the first frame AFTER the collision than they did in the frame BEFORE, so they travel into each other further in one frame than they travel away from each other in the next one; the reason can be rounding errors, and / or the fact that you probably apply some sort of force that reduces their velocities - frictions, and maybe a constant damping factor on the collision.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Tue, 03 Jul 2007 03:52:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Here&#39;s a neat article that was featured in Game Dev Magazine: <a href="http://www.gamasutra.com/features/20000516/lander_01.htm">Physics on the Back of a Cocktail Napkin</a>.<br />If it asks for login:<br />Username: js8464@emailaccount.com<br />password: password
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Billybob)</author>
		<pubDate>Tue, 03 Jul 2007 04:49:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><ul><li><p>moved from an earlier post and edited (url didn&#39;t work)*</p></li></ul><p>I just downloaded Copernicus, a screen capture application for OSX, and did this:</p><p><a href="http://kotisivu.dnainternet.fi/johan25/bomberballs.mov">http://kotisivu.dnainternet.fi/johan25/bomberballs.mov</a> (4.4 MB)</p><p>The frame rate in the game is much better than in that video. The game needs lots of polishing and developing of the game idea. But the bouncing balls work great. The biggest step size is now about 5 pixels, while the radius is 15 pixels. And I can reduce the step size by separating the redraw rate from logic loop rate. I think.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Johan Halmén)</author>
		<pubDate>Tue, 03 Jul 2007 13:11:36 +0000</pubDate>
	</item>
</rss>

