It has been for a while since I have stopped writing about Pygame related topic on this website and today I will start to write about it again because there are 5 ongoing gaming projects that I have developed recently using Pygame and I would really like to show you one of them in this website from start to finish. If you want to know all about this project make sure you visit this website every week to see the latest post about my latest Pygame project.
I have selected PyCharm as the Python IDE for my next Pygame development which is not surprise at all because it is the only real deal in the market when it comes to the best IDE for Python application development. I have considered using Eclipse before because Eclipse is indeed the best IDE when it comes to writing and developing application but unfortunately Eclipse does not have the stand alone version just for the software development in Python, we will need to install PyDev plugin in Eclipse before we can develop application written with Python. So PyCharm is the one to go for. Basically PyCharm consists of the Community and Professional version. If you need Full-featured IDE for Python & Web development then go for the paid Professional version, I will use the free Community version for my Pygame development because the free version is more than enough if you just need a Lightweight IDE for Python & Scientific development. Go ahead to www.jetbrains.com then decide which version of PyCharm you would like to install.
After you have downloaded PyCharm then follow the step by step installation instructions to install this IDE on windows 10 os.
Next is to install Pygame, open up the windows command prompt and type in
pip install Pygame==1.9.4
to download and install Pygame from pypi.org and that is it!
Now it is time to see whether Pygame has been installed successfully or not, Launch PyCharm then go to the File menu and select New Project.
Provide the Project folder name together with the folder location and click on the create button.
One last thing you will need to do before you can start coding and that is to set the location of the project interpreter, so go ahead and select File->Settings then type ‘interpreter’ into the search box on the left pane and select the location on your disk where you have installed the Python program on the right pane then click the Apply and OK button.
Now lets create a python file, write some code and run pygame. Right click on the project folder under file explorer then select New->Python File from the pop up. Type a name for your python file with .py extension into the Name field then click on the ok button.
That is it, now click on the empty python file you have just created on the left pane and enter below code into the code editor.
import sys, pygame from pygame import Color pygame.init() size = width, height = 600, 600 screen = pygame.display.set_mode(size) while True: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() screen.fill(Color(25, 100, 200, 255)) pygame.display.flip()
Next goto the Run menu then select Run ‘file name’, PyCharm will first debug the python program and if there is no error then it will run the program and this is what we will see. The code will be automatically saved each time you have debugged the program.
OK so much for today, just to remind you all that I will write a new Pygame development series story on this website from start to finish so do come back again to read more Pygame development stories on this website under the Pygame category. If you like this post then don’t forget to share it!