Gaming With Python Pygame

Gaming With Python Pygame

ยท

3 min read

1. Introduction to Pygame ๐Ÿ’๐Ÿปโ€โ™‚๏ธ๐Ÿ’๐Ÿปโ€โ™€๏ธ

PyGame is a library of python language. It is used to develop 2-D games and is a platform where you can set python modules to develop a game. It is a user-friendly platform that helps to build games quickly and easily.

68747470733a2f2f7777772e707967616d652e6f72672f696d616765732f6c6f676f2e706e67.png

For making a game of your choice there are 3 main questions that need answering. They are as follows:

  • What sort of game do you want to build?
  • What sort of language do you want to program in?
  • What sort of platform do you want to deploy your game to?

Most of the time you can answer each of these questions and find a perfect framework that fits your requirements. Other times, it might not be possible. Consider for example, there arenโ€™t many HTML5 frameworks that allow you to write a high-performance 3D game that you can build.

For PyGame, letโ€™s assume you gave the following answers to the previous 3 questions:

  • The game you want to create is graphical, but not 3D.
  • You want to program in Python. Also, you already know a little bit of Python
  • You want to create a client application that can potentially be wrapped in a standalone executable.

2. Install Pygame in local system โš™

  • Install and check python present in your local system or not

WhatsAppImage20210415at124356PM1.jpeg

  • Install and check pip is already install in python or not

pip.jpg

  • Install pygame

insall pygame in our your local system by using this command

pip install pygame

7845.jpeg

  • Check Whether PyGame is Working or not

WhatsAppImage20210415at124356PM1.jpeg

3. Advantages of using pygame ๐ŸŽฏ

There are lots of advantages to using this python library to make codebase on building a game bacause without using this library we have to worry about graphics, timing, files and lot of things things. The advantage behind to using this package are as following:

Gaming-banner.png

  • Easy to install in local system and support any operating system

  • Pygame is a cross-platform set of Python modules which is used to create video games.

  • It consists of computer graphics and sound libraries designed to be used with the Python programming language.

  • Pygame was officially written by Pete Shinners to replace PySDL.

  • Pygame is suitable to create client-side applications that can be potentially wrapped in a standalone executable.

4. Comparison between Pygame and Pyglet ๐ŸŽฎ๐Ÿ•น

Pygame Pyglet
Easy Python syntax Pygame uses Python as its scripting language. Python is widely treated one of the most natural languages to grasp even for beginners. 3d support Since pyglet is so firmly merged with OpenGL. It allows the support of drawing in 3D.
Usage API The API is very straightforward. Cross-platform It can work with Window, Linux, and OS X.
Best canvas system Pygame provides a drawing system that allows the user to create and draw an unlimited number of the canvas. Written in pure Python It can be compiled using the other Python interpreters.
More popular Pygame is more popular than the pyglet. Less Popularity Pyglet is less popularee because it has small community support.

5. Demo ๐Ÿš€

github.com/ADITYADAS1999/python-game_pygame_1

ezgif.com-gif-maker.gif

6. References ๐Ÿ“š

๐Ÿšฉ pygame.org/news

๐Ÿšฉ github.com/pygame

๐Ÿšฉ python.org

Thats it for this blog. I hope you will try it out and learn something new. Also incase i have missed something feel free to share your thoughts and feedback. Thanks for reading.

Reachout to me ๐Ÿ‘€

Twitter๐Ÿ”—

Linkedin๐Ÿ”—

GitHub๐Ÿ”—

Did you find this article valuable?

Support ADITYA DAS by becoming a sponsor. Any amount is appreciated!

ย