Pong devlog


Game Info
First player to reach 10 points wins. If the ball reaches the edge of the screen behind the player, the other player scores a point.

Controls
- Player 1:
  - W up, S down
- Player 2:
  - Up arrow up, Down arrow down
  - T: enable/disable opponent AI mode. If enabled the paddle will automatically move towards the ball

- Art was "made" myself. Most of it is just scaling a single pixel square
- The dotted centre line was made using an online editor piskelapp  www.piskelapp.com
- Super simple opponent AI just moves up or down based on where the ball's position is relative to itself.

Features attempted
When ball hits the edge of the screen it resets to the centre and moves in a random direction. 
- Prevent paddles from leaving the screen
- Display scores at top
- When a player reaches 10 points the game stops and shows a game over message
- Adds a button to allow players to start again
- Basic second player AI. I didn't add any UI elements for this, it's just toggleable with the T key
- Add different sound effects when the ball hits a paddle, when the ball hits a wall, when the ball goes off screen and when the game is over
- Ball increases speed per paddle hit. The ball also goes up or down based on if the paddle hits the ball in the top half or bottom half of the paddle. I went super basic and just reflected the ball up and down. It means the angle stays pretty much the same for the whole game.


References

- Free sound pack from unity store: https://assetstore.unity.com/packages/audio/sound-fx/free-sound-effects-pack-155..

Generative AI assistance
chat link: https://gemini.google.com/share/4ac415b22cbc
Usages
- Figuring out how to prevent the player paddles from going past the boundaries. The solution was to set the position to ensure that even if the velocity led the paddle to overshoot, it would manually set the position of the paddle to its highest or lowest points
- Figuring out how to pass an input key via serializefield. Initially I had KeyControl but that couldn't be passed it, using Key makes it work as expected
- Figuring out how to create a dotted line. One of the options was to use a half painted sprite and set it to `wrap mode: repeat`

Other code sources:
- How to reload scene to reset game https://discussions.unity.com/t/how-to-reload-a-scene/913676
- How to figure out where the collision happened relative to the other object: https://discussions.unity.com/t/location-of-collision/763179 
- KIT109 tutorial scripts. 

Files

pong Play in browser
8 hours ago

Leave a comment

Log in with itch.io to leave a comment.