[4] Pong WIP [3/4]
- Conlan Walker

- Oct 14, 2021
- 3 min read
Updated: Oct 21, 2021
There was about 4 things, with varying levels of importance, I was aiming for this week.
I can't say I did a sufficient job at either, more so I got a rough concept implemented in one way or another. However, the 4th I didn't get around to completing at all.
Originally, I thought working on that double-bounce bug would just be a matter of disabling collisions after the initial hit, and re-enabling collisions the moment the ball is no longer overlapping. This didn't work, and I had to find something better.

My 2nd solution was to put a divider, which would be the object that the ball needs to pass through to turn collisions back on. A new problem emerged where the ball's angle of motion got so vertical that the ball flew toward and straight though the paddle several times before ever reaching that middle divider.
After a bit of thinking, I thought of the third (and hopefully final) solution:
Of course, these dividers aren't shown in normal play. They're just visible here for demo.
The horizontal dividers are pinned to the yellow anchors such that they're equidistant to the anchor at all times.
The 2nd of the 3 'completed' ideas was how to simplify a paddle's rotation to the point where touch controls would be a viable option.
Again, the progression of solutions came in a pack of 3:
The 1st idea, shown in the video above, was to have the turn direction be directly affected by the ball's y position compared to the paddle's anchor. The goal of this method was to always have the paddle swing against the ball for an optimal hit.
Unfortunately, this proved to be very annoying when the object that was above changed rapidly, making the paddle kinda just vibrate in-place and not actually do anything.
I forgot to take a video for this one, but my 2nd idea was to have the turn direction be affected by the last vertical movement. Specifically, the paddle would turn clockwise if the player moved up last, and counter-clockwise for when the player moved down last.
I didn't keep it this way for long on grounds of it being inconvenient/not fun to use.
The third way of dealing with this is a product of me just wanting to steer my attention to anything else. What I added in its place was just a fixed rotation with a bias toward the paddle's north side.
The hardest thing this week of getting the index of the image point the ball was closest to on a paddle. I couldn't just do an ugly one-line clamp() chain, because I needed the index, too.
It took me a longer time than I'd care to admit before I admitted defeat and just asked for help.
For loops were apparently the answer to my problem, and the implementation went like so:

This image was intentionally cropped from the right side to accommodate Wix's handling of image ratios. The actual expression that was cropped went:
distance(bar1.ImagePointX(loopindex("test")),bar1.ImagePointY(loopindex("test")),ball.X,ball.Y)
This just gets the distance from a specified image point to the ball.

The actual function as a whole runs through all 5 image points, shown in the image above, and returns the index of the closest point to the ball.
To integrate the newly completed function, all I had to do was call it inside a desired expression. I ran into a problem when trying to display its output with text, and it turns out:

Construct 3 doesn't seem to like the calling of parameterless functions using parentheses.

I don't know why this should work but it just does.
And the expression that puts it into practice goes:
ball.Bullet.Speed=ball.Bullet.Speed*(1+0.1*(Functions.bar1_ip_min/4))
Depending on where the ball hits, the ball's speed should be multiplied anywhere between 1x and 1.1x. I'll also add this only occurs when the paddle is considered to be rotating at the time of a hit. This is how the game works in its current state:
The number in the bottom-left corner is the speed of the ball, so you can see it increase for just about every hit of the paddle.
The 4th thing that I didn't bother to do this week is making the ball bias toward a horizontal angle of movement.
I haven't quite reintroduced touch controls yet, and thus haven't seen how well they'd work.
So yeah, that's basically it. I'm not too thrilled about working on this again next week, so I'll either cram to finish during the weekend, or think over the weekend a way to quickly end this next week. Probably the latter.

![[158] Most Important Brick in the Least Important Wall](https://static.wixstatic.com/media/df100d_f70be6ae4318455fbbc605cd1069c6ee~mv2.jpg/v1/fill/w_980,h_410,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/df100d_f70be6ae4318455fbbc605cd1069c6ee~mv2.jpg)
![[157] Mail Order Sacrifice](https://static.wixstatic.com/media/df100d_e284fa6c51b04524bab9d3cf9f1f6441~mv2.png/v1/fill/w_980,h_382,al_c,q_90,usm_0.66_1.00_0.01,enc_avif,quality_auto/df100d_e284fa6c51b04524bab9d3cf9f1f6441~mv2.png)
![[156] Moat of Babble](https://static.wixstatic.com/media/df100d_091e451794b14aecb494a16c15c966c3~mv2.png/v1/fill/w_980,h_705,al_c,q_90,usm_0.66_1.00_0.01,enc_avif,quality_auto/df100d_091e451794b14aecb494a16c15c966c3~mv2.png)
Comments