Link: Pinball Machine Game
What he has created:
I have a student working on a pinball game for his final project. Instead of edgeSprites, he created sprites for his left, top, right, and diagonal walls for the pinball machine. He coded these walls to have the ball bounceOff of them and stay in play at all times unless the ball goes through the center of the flippers and into the bottom half of the game. Just like what would happen in a real pinball game. He did try edgeSprites first, but the ball did not react correctly at all in the game. The ball mostly disappeared… He also coded Flippers to have the ball bounce off of them as well. Please Note that right now, he has the right and left arrow buttons working the flippers (albeit to me opposite from what I think they should be). The up and down arrows will be eliminted. He originally had the left and rigt arrows rotating the flippers up and the up and down arrows resetting the flippers down. He figured out how to correctly code just the left and right flippers to move, but left the code in for the up and down arrows for now. I put a freeze on his coding until we got some answers on everything.
What is happening and what should happen:
- Sometimes, the flippers will shoot the ball out of play, even though the side walls are coded to have the ball bounceOff of them and keep the ball in the playing field. The ball goes out of play and disappears… This same thing happens with the very tip of the flippers - particularily the left flipper.
- Sometimes, the new ball put into play will get caught up along the top or side walls and it clings to the walls. The ball should never do this and should automatically be in play, bouncing off any walls it encounters. We have witnessed this with the top wall and the right side wall, as well as the top left corner. Any time this happens when the ball is y <70, the score will keep going up and up. We know the score is not the issue right now - as that will be fixed once the coding is correct to have those new balls bounce off of it… He did try adjusting the x and y of the new ball in play, but that still did not seem to fix the issue…
- It almost seems like there is a hidden square sprite in the middle of the game. Watching the reaction of the ball when it is hit with the flipper, often times, it will not go up in the center area of the game and it looks like the ball almost bounces off of something invisible in the center… The student used debug to see if any of his sprites needed a setCollider adjustment - but we can’t seem to find anything… I told him to keep the debug coding in the game while you all take a look at the code. The ball never seems to shoot to the stars from the flippers. Any thoughts on that? Are we missing something hidden?
Thank you all so much for any help you can give this student.