ioi_xd [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=46383 Why won't this function that returns true activate this command? <p>Let me explain.</p> <p>I'm a new to PICO-8 (this is my first post actually) but not programming. I'm looking to develop games on PICO-8 to improve my programming skills. That being said, I'm following a tutorial to make a small breakout clone, and I've decided to give it my own flair in several ways, one of which is giving the ball a smooth animation when it bounces off of a wall or the paddle. It works swimmingly when bouncing off of a wall, and I was able to make it animate when bouncing off of a paddle by forgoing the tutorial and adding my own rudimentory collision detection. The collision detection isn't the greatest, but it works and I've gotten the ball to animate when bouncing off of the paddle in the past. Today, I decided to finish up the animation by making it only play when the ball is within a certain range of the paddle. As soon as I added this functionality, the animation stopped playing, as shown in the gif below (the animation of the ball bouncing is slowed down since it's an admittedly very small detail in normal game play)</p> <img style="margin-bottom:16px" border=0 src="/media/46383/breakout_0.gif" alt="" /> <p>This is the code in question:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre> if inrange(mn,-1,1) then print(&quot;1&quot;,75,0,7) ball_spr = pad_spr end if inrange(mn,-2,2) then print(&quot;2&quot;,75,0,7) ball_spr = 18 end if inrange(mn,-3,3) then print(&quot;3&quot;,75,0,7) ball_spr = 17 end if inrange(mn,-4,4) then print(&quot;4&quot;,75,0,7) ball_spr = 0 end</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Note the inrange function, it's basically the equivalent of a function I wish PICO-8 actually had which is &quot;if mn &gt;= -1 and mn &lt;= 1&quot;. I've tried replacing the function with the actual equivalent code and it still does not activate the latter command, ball_spr = X. But, although I didn't show it in the GIF, I can confirm it activates the former print command. So what did I do wrong? Why is this function activating the print command but not the one after it? Keep in mind that without the print function it still doesn't work.</p> <p><a href="https://pastebin.com/Vft0LPZV">Here's</a> the code in question. Note that the parts I believe to be unimportant are cut out because I don't want to release all the code just yet. </p> https://www.lexaloffle.com/bbs/?tid=39163 https://www.lexaloffle.com/bbs/?tid=39163 Sun, 09 Aug 2020 21:00:32 UTC