Pong v. 1.0 – Pygame example

Pong 2.0

The new version of Pong now uses classes, instead of functions only and has a new way to update the page.

You will find the old code below. In this version both the bars are controlled by the mouse.

The github repository for pong.

This code is done after ArkaPyGame that is also a github repo and on itch.

 

Pong game has been updated to v. 1.0 with the players to be controlled via keyboard and mouse.

Go here to see the previous post with this code from skratch.

The code is here:

The changes

The changes are in the fact that now the player one is controlled by the mouse

Mouse coordinates

We get the coordinates of the mouse here:

This is in the while loop.

Then we send the coordinates to the sprite1 function that draws the bar on the screen. We just need the y coordinate, as the bar need to go up and down.

So, in sprite1 function, now, we just have to pass y and x1 is a global value that stays fixed.

Set the mouse invisible

To hide the mouse, before the while loop, we put this line of code

The video of the mouse controlled bar code

In this video I am trying to add the movement of the mouse to the game, having some issues to make the ball to restart when it went out of the right part of the screen. At the end the only problem is to make the ball bouce in a more interesting way, otherwise the ball is just bouncing in the same clockwise path.

Arkanoid ???

In the following code (with a video of the output) I made some changes to the code to transform pong into arkanoid. There is still the clockwise path that need to be fixed, in the next post.

This is a more recent version of Arkanoid made with pygame.

Particles in Arkapygame v. 10.0e

ArkaPyGame , the new version, has a github repo and it has an executable on itch.

Pygame's Platform Game

Other Pygame's posts