Log In  
Follow
ioi_xd

yeah

[ :: Read More :: ]

Let me explain.

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)

This is the code in question:

  if inrange(mn,-1,1) then print("1",75,0,7) ball_spr = pad_spr end
  if inrange(mn,-2,2) then print("2",75,0,7) ball_spr = 18 end
  if inrange(mn,-3,3) then print("3",75,0,7) ball_spr = 17 end
  if inrange(mn,-4,4) then print("4",75,0,7) ball_spr = 0 end

Note the inrange function, it's basically the equivalent of a function I wish PICO-8 actually had which is "if mn >= -1 and mn <= 1". 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.

Here's 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#80570 2020-08-09 21:00 ( Edited 2020-08-09 21:01)