Today I was watching Roland Garros on the TV when I figured I would waste less my time playing with PICO-8 and so I did ... another pong.
The code is quite simple and should help beginners starting with PICO-8 programming
It supports different bouncing angles - I store them in a table for each pixel of the paddle (8 pixels high) :
angles={-1.2,-0.8,-0.5,-0.2,0.2,0.5,0.8,1.2} ... b.dy=angles[flr(b.y-p1y)+1] |
At first, player2 (p2) was always following the ball and was unbeatable... so I modified it to only follow the ball when it is in the right half of the screen - I found this solution giving a good difficulty level - you can raise it if you increase the area where it "sees" the ball :
-- p2 follows the ball, only if the ball is on the right side of the screen if (b.x>64 and p2y+4>b.y ) p2y-=1 if (b.x>64 and p2y+4<b.y ) p2y+=1 |
Enjoy !
[Please log in to post a comment]