Posts

Es werden Posts vom Juni, 2019 angezeigt.

How to turn your PC into a Tennis court by using pygame [Pygameを利用してパスコンをテニスコートに変更させましょう]

Bild
Turn your PC into a Tennis Court [日本語版] What if I told you that recreating the all-time classic game Pong might be significantly easier than you think? In this article I will show you a way of programming Pong on your own pc using Python. I will make use of the pygame library, which you can find more about on this link. This article will be divided in the following chapters: Creating a Screen Creating the court, pads and ball Making the ball move Making the pads move 1.) Creating the Screen Before we start building our own screen, we have to initialize pygame module in our code first. So first things first by adding the command pygame.init() to our code we are able to execute all the nice functions pygame has to offer for us. In order to create a screen/window with pygame we can make use of an in-built function which is called pygame.display.set_mode(). This function requires us to set the height as well as the width of the screen we are trying to implement. I set