We all have been a Gamer since childhood, some give up gaming growing up maintaining pace with life. Games have always involved us from within. While playing we not only wish to go inside game being kid but also wished to create one on our own. So, here we are having a look at an awesome library PYGAME with all you need to design a game with graphics using python that is very easy.
Have you ever tried peeping inside your system hardware and wondered how the game we are playing works? Like how do we get visual of the game, sound of it. We are interacting with it through controls all at the same time and everything happening at so near real time. How does all happened how many code are required to communicate with so many devices? We all have known programmers with shabby haircut and thick rimmed glasses. They have put so much hard work in to give us the gaming experience we cherish.
Yes it was very difficult for programmers to write codes for games to incorporate devices. They had to write device dedicated code too, this was all done to communicate with different devices. In recent times our programmers with shabby hair but less thick glasses now because of common way of communicating with graphic ,audio and input. But still the task is difficult as we have so many hardware in the market today.
Fortunately we have PYGAME that has made programming for game easy without having to think about the above details (and our programmers can now have time to go for a decent haircut).

PYGAME LIBRARY

The pygame library is an open-source module for the Python programming language specifically designed to help you make games and other multimedia applications. Built on top of the highly portable SDL (Simple Direct Media Layer) development library, pygame can be used across many platforms and operating systems. You can focus on the logic and graphics of your games without having to think about the backend complexities required for working with video and audio.
By far we came to know on why we are going for pygame now coming to how to use it so first we will set up our environment and then we will code a sample game.

Installing pygame on Ubuntu :

To install pygame for python3 (your version is 3.6.6), do this on a terminal(Ctrl+Alt+t):
Note : Python3 should be installed previously guide here
sudo apt-get install python-pygame
and then start the python interpreter
python
and then try to import pygame as –
import pygame
To set python as your default interpreter, you can set an alias in your bash_aliases file. To do this, open a terminal and type:
nano ~/.bash_aliases
This may open an empty file, depending upon whether you have set an alias before and then type
alias python=’python2′
Do not change symlinks in /usr/bin/python3, since this may break many application in Ubuntu 13.10 which use python3 vociferously.
Installing pygame for windows can be done from the link – https://www.pygame.org/download.shtml
Next we will straight way start with coding our own game with python. Link

Categorized in:

Tagged in:

, ,